[whatwg] Stroking algorithm in Canvas 2d

Rik Cabanier cabanier at gmail.com
Mon Oct 28 10:39:31 PDT 2013

On Mon, Oct 28, 2013 at 7:04 AM, Justin Novosad <junov at google.com> wrote:

> On Sun, Oct 27, 2013 at 10:36 PM, Rik Cabanier <cabanier at gmail.com> wrote:
>>  The outline should be done in such a way that it is not affected by
>> winding.
> Why is that important? Enforcing that can add a lot of complexity to cases
> of self intersecting strokes, or line caps that overlap (
> http://jsfiddle.net/aBmZ4/2/).  Today, these problems are easy to solve
> correctly by using a non-zero fill.

Hi Justin,

this was for APIs that calculates the outline/path of a stroke. Regular
strokes can use nzo-fill (if they're implemented by drawing paths).
Being winding agnostic is more author friendly. Otherwise the author would
have to remember that the other winding would give bad results. I've relied
on this behavior of our path optimizer many times in the past.
Compared to how difficult it is to get a useful outlined stroke, reversing
paths is very easy.

A "useful" stroke needs to remove subsections that have a color on both
I've attached an example outlined_stroke.png.
Example 1 is a dashed stroke where the endcaps overlap
Example 2 is the path that is calculated by the stroking algorithm and
filled with NZO
Example 3 is the path that describes the region of the stroke and is what
would be useful for an author

More information about the whatwg mailing list