2d.layer.nested.html (975B)
1 <!DOCTYPE html> 2 <!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. --> 3 <meta charset="UTF-8"> 4 <link rel="match" href="2d.layer.nested-expected.html"> 5 <title>Canvas test: 2d.layer.nested</title> 6 <h1>2d.layer.nested</h1> 7 <p class="desc">Tests nested canvas layers.</p> 8 <canvas id="canvas" width="200" height="200"> 9 <p class="fallback">FAIL (fallback content)</p> 10 </canvas> 11 <script> 12 const canvas = document.getElementById("canvas"); 13 const ctx = canvas.getContext('2d'); 14 15 var circle = new Path2D(); 16 circle.arc(90, 90, 40, 0, 2 * Math.PI); 17 ctx.fill(circle); 18 19 ctx.globalCompositeOperation = 'source-in'; 20 21 ctx.beginLayer(); 22 23 ctx.fillStyle = 'rgba(0, 0, 255, 1)'; 24 ctx.fillRect(60, 60, 75, 50); 25 26 ctx.globalAlpha = 0.5; 27 28 ctx.beginLayer(); 29 30 ctx.fillStyle = 'rgba(225, 0, 0, 1)'; 31 ctx.fillRect(50, 50, 75, 50); 32 ctx.fillStyle = 'rgba(0, 255, 0, 1)'; 33 ctx.fillRect(70, 70, 75, 50); 34 35 ctx.endLayer(); 36 ctx.endLayer(); 37 </script>