[whatwg] Dashed strokes on <canvas>

Henri Sivonen hsivonen at iki.fi
Thu May 10 07:39:05 PDT 2007


On May 9, 2007, at 22:51, Philip Taylor wrote:

> The common graphics APIs (at least
> Cairo, Quartz and java.awt.Graphics, and any SVG implementation) all
> have dashes specified by passing an array of dash lengths (alternating
> on/off), so that should be alright as long as you define what units
> it's measured in and what happens when you specify an odd number of
> values and how errors are handled and what happens if you update the
> array later.

Naïvely, one might expect the right answer to be "Do whatever Adobe's  
PostScript implementation does."

Has anyone tested if the expected <canvas> back end libraries (Quartz  
2D, Cairo, whatever they call the 2D stuff under WPF, Java 2D) follow  
PostScript faithfully in the case of dashed strokes?

> But after that, what does it do when stroking multiple subpaths, in  
> terms of offsetting the dashes?

"Each subpath of a path is treated independently; the dash pattern is  
restarted and the offset reapplied at the beginning of each subpath."  
– PostScript Language Reference, 3rd ed. p. 667

> How does it interact with lineCap/lineJoin?

"Dashed strokes wrap around curves and corners in the same way as  
solid strokes. The ends of each dash are treated with the current  
line cap, and corners within a dash are treated with the current line  
join." – PostScript Language Reference, 3rd ed. p. 666

-- 
Henri Sivonen
hsivonen at iki.fi
http://hsivonen.iki.fi/





More information about the whatwg mailing list