2d.line.width.basic.html (1931B)
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.width.basic</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.width.basic</h1> 10 <p class="desc">lineWidth determines the width of line strokes</p> 11 12 13 <script> 14 var t = async_test("lineWidth determines the width of line strokes"); 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 ctx.lineWidth = 20; 28 // Draw a green line over a red box, to check the line is not too small 29 ctx.fillStyle = '#f00'; 30 ctx.strokeStyle = '#0f0'; 31 ctx.fillRect(15, 15, 20, 20); 32 ctx.beginPath(); 33 ctx.moveTo(25, 15); 34 ctx.lineTo(25, 35); 35 ctx.stroke(); 36 37 // Draw a green box over a red line, to check the line is not too large 38 ctx.fillStyle = '#0f0'; 39 ctx.strokeStyle = '#f00'; 40 ctx.beginPath(); 41 ctx.moveTo(75, 15); 42 ctx.lineTo(75, 35); 43 ctx.stroke(); 44 ctx.fillRect(65, 15, 20, 20); 45 46 _assertPixel(canvas, 14,25, 0,255,0,255); 47 _assertPixel(canvas, 15,25, 0,255,0,255); 48 _assertPixel(canvas, 16,25, 0,255,0,255); 49 _assertPixel(canvas, 25,25, 0,255,0,255); 50 _assertPixel(canvas, 34,25, 0,255,0,255); 51 _assertPixel(canvas, 35,25, 0,255,0,255); 52 _assertPixel(canvas, 36,25, 0,255,0,255); 53 54 _assertPixel(canvas, 64,25, 0,255,0,255); 55 _assertPixel(canvas, 65,25, 0,255,0,255); 56 _assertPixel(canvas, 66,25, 0,255,0,255); 57 _assertPixel(canvas, 75,25, 0,255,0,255); 58 _assertPixel(canvas, 84,25, 0,255,0,255); 59 _assertPixel(canvas, 85,25, 0,255,0,255); 60 _assertPixel(canvas, 86,25, 0,255,0,255); 61 t.done(); 62 63 }); 64 </script>