2d.path.stroke.skew.worker.js (1696B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.path.stroke.skew 3 // Description:Strokes lines are skewed by the current transformation matrix 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("Strokes lines are skewed by the current transformation matrix"); 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 = '#f00'; 20 ctx.fillRect(0, 0, 100, 50); 21 22 ctx.save(); 23 ctx.beginPath(); 24 ctx.moveTo(49, -50); 25 ctx.lineTo(201, -50); 26 ctx.rotate(Math.PI/4); 27 ctx.scale(1, 283); 28 ctx.strokeStyle = '#0f0'; 29 ctx.stroke(); 30 ctx.restore(); 31 32 ctx.save(); 33 ctx.beginPath(); 34 ctx.translate(-150, 0); 35 ctx.moveTo(49, -50); 36 ctx.lineTo(199, -50); 37 ctx.rotate(Math.PI/4); 38 ctx.scale(1, 142); 39 ctx.strokeStyle = '#f00'; 40 ctx.stroke(); 41 ctx.restore(); 42 43 ctx.save(); 44 ctx.beginPath(); 45 ctx.translate(-150, 0); 46 ctx.moveTo(49, -50); 47 ctx.lineTo(199, -50); 48 ctx.rotate(Math.PI/4); 49 ctx.scale(1, 142); 50 ctx.strokeStyle = '#f00'; 51 ctx.stroke(); 52 ctx.restore(); 53 54 _assertPixel(canvas, 0,0, 0,255,0,255); 55 _assertPixel(canvas, 50,0, 0,255,0,255); 56 _assertPixel(canvas, 99,0, 0,255,0,255); 57 _assertPixel(canvas, 0,25, 0,255,0,255); 58 _assertPixel(canvas, 50,25, 0,255,0,255); 59 _assertPixel(canvas, 99,25, 0,255,0,255); 60 _assertPixel(canvas, 0,49, 0,255,0,255); 61 _assertPixel(canvas, 50,49, 0,255,0,255); 62 _assertPixel(canvas, 99,49, 0,255,0,255); 63 t.done(); 64 }); 65 done();