Opened 12 years ago

Closed 4 years ago

#5171 closed enhancement (patchwelcome)

Allow stroke width to be specified in absolute units

Reported by: guest Owned by: Eugene Lazutkin
Priority: high Milestone: 1.13
Component: DojoX GFX Version: 1.0
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by dylan)

Filing this request per forum post http://www.dojotoolkit.org/forum/dojox-dojox/dojox-support/gfx-constant-stroke-width :

I'm new to the whole svg thing. Is there a way for me to get the stroke width on a shape to remain a constant pixel size regardless of how the shape is scaled? I'm working mostly with tiled rectangles. I want the border between them to stay one pixel wide regardless of the unit size of the rectangles or the size at which they are scaled. For example, if I have a square that has width and height of 100, I want the border to be one pixel. If I scale it by 10, I still want the border to be one pixel, and not grow to a fat line.

Change History (9)

comment:1 Changed 12 years ago by Eugene Lazutkin

Milestone: 1.0.2
Status: newassigned

comment:2 Changed 12 years ago by Adam Peller

Milestone: 1.0.21.0.3

comment:3 Changed 12 years ago by guest

--- From Jayant (jayant dot b dot sai at gmail dot com) ---

Adding some more content to this bug.

If I add a simple rect to the surface,

rect = surface.createRect({x:-50, y:-50, width:100, height:100}).setStroke({width:2});

Now when I apply a scale transform to the rect

rect.applyTransform(dojox.gfx.matrix.scale(2));

the behavior is different in IE & FF/Safari. In IE (VML), the stroke width remains constant, where as in FF/Safari (SVG), the stroke width scales as well. Thus the behaviors are different in the 2 implementations. I am hoping to get the implementation to be consistent.

--- From Eugene ---

It's the known difference between VML and SVG. The former doesn't scale strokes, the latter does. I believe that the SVG's default is more sane. I am not sure if it's even possible to implement the non-scaling behavior in SVG. The only way to implement this behavior in VML is to manually scale all relevant parameters and re-apply the stroke. I image it will slow down the VML renderer considerably --- this is the reason why it is not implemented.

comment:4 Changed 11 years ago by dylan

Milestone: 1.0.31.2

comment:5 Changed 11 years ago by Eugene Lazutkin

Milestone: 1.2future

Moving all open ticketd to the future.

comment:6 Changed 10 years ago by Stefan Bird

The difference between VML and SVG is currently undocumented - could you please add it as an "Implementation detail" in the API reference?

Thanks

comment:7 Changed 9 years ago by futuraprime

Fixed-width strokes are implemented in SVG with the vector-effect property "non-scaling-stroke"; see http://www.w3.org/TR/SVGTiny12/painting.html#NonScalingStroke.

As of writing, Safari (5.0.3) and Firefox (3.6.12) do not support it in their SVG renderers. Chrome (7.0.517.44) does.

comment:8 Changed 8 years ago by vvoovv

Here is the status of "non-scaling-stroke" for Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=528332 Vote for it there :)

comment:9 Changed 4 years ago by dylan

Description: modified (diff)
Milestone: future1.12
Resolution: patchwelcome
Status: assignedclosed

Given that no one has shown interest in creating a patch in the past 8 years, I'm closing this as patchwelcome. Note that FF fixed the issue linked 5 years ago.

Note: See TracTickets for help on using tickets.