OLD | NEW |
---|---|
(Empty) | |
1 <!DOCTYPE html> | |
2 | |
3 <script src="../../resources/testharness.js"></script> | |
4 <script src="../../resources/testharnessreport.js"></script> | |
5 <canvas id="myCanvas" width="240" height="240" style="border:1px solid #d3d3d3;" ></canvas> | |
6 | |
7 <script> | |
8 | |
9 test(function() { | |
10 var c = document.getElementById("myCanvas"); | |
11 var ctx = c.getContext("2d"); | |
12 | |
13 ctx.beginPath(); | |
14 ctx.moveTo(120, 20); | |
15 ctx.lineTo(220, 120); | |
16 ctx.lineTo(120, 220); | |
17 ctx.lineTo(20, 120); | |
18 ctx.lineTo(120, 20); | |
19 ctx.closePath(); | |
20 ctx.clip(); | |
21 | |
22 ctx.lineWidth = 1; | |
23 ctx.strokeStyle="#FF0000"; | |
24 ctx.stroke(); | |
25 | |
26 // When canvas clips are not anti-aliased, only the first two segments of | |
27 // the diamond-shaped closed path are drawn on the canvas. | |
28 // To check that canvas clip anti-aliasing works fine, we check the | |
29 // junction of the third and fourth segments of the path. | |
Justin Novosad
2016/09/22 19:15:18
You should check multiple points. you never know h
| |
30 var colorData = ctx.getImageData(20, 120, 1, 1).data; | |
31 assert_equals(colorData[0], 255); | |
32 assert_equals(colorData[1], 0); | |
33 assert_equals(colorData[2], 0); | |
34 assert_not_equals(colorData[3], 0); | |
35 | |
36 }, 'canvas-2d-clip-anti-aliasing should not return any error'); | |
Justin Novosad
2016/09/22 19:15:18
The description you put here should describe what
| |
37 | |
38 </script> | |
39 | |
40 | |
41 | |
OLD | NEW |