W3C home > Mailing lists > Public > whatwg@whatwg.org > September 2013

Re: [whatwg] Stroking algorithm in Canvas 2d

From: Rik Cabanier <cabanier@gmail.com>
Date: Thu, 12 Sep 2013 16:28:09 -0700
Message-ID: <CAGN7qDDfcvmrJciqPDhJ_YPT=n4caMRZTAQ_SgYwE1pjPx5iYA@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>
Cc: "whatwg@whatwg.org" <whatwg@whatwg.org>, syhann@adobe.com
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.
Received on Thursday, 12 September 2013 23:28:41 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:09 UTC