Skip to content

Commit 6532f1d

Browse files
committed
Bug 1979523 [wpt PR 53993] - canvas: Respect FillRule, a=testonly
Automatic update from web-platform-tests Add test for fill/clip with evenodd Signed-off-by: sagudev <16504129+sagudevusers.noreply.github.com> -- wpt-commits: 5a64c2271b227730463694024e0f7daeecfa319b wpt-pr: 53993 UltraBlame original commit: 70fbd4b46298d2584418b61eb1a12996ca530010
1 parent ce27372 commit 6532f1d

13 files changed

+504
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>Canvas test: 2d.path.clip.winding.evenodd.1</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
9+
<body class="show_output">
10+
11+
<h1>2d.path.clip.winding.evenodd.1</h1>
12+
<p class="desc">evenodd winding number rule works in clip</p>
13+
14+
15+
<p class="output">Actual output:</p>
16+
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
17+
18+
<ul id="d"></ul>
19+
<script>
20+
var t = async_test("evenodd winding number rule works in clip");
21+
_addTest(function(canvas, ctx) {
22+
23+
ctx.fillStyle = '#0f0';
24+
ctx.fillRect(0, 0, 100, 50);
25+
26+
ctx.beginPath();
27+
ctx.rect(0, 0, 100, 50);
28+
ctx.rect(0, 0, 100, 50);
29+
30+
ctx.fillStyle = "#f00";
31+
ctx.clip("evenodd");
32+
ctx.fillRect(0, 0, 100, 50);
33+
34+
_assertPixel(canvas, 50,25, 0,255,0,255);
35+
36+
});
37+
</script>
38+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>Canvas test: 2d.path.clip.winding.evenodd.2</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
9+
<body class="show_output">
10+
11+
<h1>2d.path.clip.winding.evenodd.2</h1>
12+
<p class="desc">evenodd winding number rule works in clip</p>
13+
14+
15+
<p class="output">Actual output:</p>
16+
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
17+
18+
<ul id="d"></ul>
19+
<script>
20+
var t = async_test("evenodd winding number rule works in clip");
21+
_addTest(function(canvas, ctx) {
22+
23+
ctx.fillStyle = '#0f0';
24+
ctx.fillRect(0, 0, 100, 50);
25+
26+
let path = new Path2D();
27+
path.rect(0, 0, 100, 50);
28+
path.rect(0, 0, 100, 50);
29+
path.closePath();
30+
31+
ctx.fillStyle = "#f00";
32+
ctx.clip(path, "evenodd");
33+
ctx.fillRect(0, 0, 100, 50);
34+
35+
_assertPixel(canvas, 50,25, 0,255,0,255);
36+
37+
});
38+
</script>
39+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>Canvas test: 2d.path.fill.winding.evenodd.1</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
9+
<body class="show_output">
10+
11+
<h1>2d.path.fill.winding.evenodd.1</h1>
12+
<p class="desc">evenodd winding number rule works in fill</p>
13+
14+
15+
<p class="output">Actual output:</p>
16+
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
17+
18+
<ul id="d"></ul>
19+
<script>
20+
var t = async_test("evenodd winding number rule works in fill");
21+
_addTest(function(canvas, ctx) {
22+
23+
ctx.fillStyle = '#0f0';
24+
ctx.fillRect(0, 0, 100, 50);
25+
26+
ctx.beginPath();
27+
ctx.rect(0, 0, 100, 50);
28+
ctx.rect(0, 0, 100, 50);
29+
30+
ctx.fillStyle = "#f00";
31+
ctx.fill("evenodd");
32+
33+
_assertPixel(canvas, 50,25, 0,255,0,255);
34+
35+
});
36+
</script>
37+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>Canvas test: 2d.path.fill.winding.evenodd.2</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
<link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css">
9+
<body class="show_output">
10+
11+
<h1>2d.path.fill.winding.evenodd.2</h1>
12+
<p class="desc">evenodd winding number rule works in fill</p>
13+
14+
15+
<p class="output">Actual output:</p>
16+
<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
17+
18+
<ul id="d"></ul>
19+
<script>
20+
var t = async_test("evenodd winding number rule works in fill");
21+
_addTest(function(canvas, ctx) {
22+
23+
ctx.fillStyle = '#0f0';
24+
ctx.fillRect(0, 0, 100, 50);
25+
26+
let path = new Path2D();
27+
path.rect(0, 0, 100, 50);
28+
path.rect(0, 0, 100, 50);
29+
path.closePath();
30+
31+
ctx.fillStyle = "#f00";
32+
ctx.fill(path, "evenodd");
33+
34+
_assertPixel(canvas, 50,25, 0,255,0,255);
35+
36+
});
37+
</script>
38+
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>OffscreenCanvas test: 2d.path.clip.winding.evenodd.1</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
9+
<h1>2d.path.clip.winding.evenodd.1</h1>
10+
<p class="desc">evenodd winding number rule works in clip</p>
11+
12+
13+
<script>
14+
var t = async_test("evenodd winding number rule works in clip");
15+
var t_pass = t.done.bind(t);
16+
var t_fail = t.step_func(function(reason) {
17+
throw reason;
18+
});
19+
t.step(function() {
20+
21+
var canvas = new OffscreenCanvas(100, 50);
22+
var ctx = canvas.getContext('2d');
23+
24+
ctx.fillStyle = '#0f0';
25+
ctx.fillRect(0, 0, 100, 50);
26+
27+
ctx.beginPath();
28+
ctx.rect(0, 0, 100, 50);
29+
ctx.rect(0, 0, 100, 50);
30+
31+
ctx.fillStyle = "#f00";
32+
ctx.clip("evenodd");
33+
ctx.fillRect(0, 0, 100, 50);
34+
35+
_assertPixel(canvas, 50,25, 0,255,0,255);
36+
t.done();
37+
38+
});
39+
</script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
3+
4+
5+
6+
importScripts("/resources/testharness.js");
7+
importScripts("/html/canvas/resources/canvas-tests.js");
8+
9+
var t = async_test("evenodd winding number rule works in clip");
10+
var t_pass = t.done.bind(t);
11+
var t_fail = t.step_func(function(reason) {
12+
throw reason;
13+
});
14+
t.step(function() {
15+
16+
var canvas = new OffscreenCanvas(100, 50);
17+
var ctx = canvas.getContext('2d');
18+
19+
ctx.fillStyle = '#0f0';
20+
ctx.fillRect(0, 0, 100, 50);
21+
22+
ctx.beginPath();
23+
ctx.rect(0, 0, 100, 50);
24+
ctx.rect(0, 0, 100, 50);
25+
26+
ctx.fillStyle = "#f00";
27+
ctx.clip("evenodd");
28+
ctx.fillRect(0, 0, 100, 50);
29+
30+
_assertPixel(canvas, 50,25, 0,255,0,255);
31+
t.done();
32+
});
33+
done();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>OffscreenCanvas test: 2d.path.clip.winding.evenodd.2</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
9+
<h1>2d.path.clip.winding.evenodd.2</h1>
10+
<p class="desc">evenodd winding number rule works in clip</p>
11+
12+
13+
<script>
14+
var t = async_test("evenodd winding number rule works in clip");
15+
var t_pass = t.done.bind(t);
16+
var t_fail = t.step_func(function(reason) {
17+
throw reason;
18+
});
19+
t.step(function() {
20+
21+
var canvas = new OffscreenCanvas(100, 50);
22+
var ctx = canvas.getContext('2d');
23+
24+
ctx.fillStyle = '#0f0';
25+
ctx.fillRect(0, 0, 100, 50);
26+
27+
let path = new Path2D();
28+
path.rect(0, 0, 100, 50);
29+
path.rect(0, 0, 100, 50);
30+
path.closePath();
31+
32+
ctx.fillStyle = "#f00";
33+
ctx.clip(path, "evenodd");
34+
ctx.fillRect(0, 0, 100, 50);
35+
36+
_assertPixel(canvas, 50,25, 0,255,0,255);
37+
t.done();
38+
39+
});
40+
</script>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
3+
4+
5+
6+
importScripts("/resources/testharness.js");
7+
importScripts("/html/canvas/resources/canvas-tests.js");
8+
9+
var t = async_test("evenodd winding number rule works in clip");
10+
var t_pass = t.done.bind(t);
11+
var t_fail = t.step_func(function(reason) {
12+
throw reason;
13+
});
14+
t.step(function() {
15+
16+
var canvas = new OffscreenCanvas(100, 50);
17+
var ctx = canvas.getContext('2d');
18+
19+
ctx.fillStyle = '#0f0';
20+
ctx.fillRect(0, 0, 100, 50);
21+
22+
let path = new Path2D();
23+
path.rect(0, 0, 100, 50);
24+
path.rect(0, 0, 100, 50);
25+
path.closePath();
26+
27+
ctx.fillStyle = "#f00";
28+
ctx.clip(path, "evenodd");
29+
ctx.fillRect(0, 0, 100, 50);
30+
31+
_assertPixel(canvas, 50,25, 0,255,0,255);
32+
t.done();
33+
});
34+
done();
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<!DOCTYPE html>
2+
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
3+
<meta charset="UTF-8">
4+
<title>OffscreenCanvas test: 2d.path.fill.winding.evenodd.1</title>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/html/canvas/resources/canvas-tests.js"></script>
8+
9+
<h1>2d.path.fill.winding.evenodd.1</h1>
10+
<p class="desc">evenodd winding number rule works in fill</p>
11+
12+
13+
<script>
14+
var t = async_test("evenodd winding number rule works in fill");
15+
var t_pass = t.done.bind(t);
16+
var t_fail = t.step_func(function(reason) {
17+
throw reason;
18+
});
19+
t.step(function() {
20+
21+
var canvas = new OffscreenCanvas(100, 50);
22+
var ctx = canvas.getContext('2d');
23+
24+
ctx.fillStyle = '#0f0';
25+
ctx.fillRect(0, 0, 100, 50);
26+
27+
ctx.beginPath();
28+
ctx.rect(0, 0, 100, 50);
29+
ctx.rect(0, 0, 100, 50);
30+
31+
ctx.fillStyle = "#f00";
32+
ctx.fill("evenodd");
33+
34+
_assertPixel(canvas, 50,25, 0,255,0,255);
35+
t.done();
36+
37+
});
38+
</script>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
3+
4+
5+
6+
importScripts("/resources/testharness.js");
7+
importScripts("/html/canvas/resources/canvas-tests.js");
8+
9+
var t = async_test("evenodd winding number rule works in fill");
10+
var t_pass = t.done.bind(t);
11+
var t_fail = t.step_func(function(reason) {
12+
throw reason;
13+
});
14+
t.step(function() {
15+
16+
var canvas = new OffscreenCanvas(100, 50);
17+
var ctx = canvas.getContext('2d');
18+
19+
ctx.fillStyle = '#0f0';
20+
ctx.fillRect(0, 0, 100, 50);
21+
22+
ctx.beginPath();
23+
ctx.rect(0, 0, 100, 50);
24+
ctx.rect(0, 0, 100, 50);
25+
26+
ctx.fillStyle = "#f00";
27+
ctx.fill("evenodd");
28+
29+
_assertPixel(canvas, 50,25, 0,255,0,255);
30+
t.done();
31+
});
32+
done();

0 commit comments

Comments
 (0)