OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- DO NOT EDIT! This test has been generated by tools/gentest.py. --> |
| 3 <title>OffscreenCanvas test: 2d.line.cap.round</title> |
| 4 <script src="/resources/testharness.js"></script> |
| 5 <script src="/resources/testharnessreport.js"></script> |
| 6 <script src="/common/canvas-tests.js"></script> |
| 7 |
| 8 <h1>2d.line.cap.round</h1> |
| 9 <p class="desc">lineCap 'round' is rendered correctly</p> |
| 10 |
| 11 |
| 12 <script> |
| 13 var t = async_test("lineCap 'round' is rendered correctly"); |
| 14 t.step(function() { |
| 15 |
| 16 var offscreenCanvas = new OffscreenCanvas(100, 50); |
| 17 var ctx = offscreenCanvas.getContext('2d'); |
| 18 |
| 19 ctx.fillStyle = '#0f0'; |
| 20 ctx.fillRect(0, 0, 100, 50); |
| 21 var tol = 1; // tolerance to avoid antialiasing artifacts |
| 22 ctx.lineCap = 'round'; |
| 23 ctx.lineWidth = 20; |
| 24 ctx.fillStyle = '#f00'; |
| 25 ctx.strokeStyle = '#0f0'; |
| 26 ctx.beginPath(); |
| 27 ctx.moveTo(35-tol, 15); |
| 28 ctx.arc(25, 15, 10-tol, 0, Math.PI, true); |
| 29 ctx.arc(25, 35, 10-tol, Math.PI, 0, true); |
| 30 ctx.fill(); |
| 31 ctx.beginPath(); |
| 32 ctx.moveTo(25, 15); |
| 33 ctx.lineTo(25, 35); |
| 34 ctx.stroke(); |
| 35 ctx.fillStyle = '#0f0'; |
| 36 ctx.strokeStyle = '#f00'; |
| 37 ctx.beginPath(); |
| 38 ctx.moveTo(75, 15); |
| 39 ctx.lineTo(75, 35); |
| 40 ctx.stroke(); |
| 41 ctx.beginPath(); |
| 42 ctx.moveTo(85+tol, 15); |
| 43 ctx.arc(75, 15, 10+tol, 0, Math.PI, true); |
| 44 ctx.arc(75, 35, 10+tol, Math.PI, 0, true); |
| 45 ctx.fill(); |
| 46 _assertPixel(offscreenCanvas, 17,6, 0,255,0,255, "17,6", "0,255,0,255"); |
| 47 _assertPixel(offscreenCanvas, 25,6, 0,255,0,255, "25,6", "0,255,0,255"); |
| 48 _assertPixel(offscreenCanvas, 32,6, 0,255,0,255, "32,6", "0,255,0,255"); |
| 49 _assertPixel(offscreenCanvas, 17,43, 0,255,0,255, "17,43", "0,255,0,255"); |
| 50 _assertPixel(offscreenCanvas, 25,43, 0,255,0,255, "25,43", "0,255,0,255"); |
| 51 _assertPixel(offscreenCanvas, 32,43, 0,255,0,255, "32,43", "0,255,0,255"); |
| 52 _assertPixel(offscreenCanvas, 67,6, 0,255,0,255, "67,6", "0,255,0,255"); |
| 53 _assertPixel(offscreenCanvas, 75,6, 0,255,0,255, "75,6", "0,255,0,255"); |
| 54 _assertPixel(offscreenCanvas, 82,6, 0,255,0,255, "82,6", "0,255,0,255"); |
| 55 _assertPixel(offscreenCanvas, 67,43, 0,255,0,255, "67,43", "0,255,0,255"); |
| 56 _assertPixel(offscreenCanvas, 75,43, 0,255,0,255, "75,43", "0,255,0,255"); |
| 57 _assertPixel(offscreenCanvas, 82,43, 0,255,0,255, "82,43", "0,255,0,255"); |
| 58 |
| 59 t.done(); |
| 60 |
| 61 }); |
| 62 </script> |
OLD | NEW |