2d.line.join.round.html (1994B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <title>OffscreenCanvas test: 2d.line.join.round</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/html/canvas/resources/canvas-tests.js"></script> 8 9 <h1>2d.line.join.round</h1> 10 <p class="desc">lineJoin 'round' is rendered correctly</p> 11 12 13 <script> 14 var t = async_test("lineJoin 'round' is rendered correctly"); 15 var t_pass = t.done.bind(t); 16 var t_fail = t.step_func(function(reason) { 17 throw reason; 18 }); 19 t.step(function() { 20 21 var canvas = new OffscreenCanvas(100, 50); 22 var ctx = canvas.getContext('2d'); 23 24 ctx.fillStyle = '#0f0'; 25 ctx.fillRect(0, 0, 100, 50); 26 27 var tol = 1; // tolerance to avoid antialiasing artifacts 28 29 ctx.lineJoin = 'round'; 30 ctx.lineWidth = 20; 31 32 ctx.fillStyle = '#f00'; 33 ctx.strokeStyle = '#0f0'; 34 35 ctx.fillRect(10, 10, 20, 20); 36 ctx.fillRect(20, 20, 20, 20); 37 ctx.beginPath(); 38 ctx.moveTo(30, 20); 39 ctx.arc(30, 20, 10-tol, 0, 2*Math.PI, true); 40 ctx.fill(); 41 42 ctx.beginPath(); 43 ctx.moveTo(10, 20); 44 ctx.lineTo(30, 20); 45 ctx.lineTo(30, 40); 46 ctx.stroke(); 47 48 49 ctx.fillStyle = '#0f0'; 50 ctx.strokeStyle = '#f00'; 51 52 ctx.beginPath(); 53 ctx.moveTo(60, 20); 54 ctx.lineTo(80, 20); 55 ctx.lineTo(80, 40); 56 ctx.stroke(); 57 58 ctx.fillRect(60, 10, 20, 20); 59 ctx.fillRect(70, 20, 20, 20); 60 ctx.beginPath(); 61 ctx.moveTo(80, 20); 62 ctx.arc(80, 20, 10+tol, 0, 2*Math.PI, true); 63 ctx.fill(); 64 65 _assertPixel(canvas, 36,14, 0,255,0,255); 66 _assertPixel(canvas, 36,13, 0,255,0,255); 67 _assertPixel(canvas, 37,13, 0,255,0,255); 68 _assertPixel(canvas, 38,13, 0,255,0,255); 69 _assertPixel(canvas, 38,12, 0,255,0,255); 70 71 _assertPixel(canvas, 86,14, 0,255,0,255); 72 _assertPixel(canvas, 86,13, 0,255,0,255); 73 _assertPixel(canvas, 87,13, 0,255,0,255); 74 _assertPixel(canvas, 88,13, 0,255,0,255); 75 _assertPixel(canvas, 88,12, 0,255,0,255); 76 t.done(); 77 78 }); 79 </script>