2d.line.width.basic.html (2141B)
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>Canvas 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 <link rel="stylesheet" href="/html/canvas/resources/canvas-tests.css"> 9 <body class="show_output"> 10 11 <h1>2d.line.width.basic</h1> 12 <p class="desc">lineWidth determines the width of line strokes</p> 13 14 15 <p class="output">Actual output:</p> 16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> 17 <p class="output expectedtext">Expected output:<p><img src="/images/green-100x50.png" class="output expected" id="expected" alt=""> 18 <ul id="d"></ul> 19 <script> 20 var t = async_test("lineWidth determines the width of line strokes"); 21 _addTest(function(canvas, ctx) { 22 23 ctx.fillStyle = '#0f0'; 24 ctx.fillRect(0, 0, 100, 50); 25 26 ctx.lineWidth = 20; 27 // Draw a green line over a red box, to check the line is not too small 28 ctx.fillStyle = '#f00'; 29 ctx.strokeStyle = '#0f0'; 30 ctx.fillRect(15, 15, 20, 20); 31 ctx.beginPath(); 32 ctx.moveTo(25, 15); 33 ctx.lineTo(25, 35); 34 ctx.stroke(); 35 36 // Draw a green box over a red line, to check the line is not too large 37 ctx.fillStyle = '#0f0'; 38 ctx.strokeStyle = '#f00'; 39 ctx.beginPath(); 40 ctx.moveTo(75, 15); 41 ctx.lineTo(75, 35); 42 ctx.stroke(); 43 ctx.fillRect(65, 15, 20, 20); 44 45 _assertPixel(canvas, 14,25, 0,255,0,255); 46 _assertPixel(canvas, 15,25, 0,255,0,255); 47 _assertPixel(canvas, 16,25, 0,255,0,255); 48 _assertPixel(canvas, 25,25, 0,255,0,255); 49 _assertPixel(canvas, 34,25, 0,255,0,255); 50 _assertPixel(canvas, 35,25, 0,255,0,255); 51 _assertPixel(canvas, 36,25, 0,255,0,255); 52 53 _assertPixel(canvas, 64,25, 0,255,0,255); 54 _assertPixel(canvas, 65,25, 0,255,0,255); 55 _assertPixel(canvas, 66,25, 0,255,0,255); 56 _assertPixel(canvas, 75,25, 0,255,0,255); 57 _assertPixel(canvas, 84,25, 0,255,0,255); 58 _assertPixel(canvas, 85,25, 0,255,0,255); 59 _assertPixel(canvas, 86,25, 0,255,0,255); 60 61 }); 62 </script>