Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<meta charset="UTF-8">
<html class="reftest-wait">
<link rel="match" href="2d.layer.ctm.setTransform-expected.html">
<title>Canvas test: 2d.layer.ctm.setTransform</title>
<h1>2d.layer.ctm.setTransform</h1>
<p class="desc">Tests setTransform inside layers.</p>
<canvas id="canvas" width="100" height="50">
<p class="fallback">FAIL (fallback content)</p>
</canvas>
<script id='myWorker' type='text/worker'>
self.onmessage = function(e) {
const canvas = new OffscreenCanvas(100, 50);
const ctx = canvas.getContext('2d');
ctx.translate(80, 0);
ctx.beginLayer();
ctx.rotate(2);
ctx.beginLayer();
ctx.scale(5, 6);
ctx.setTransform(4, 0, 0, 2, 20, 10);
ctx.fillStyle = 'blue';
ctx.fillRect(0, 0, 10, 10);
ctx.endLayer();
ctx.endLayer();
ctx.fillStyle = 'green';
ctx.fillRect(0, 0, 20, 20);
const bitmap = canvas.transferToImageBitmap();
self.postMessage(bitmap, bitmap);
};
</script>
<script>
const blob = new Blob([document.getElementById('myWorker').textContent]);
const worker = new Worker(URL.createObjectURL(blob));
worker.addEventListener('message', msg => {
const outputCtx = document.getElementById("canvas").getContext('2d');
outputCtx.drawImage(msg.data, 0, 0);
document.documentElement.classList.remove("reftest-wait");
});
worker.postMessage(null);
</script>
</html>