2d.line.cap.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.cap.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.cap.round</h1> 10 <p class="desc">lineCap 'round' is rendered correctly</p> 11 12 13 <script> 14 var t = async_test("lineCap '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.lineCap = 'round'; 30 ctx.lineWidth = 20; 31 32 33 ctx.fillStyle = '#f00'; 34 ctx.strokeStyle = '#0f0'; 35 36 ctx.beginPath(); 37 ctx.moveTo(35-tol, 15); 38 ctx.arc(25, 15, 10-tol, 0, Math.PI, true); 39 ctx.arc(25, 35, 10-tol, Math.PI, 0, true); 40 ctx.fill(); 41 42 ctx.beginPath(); 43 ctx.moveTo(25, 15); 44 ctx.lineTo(25, 35); 45 ctx.stroke(); 46 47 48 ctx.fillStyle = '#0f0'; 49 ctx.strokeStyle = '#f00'; 50 51 ctx.beginPath(); 52 ctx.moveTo(75, 15); 53 ctx.lineTo(75, 35); 54 ctx.stroke(); 55 56 ctx.beginPath(); 57 ctx.moveTo(85+tol, 15); 58 ctx.arc(75, 15, 10+tol, 0, Math.PI, true); 59 ctx.arc(75, 35, 10+tol, Math.PI, 0, true); 60 ctx.fill(); 61 62 _assertPixel(canvas, 17,6, 0,255,0,255); 63 _assertPixel(canvas, 25,6, 0,255,0,255); 64 _assertPixel(canvas, 32,6, 0,255,0,255); 65 _assertPixel(canvas, 17,43, 0,255,0,255); 66 _assertPixel(canvas, 25,43, 0,255,0,255); 67 _assertPixel(canvas, 32,43, 0,255,0,255); 68 69 _assertPixel(canvas, 67,6, 0,255,0,255); 70 _assertPixel(canvas, 75,6, 0,255,0,255); 71 _assertPixel(canvas, 82,6, 0,255,0,255); 72 _assertPixel(canvas, 67,43, 0,255,0,255); 73 _assertPixel(canvas, 75,43, 0,255,0,255); 74 _assertPixel(canvas, 82,43, 0,255,0,255); 75 t.done(); 76 77 }); 78 </script>