Re: [whatwg] Canvas: even-odd winding rule fills

Hi James,

this features is not a trivial as it seems. Adding this will necessitate
updates to the algorithms that deal with paths and the outlining of strokes
and text.
As Dirk mentioned, instead of making it part of the graphics state, it's
more likely better to make it part of the fill or clip operator like SVG,
PDF and PostScript.
In addition, the path object will need to be extended so it can deal with
this idiom.

The easiest way to implement this, would be to leave the core interface of
canvas alone and just extend the path object with winding rules and a
method to 'simplify' a path so it can be drawn with any winding rule.
Looking at Skia, Adobe's internal libraries and lib2geom, this should be
fairly easy to implement. It would make eofill a bit slower, but since it's
not as common, it's probably not an issue.

On Wed, Jan 2, 2013 at 3:40 AM, James Ascroft-Leigh <jwal@jwal.me.uk> wrote:

> All,
>
> I recently discovered that a common and well understood 2D graphics
> operation is not supported by the 2D canvas API even though it is supported
> by almost every other modern 2D graphics API.  This missing feature is
> called even-odd fill and controls how the fill region is calculated for
> self-intersecting paths or enclosed subpaths.
>
> This is already implemented in Mozilla Firefox as the mozFillRule property
> of the 2D canvas drawing context which can take the values "nonzero"
> (default) and "evenodd".  The feature is used by projects such as pdf.js
> for rendering PDFs to the canvas.
>
> I am working on adding similar functionality to WebKit (for Apple Safari,
> Google Chrome and other related browsers).  This is actually really easy as
> the backend drawing APIs already have the necessary features to support SVG
> rendering.
>
> The suggestion has been made that this is added as an unprefixed fillRule
> property and incorporated into the HTML standard.  This has been mentioned
> on this list before but there hasn't really been much discussion. Please
> see the links below for more information if you are interested.
>
>    * Webkit patch: https://bugs.webkit.org/show_bug.cgi?id=105508
>    * W3 "bug": https://www.w3.org/Bugs/Public/show_bug.cgi?id=19932
>    * pdf.js issue: https://github.com/mozilla/pdf.js/issues/2351
>
> Post to the list if you have any comments about the proposal or if you
> think you can help me.
>
> Thanks,
>
> James
>

Received on Wednesday, 2 January 2013 18:07:55 UTC