summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/element/layers/2d.layer.opaque-canvas.html
blob: be8b088fbbbd3b5778a032efe7ef0c3863537775 (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
33
34
35
<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<link rel="match" href="2d.layer.opaque-canvas-expected.html">
<title>Canvas test: 2d.layer.opaque-canvas</title>
<h1>2d.layer.opaque-canvas</h1>
<p class="desc">Checks that layer blending works inside opaque canvas</p>
<canvas id="canvas" width="300" height="300">
  <p class="fallback">FAIL (fallback content)</p>
</canvas>
<script>
  const canvas = document.getElementById("canvas");
  const ctx = canvas.getContext('2d');

  const canvas2 = document.createElement('canvas');
  canvas2.width = 200;
  canvas2.height = 200;
  const ctx2 = canvas2.getContext('2d', {alpha: false});

  ctx2.fillStyle = 'purple';
  ctx2.fillRect(10, 10, 100, 100);

  ctx2.beginLayer({filter: {name: 'dropShadow', dx: -10, dy: 10,
                            stdDeviation: 0,
                            floodColor: 'rgba(200, 100, 50, 0.5)'}});
  ctx2.fillStyle = 'green';
  ctx2.fillRect(50, 50, 100, 100);
  ctx2.globalAlpha = 0.8;
  ctx2.fillStyle = 'yellow';
  ctx2.fillRect(75, 25, 100, 100);
  ctx2.endLayer();

  ctx.fillStyle = 'blue';
  ctx.fillRect(0, 0, 300, 300);
  ctx.drawImage(canvas2, 0, 0);
</script>