[whatwg] Stroking algorithm in Canvas 2d
junov at google.com
Mon Oct 28 11:05:47 PDT 2013
If I understand correctly, the need to produce a path that is winding
agnostic is for cases where we are not stroking to the display. It is for
cases where the API produces a stored path that could be further
manipulated. The only examples of this that come to my mind right now are
the addPathByStrokingPath and addPathByStrokingText methods of the Path
object interface. Is that what you had in mind? Perhaps the requirement
for generating winding agnostic paths should be specific to those two
Also it may be helpful to provide an accurate/formal description of what
winding agnostic means. I think I have a good idea of what it means: line
cross count is 0 or 1 at any given point. Correct? I am sure these are
solved problems and there must be plenty of literature on the subject, but
it would be great to provide either algortihms or references to algorithms
for converting paths that are meant to be filled with a given winding rule
into a winding agnostic representation that produces the same result.
On Mon, Oct 28, 2013 at 1:39 PM, Rik Cabanier <cabanier at gmail.com> wrote:
> 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
>> 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