2d.path.stroke.scale2.worker.js (1437B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.path.stroke.scale2 3 // Description:Stroke line widths are scaled 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("Stroke line widths are scaled 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.beginPath(); 23 ctx.rect(25, 12.5, 50, 25); 24 ctx.save(); 25 ctx.rotate(Math.PI/2); 26 ctx.scale(25, 50); 27 ctx.strokeStyle = '#0f0'; 28 ctx.stroke(); 29 ctx.restore(); 30 31 ctx.beginPath(); 32 ctx.rect(-25, -12.5, 150, 75); 33 ctx.save(); 34 ctx.rotate(Math.PI/2); 35 ctx.scale(25, 50); 36 ctx.strokeStyle = '#f00'; 37 ctx.stroke(); 38 ctx.restore(); 39 40 _assertPixel(canvas, 0,0, 0,255,0,255); 41 _assertPixel(canvas, 50,0, 0,255,0,255); 42 _assertPixel(canvas, 99,0, 0,255,0,255); 43 _assertPixel(canvas, 0,25, 0,255,0,255); 44 _assertPixel(canvas, 50,25, 0,255,0,255); 45 _assertPixel(canvas, 99,25, 0,255,0,255); 46 _assertPixel(canvas, 0,49, 0,255,0,255); 47 _assertPixel(canvas, 50,49, 0,255,0,255); 48 _assertPixel(canvas, 99,49, 0,255,0,255); 49 t.done(); 50 }); 51 done();