NEW 202516
Implement 2d.path.rect so that it matches the winding rule
https://bugs.webkit.org/show_bug.cgi?id=202516
Summary Implement 2d.path.rect so that it matches the winding rule
Chris Lord
Reported 2019-10-03 02:25:33 PDT
This test fails on both MacOS and iOS with: FAIL Canvas test: 2d.path.rect.winding assert_equals: Red channel of the pixel at (25, 12) expected 0 but got 255
Attachments
rendering in safari, firefox, chrome (387.72 KB, image/png)
2024-05-14 04:55 PDT, Karl Dubost
no flags
Radar WebKit Bug Importer
Comment 1 2024-02-08 15:14:28 PST
Karl Dubost
Comment 2 2024-05-14 04:55:34 PDT
Created attachment 471399 [details] rendering in safari, firefox, chrome Test is failing in Safari, and passing in Firefox and Chrome.
Karl Dubost
Comment 3 2024-05-14 05:34:30 PDT
From https://html.spec.whatwg.org/multipage/canvas.html#fill-rule The CanvasFillRule enumeration is used to select the fill rule algorithm by which to determine if a point is inside or outside a path. The value "nonzero" value indicates the nonzero winding rule, wherein a point is considered to be outside a shape if the number of times a half-infinite straight line drawn from that point crosses the shape's path going in one direction is equal to the number of times it crosses the path going in the other direction. The "evenodd" value indicates the even-odd rule, wherein a point is considered to be outside a shape if the number of times a half-infinite straight line drawn from that point crosses the shape's path is even. If a point is not outside a shape, it is inside the shape.
Karl Dubost
Comment 4 2024-05-14 05:50:27 PDT
// Drawing a green rectangle with a width of 100 and a height of 50 ctx.fillStyle = '#0f0'; ctx.fillRect(0, 0, 100, 50); // start the path ctx.beginPath(); // set the color to red. ctx.fillStyle = '#f00'; // draw a square on the left side ctx.rect(0, 0, 50, 50); // draw a square on the right side ctx.rect(100, 50, -50, -50); // draw a rectangle on the top side ctx.rect(0, 25, 100, -25); // draw a rectangle on the bottom side ctx.rect(100, 25, -100, 25); // finish the path by filling ctx.fill(); The shape at the end is not closed at all. The paths defines cross inside the rectangle.
Note You need to log in before you can comment on or make changes to this bug.