2d.layer.non-invertible-matrix.html (1430B)
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.non-invertible-matrix-expected.html"> 5 <title>Canvas test: 2d.layer.non-invertible-matrix</title> 6 <h1>2d.layer.non-invertible-matrix</h1> 7 <p class="desc">Test drawing layers when the transform is not invertible.</p> 8 <canvas id="canvas" width="200" height="200"> 9 <p class="fallback">FAIL (fallback content)</p> 10 </canvas> 11 <script> 12 const canvas = new OffscreenCanvas(200, 200); 13 const ctx = canvas.getContext('2d'); 14 15 ctx.fillStyle = 'blue'; 16 ctx.fillRect(30, 30, 50, 50); 17 18 // Anything below will be non-rasterizable. 19 ctx.scale(1, 0); 20 21 // Open the layer with a non-invertible matrix. The whole layer will be 22 // non-rasterizable. 23 ctx.beginLayer(); 24 25 // Because the transform is global, the matrix is still non-invertible. 26 ctx.fillStyle = 'rgba(225, 0, 0, 1)'; 27 ctx.fillRect(40, 70, 50, 50); 28 29 // Set a valid matrix in the middle of the layer. This makes the global 30 // matrix invertible again, but because because the layer was opened with a 31 // non-invertible matrix, the whole layer remains non-rasterizable. 32 ctx.setTransform(1, 0, 0, 1, 0, 0); 33 34 ctx.fillStyle = 'green'; 35 ctx.fillRect(70, 40, 50, 50); 36 37 ctx.endLayer(); 38 39 const outputCanvas = document.getElementById("canvas"); 40 outputCanvas.getContext('2d').drawImage(canvas, 0, 0); 41 </script>