summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/offscreen/layers/2d.layer.ctm.filter.html
blob: e5efc24bcc4f1e19ba49e5e5bee67cc21cce1eb6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<link rel="match" href="2d.layer.ctm.filter-expected.html">
<title>Canvas test: 2d.layer.ctm.filter</title>
<h1>2d.layer.ctm.filter</h1>
<p class="desc">Checks that parent transforms affect layer filters.</p>
<canvas id="canvas" width="200" height="200">
  <p class="fallback">FAIL (fallback content)</p>
</canvas>
<script>
  const canvas = new OffscreenCanvas(200, 200);
  const ctx = canvas.getContext('2d');

  // Transforms inside the layer should not apply to the layer's filter.
  ctx.beginLayer({filter: 'drop-shadow(5px 5px 0px grey)'});
  ctx.translate(30, 90);
  ctx.scale(2, 2);
  ctx.rotate(Math.PI / 2);
  ctx.fillRect(-30, -5, 60, 10);
  ctx.endLayer();

  // Transforms in the layer's parent should apply to the layer's filter.
  ctx.translate(80, 90);
  ctx.scale(2, 2);
  ctx.rotate(Math.PI / 2);
  ctx.beginLayer({filter: 'drop-shadow(5px 5px 0px grey)'});
  ctx.fillRect(-30, -5, 60, 10);
  ctx.endLayer();

  const outputCanvas = document.getElementById("canvas");
  outputCanvas.getContext('2d').drawImage(canvas, 0, 0);
</script>