OLD | NEW |
| (Empty) |
1 // DO NOT EDIT! This test has been generated by tools/gentest.py. | |
2 // OffscreenCanvas test in a worker:2d.line.cap.round | |
3 // Description:lineCap 'round' is rendered correctly | |
4 // Note: | |
5 | |
6 importScripts("/resources/testharness.js"); | |
7 importScripts("/common/canvas-tests.js"); | |
8 | |
9 var t = async_test("lineCap 'round' is rendered correctly"); | |
10 t.step(function() { | |
11 | |
12 var offscreenCanvas = new OffscreenCanvas(100, 50); | |
13 var ctx = offscreenCanvas.getContext('2d'); | |
14 | |
15 ctx.fillStyle = '#0f0'; | |
16 ctx.fillRect(0, 0, 100, 50); | |
17 var tol = 1; // tolerance to avoid antialiasing artifacts | |
18 ctx.lineCap = 'round'; | |
19 ctx.lineWidth = 20; | |
20 ctx.fillStyle = '#f00'; | |
21 ctx.strokeStyle = '#0f0'; | |
22 ctx.beginPath(); | |
23 ctx.moveTo(35-tol, 15); | |
24 ctx.arc(25, 15, 10-tol, 0, Math.PI, true); | |
25 ctx.arc(25, 35, 10-tol, Math.PI, 0, true); | |
26 ctx.fill(); | |
27 ctx.beginPath(); | |
28 ctx.moveTo(25, 15); | |
29 ctx.lineTo(25, 35); | |
30 ctx.stroke(); | |
31 ctx.fillStyle = '#0f0'; | |
32 ctx.strokeStyle = '#f00'; | |
33 ctx.beginPath(); | |
34 ctx.moveTo(75, 15); | |
35 ctx.lineTo(75, 35); | |
36 ctx.stroke(); | |
37 ctx.beginPath(); | |
38 ctx.moveTo(85+tol, 15); | |
39 ctx.arc(75, 15, 10+tol, 0, Math.PI, true); | |
40 ctx.arc(75, 35, 10+tol, Math.PI, 0, true); | |
41 ctx.fill(); | |
42 _assertPixel(offscreenCanvas, 17,6, 0,255,0,255, "17,6", "0,255,0,255"); | |
43 _assertPixel(offscreenCanvas, 25,6, 0,255,0,255, "25,6", "0,255,0,255"); | |
44 _assertPixel(offscreenCanvas, 32,6, 0,255,0,255, "32,6", "0,255,0,255"); | |
45 _assertPixel(offscreenCanvas, 17,43, 0,255,0,255, "17,43", "0,255,0,255"); | |
46 _assertPixel(offscreenCanvas, 25,43, 0,255,0,255, "25,43", "0,255,0,255"); | |
47 _assertPixel(offscreenCanvas, 32,43, 0,255,0,255, "32,43", "0,255,0,255"); | |
48 _assertPixel(offscreenCanvas, 67,6, 0,255,0,255, "67,6", "0,255,0,255"); | |
49 _assertPixel(offscreenCanvas, 75,6, 0,255,0,255, "75,6", "0,255,0,255"); | |
50 _assertPixel(offscreenCanvas, 82,6, 0,255,0,255, "82,6", "0,255,0,255"); | |
51 _assertPixel(offscreenCanvas, 67,43, 0,255,0,255, "67,43", "0,255,0,255"); | |
52 _assertPixel(offscreenCanvas, 75,43, 0,255,0,255, "75,43", "0,255,0,255"); | |
53 _assertPixel(offscreenCanvas, 82,43, 0,255,0,255, "82,43", "0,255,0,255"); | |
54 | |
55 t.done(); | |
56 | |
57 }); | |
58 done(); | |
OLD | NEW |