2d.line.join.round.worker.js (1843B)
1 // DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. 2 // OffscreenCanvas test in a worker:2d.line.join.round 3 // Description:lineJoin 'round' is rendered correctly 4 // Note: 5 6 importScripts("/resources/testharness.js"); 7 importScripts("/html/canvas/resources/canvas-tests.js"); 8 9 var t = async_test("lineJoin 'round' is rendered correctly"); 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 = '#0f0'; 20 ctx.fillRect(0, 0, 100, 50); 21 22 var tol = 1; // tolerance to avoid antialiasing artifacts 23 24 ctx.lineJoin = 'round'; 25 ctx.lineWidth = 20; 26 27 ctx.fillStyle = '#f00'; 28 ctx.strokeStyle = '#0f0'; 29 30 ctx.fillRect(10, 10, 20, 20); 31 ctx.fillRect(20, 20, 20, 20); 32 ctx.beginPath(); 33 ctx.moveTo(30, 20); 34 ctx.arc(30, 20, 10-tol, 0, 2*Math.PI, true); 35 ctx.fill(); 36 37 ctx.beginPath(); 38 ctx.moveTo(10, 20); 39 ctx.lineTo(30, 20); 40 ctx.lineTo(30, 40); 41 ctx.stroke(); 42 43 44 ctx.fillStyle = '#0f0'; 45 ctx.strokeStyle = '#f00'; 46 47 ctx.beginPath(); 48 ctx.moveTo(60, 20); 49 ctx.lineTo(80, 20); 50 ctx.lineTo(80, 40); 51 ctx.stroke(); 52 53 ctx.fillRect(60, 10, 20, 20); 54 ctx.fillRect(70, 20, 20, 20); 55 ctx.beginPath(); 56 ctx.moveTo(80, 20); 57 ctx.arc(80, 20, 10+tol, 0, 2*Math.PI, true); 58 ctx.fill(); 59 60 _assertPixel(canvas, 36,14, 0,255,0,255); 61 _assertPixel(canvas, 36,13, 0,255,0,255); 62 _assertPixel(canvas, 37,13, 0,255,0,255); 63 _assertPixel(canvas, 38,13, 0,255,0,255); 64 _assertPixel(canvas, 38,12, 0,255,0,255); 65 66 _assertPixel(canvas, 86,14, 0,255,0,255); 67 _assertPixel(canvas, 86,13, 0,255,0,255); 68 _assertPixel(canvas, 87,13, 0,255,0,255); 69 _assertPixel(canvas, 88,13, 0,255,0,255); 70 _assertPixel(canvas, 88,12, 0,255,0,255); 71 t.done(); 72 }); 73 done();