Stroke width rounding errors

Bug #168002 reported by Jusme on 2006-09-30
This bug affects 1 person
Affects Status Importance Assigned to Milestone
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:

width="479.00003" />

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

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) on 2007-12-12
Changed in inkscape:
importance: Undecided → Medium
status: New → Incomplete
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

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)

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

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

Hi Jusme / Ryan / Tom,

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


Changed in inkscape:
status: Confirmed → Incomplete
su_v (suv-lp) on 2010-06-29
tags: added: transformations
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

@~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) on 2012-08-28
tags: added: precision
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers