[whatwg] Stroking algorithm in Canvas 2d
Rik Cabanier
cabanier at gmail.com
Thu Sep 12 16:28:09 PDT 2013
Maybe we can start by extracting dashing from the pseudo code.
The process of dashing should break up every subpath in a bunch of new
subpaths. This new collection of subpaths can then be stroked.
Currently the spec says:
1 Let width be the aggregate length of all the lines of all the subpaths in
path, in coordinate space units.
2 Let offset be the value of the styles lineDashOffset, in coordinate space
units.
3 While offset is greater than width, decrement it by width.
4 While offset is less than width, increment it by width.
For 1, dashing should be applied to each subpath. As the PDF reference
manual says:
When a path consisting of several subpaths is stroked, each subpath shall
be treated independently—that is, the dash pattern shall be restarted and
the dash phase shall be reapplied to it at the beginning of each subpath.
2 - 4 are not correct. From the PDF reference:
Before beginning to stroke a path, the dash array shall be cycled through,
adding up the lengths of dashes and gaps. When the accumulated length
equals the value specified by the dash phase, stroking of the path shall
begin, and the dash array shall be used cyclically from that point onward.
So, this cycling should be done on the dash array and not the length of the
path that it applies to.
More information about the whatwg
mailing list