Stroke width rounding errors

Bug #168002 reported by Jusme
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Inkscape
Invalid
Medium
Diederik van Lierop

Bug Description

inkscape version: 0.44.1, built Sep 7 2006

Stroke width gets modified slightly when changing an
object even with "Scale stroke width" unchecked,
resulting in creeping rounding errors.

To demonstrate: Create simple rectangle with "Snap
bounding boxes to grid" set, grid = 1px, set stroke
width to 1 and save:

<rect
id="rect3268"
style="opacity:1;fill:none;fill-opacity:1;stroke:#5800e9;stroke-width:1;str
oke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffse
t:0;stroke-opacity:1"
y="10.499965"
x="10.500224"
height="478.99966"
width="479.00003" />

This is correct. Then reshape rectangle (stretch one
side for example) and save again:

<rect
id="rect3268"
style="opacity:1;fill:none;fill-opacity:1;stroke:#5800e9;stroke-width:0.999
99988;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-
dashoffset:0;stroke-opacity:1"
y="10.499965"
x="10.500221"
height="478.99966"
width="488.99963" />

Now stroke-width is 0.99999988, although this is
displayed as "1.000" in the stroke style dialog.

This has a knock-on effect on the x/y/width/height
values, resulting in imprecise values
(478.99966,488.99963 instead of 479/489)

Ryan Lerch (ryanlerch)
Changed in inkscape:
importance: Undecided → Medium
status: New → Incomplete
Revision history for this message
Tom Davidson (tjd-mit) wrote :

Confirmed under Linux in today's SVN (rev 17236). Almost certainly related to bug 174046...

Changed in inkscape:
status: Incomplete → Confirmed
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

There are likely two different problems: a rounding problem and a snapping problem (bug 174046). The latter has been resolved, but there are still some rounding issues left....

Changed in inkscape:
assignee: nobody → Diederik van Lierop (mail-diedenrezi)
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

Does it help if you increase the numeric precision of the svg output in the preferences dialog? (prefs -> SVG output -> numeric precision). Mine was set to 7, but changing it back to the default value of 8 already made this problem disappear. Please try setting it to e.g. 16 and let me know if this problem is still reproducible

Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

I'm adding a stack trace here, just for my own reference in case I need to dive into this a bit deeper

Thread [1] (Suspended: Breakpoint hit.)
 64 sp_svg_transform_write() /home/diedenrezi/eclipse/InkscapeSVN/src/svg/svg-affine.cpp:162 0x00000000007b499f
 63 sp_item_write() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-item.cpp:697 0x00000000004fcb74
 62 sp_lpe_item_write() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-lpe-item.cpp:294 0x000000000050e9b1
 61 sp_shape_write() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-shape.cpp:237 0x00000000005324dc
 60 sp_rect_write() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-rect.cpp:215 0x000000000052fac3
 59 SPObject::updateRepr() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-object.cpp:1220 0x000000000051904d
 58 SPObject::updateRepr() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-object.cpp:1193 0x0000000000519146
 57 sp_item_adjust_stroke() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-item.cpp:1276 0x00000000004f6896
 56 sp_item_adjust_stroke_width_recursive() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-item.cpp:1305 0x00000000004f929c
 55 sp_item_write_transform() /home/diedenrezi/eclipse/InkscapeSVN/src/sp-item.cpp:1428 0x00000000004f960e
 54 sp_selection_apply_affine() /home/diedenrezi/eclipse/InkscapeSVN/src/selection-chemistry.cpp:1287 0x00000000004ab31f
 53 sp_object_layout_any_value_changed() /home/diedenrezi/eclipse/InkscapeSVN/src/widgets/select-toolbar.cpp:259 0x0000000000bbf5b8
 52 g_closure_invoke() 0x0000003e9c20b7dd
 51 <symbol is not available> 0x0000003e9c2214bd
 50 g_signal_emit_valist() 0x0000003e9c222b68
 49 g_signal_emit() 0x0000003e9c223093
 48 IA__gtk_adjustment_value_changed() /usr/src/debug/gtk+-2.14.7/gtk/gtkadjustment.c:668 0x00000038b9271c22
 47 IA__gtk_spin_button_set_value() /usr/src/debug/gtk+-2.14.7/gtk/gtkspinbutton.c:1957 0x00000038b938cc9b
 46 IA__gtk_spin_button_update() /usr/src/debug/gtk+-2.14.7/gtk/gtkspinbutton.c:2286 0x00000038b938ce43

Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

Hi Jusme / Ryan / Tom,

Can any of you try increasing the precision as suggested above and see if this is still reproducible?

Thanks!

Changed in inkscape:
status: Confirmed → Incomplete
su_v (suv-lp)
tags: added: transformations
Revision history for this message
su_v (suv-lp) wrote :

> try increasing the precision as suggested above and see if this is still reproducible?

Inkscape 0.47+devel r9542 on OS X 10.5.8
- rectangle with no fill, stroke-width 10px
- grid spacing 1px, snap to visible lines, zoom 100%
- tested with both visual and geometric bbox mode
- tested with both snap bbox corners or snap nodes to grid
- verified by watching live updates in the XML Editor

Precision 8 (default): reproduced - sometimes the stroke width gets modified slightly, most of the times the x/y and/or height/width parameters of the rectangle have rounding errors, not displayed in the select controls bar fields.

Precision 16: still reproducible but not consistently: randomly and rarely seen rounding errors of the stroke width, mostly when dragging the left bounding box edge (de-/increasing the width of the rectangle). The x, y, width and height parameters show no rounding errors when precision is raised to 16.

Possibly related to bug #190557 in Inkscape: “resize of object or group by entering a numeric size results in a different size.”?
(still reproducible in current 0.47+devel builds, shows varying rounding errors of shape position and dimension however rarely affects stroke-width attribute)

Changed in inkscape:
status: Incomplete → Confirmed
Revision history for this message
Diederik van Lierop (mail-diedenrezi) wrote :

@~suv: When using rev. #10636 (or newer): Do you notice a difference between ellipses & stars on one hand, vs. using paths & rectangles on the other hand?

John Smith (john-smithi)
tags: added: precision
mray (mrayyyy)
tags: added: bug-migration
Revision history for this message
mray (mrayyyy) wrote :

Hi - thanks for reporting this bug, I've manually migrated it to Inkscape's new
bug tracker on GitLab, and closed it here.

Please feel free to file new bugs about the issues you're seeing at
http://inkscape.org/report.

Moved to: https://gitlab.com/inkscape/inbox/issues/323
Closed by: https://gitlab.com/mray

Changed in inkscape:
status: Confirmed → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.