This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 20612 - Canvas 2D Context needs to support fillRule attribute
Summary: Canvas 2D Context needs to support fillRule attribute
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML Canvas 2D Context (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Jay Munro
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-09 00:50 UTC by Jatinder Mann [MSFT]
Modified: 2013-03-21 16:34 UTC (History)
5 users (show)

See Also:


Attachments

Description Jatinder Mann [MSFT] 2013-01-09 00:50:46 UTC
Developers should be able to specify which fill rule to use, even-odd or non-zero winding rule, when painting a geometry created by sub-paths. Whereas SVG and other technologies support both fill rules, Canvas 2D Context currently only supports non-zero winding rule.

I recommend we update the specification to include support for the following attribute on the CanvasRenderingContext2D interface, with a default value of “nonzero” to be compatible with current Canvas sites and apps.

attribute DOMString fillRule; // "evenodd", "nonzero" (default: "nonzero")

I recommend updating “Section 12 Drawing paths to the canvas” with language similar to the SVG fill-rule property, http://www.w3.org/TR/SVG/painting.html. An example of text could be:

"The fillRule attribute represents the algorithm which is used to determine which subpaths are considered inside a closed path. The two valid values are nonzero and evenodd.

On getting, it must return the current value. On setting, if the new value is one of the literal strings nonzero, or evenodd, then the current value must be changed to the new value; other values must be ignored, leaving the value unchanged.

"Nonzero"
This fill rule determines whether an independent subpath is inside a closed path by drawing a ray from a point inside the subpath to infinity in any direction and then examining the places where the subpaths of the path crosses the ray. Starting with a count of zero, add one each time a subpath crosses the ray from left to right and subtract one each time a subpath crosses the ray from right to left. After counting the crossings, if the result is zero then the point is outside the closed path. Otherwise, it is inside. 

"evenodd"
This fill rule determines whether an independent subpath is inside a closed path by drawing a ray from a point inside the subpath to infinity in any direction and counting the number of subpaths of the path that the ray crosses. If this number is odd, the point is inside; if even, the point is outside."

Definitions of fill(), clip(), and isPointInPath() methods would need to be updated.
Comment 1 Jay Munro 2013-03-18 22:41:31 UTC
EDITOR'S RESPONSE: 
This is an Editor's Response to your comment. If
you are satisfied with this response, please change the state of
this bug to CLOSED. If you have additional information and would
like the Editor to reconsider, please reopen this bug. If you would
like to escalate the issue to the full HTML Working Group, please
add the TrackerRequest keyword to this bug, and suggest title and
text for the Tracker Issue; or you may create a Tracker Issue
yourself, if you are able to do so. For more details, see this
document:
       http://dev.w3.org/html5/decision-policy/decision-policy.html



Status: Fixed
Change Description: https://github.com/w3c/html/commit/02b587dd054416de2f240fe86b780c95132f9463
Rationale: New feature added for Context 2d L2.
Comment 3 Jay Munro 2013-03-21 16:34:08 UTC
WhatWG bug:  https://www.w3.org/Bugs/Public/show_bug.cgi?id=21077