OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> | |
3 <title>OffscreenCanvas test: 2d.line.width.transformed</title> | |
4 <script src="/resources/testharness.js"></script> | |
5 <script src="/resources/testharnessreport.js"></script> | |
6 <script src="/common/canvas-tests.js"></script> | |
7 | |
8 <h1>2d.line.width.transformed</h1> | |
9 <p class="desc">Line stroke widths are affected by scale transformations</p> | |
10 | |
11 | |
12 <script> | |
13 var t = async_test("Line stroke widths are affected by scale transformations"); | |
14 t.step(function() { | |
15 | |
16 var offscreenCanvas = new OffscreenCanvas(100, 50); | |
17 var ctx = offscreenCanvas.getContext('2d'); | |
18 | |
19 ctx.fillStyle = '#0f0'; | |
20 ctx.fillRect(0, 0, 100, 50); | |
21 ctx.lineWidth = 4; | |
22 // Draw a green line over a red box, to check the line is not too small | |
23 ctx.fillStyle = '#f00'; | |
24 ctx.strokeStyle = '#0f0'; | |
25 ctx.fillRect(15, 15, 20, 20); | |
26 ctx.save(); | |
27 ctx.scale(5, 1); | |
28 ctx.beginPath(); | |
29 ctx.moveTo(5, 15); | |
30 ctx.lineTo(5, 35); | |
31 ctx.stroke(); | |
32 ctx.restore(); | |
33 // Draw a green box over a red line, to check the line is not too large | |
34 ctx.fillStyle = '#0f0'; | |
35 ctx.strokeStyle = '#f00'; | |
36 ctx.save(); | |
37 ctx.scale(-5, 1); | |
38 ctx.beginPath(); | |
39 ctx.moveTo(-15, 15); | |
40 ctx.lineTo(-15, 35); | |
41 ctx.stroke(); | |
42 ctx.restore(); | |
43 ctx.fillRect(65, 15, 20, 20); | |
44 _assertPixel(offscreenCanvas, 14,25, 0,255,0,255, "14,25", "0,255,0,255"); | |
45 _assertPixel(offscreenCanvas, 15,25, 0,255,0,255, "15,25", "0,255,0,255"); | |
46 _assertPixel(offscreenCanvas, 16,25, 0,255,0,255, "16,25", "0,255,0,255"); | |
47 _assertPixel(offscreenCanvas, 25,25, 0,255,0,255, "25,25", "0,255,0,255"); | |
48 _assertPixel(offscreenCanvas, 34,25, 0,255,0,255, "34,25", "0,255,0,255"); | |
49 _assertPixel(offscreenCanvas, 35,25, 0,255,0,255, "35,25", "0,255,0,255"); | |
50 _assertPixel(offscreenCanvas, 36,25, 0,255,0,255, "36,25", "0,255,0,255"); | |
51 _assertPixel(offscreenCanvas, 64,25, 0,255,0,255, "64,25", "0,255,0,255"); | |
52 _assertPixel(offscreenCanvas, 65,25, 0,255,0,255, "65,25", "0,255,0,255"); | |
53 _assertPixel(offscreenCanvas, 66,25, 0,255,0,255, "66,25", "0,255,0,255"); | |
54 _assertPixel(offscreenCanvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255"); | |
55 _assertPixel(offscreenCanvas, 84,25, 0,255,0,255, "84,25", "0,255,0,255"); | |
56 _assertPixel(offscreenCanvas, 85,25, 0,255,0,255, "85,25", "0,255,0,255"); | |
57 _assertPixel(offscreenCanvas, 86,25, 0,255,0,255, "86,25", "0,255,0,255"); | |
58 | |
59 t.done(); | |
60 | |
61 }); | |
62 </script> | |
OLD | NEW |