|
3 | 3 | <title>Canvas test: 2d.layer.global-states.alpha.composite.shadow</title>
|
4 | 4 | <h1>2d.layer.global-states.alpha.composite.shadow</h1>
|
5 | 5 | <p class="desc">Checks that layers correctly use global render states.</p>
|
6 |
| -<canvas id="canvas" width="200" height="200"> |
| 6 | +<canvas id="canvas" width="90" height="90"> |
7 | 7 | <p class="fallback">FAIL (fallback content)</p>
|
8 | 8 | </canvas>
|
9 | 9 | <script>
|
10 | 10 | const canvas = document.getElementById("canvas");
|
11 | 11 | const ctx = canvas.getContext('2d');
|
12 | 12 |
|
13 |
| - ctx.fillStyle = 'rgba(0, 0, 255, 1)'; |
| 13 | + ctx.fillStyle = 'rgba(128, 128, 128, 1)'; |
| 14 | + ctx.fillRect(20, 15, 50, 50); |
14 | 15 |
|
15 |
| - var circle = new Path2D(); |
16 |
| - circle.arc(90, 90, 45, 0, 2 * Math.PI); |
17 |
| - ctx.fill(circle); |
18 |
| - |
19 |
| - ctx.globalAlpha = 0.6; |
| 16 | + ctx.globalAlpha = 0.75; |
20 | 17 | ctx.globalCompositeOperation = 'source-in';
|
21 |
| - ctx.shadowOffsetX = -10; |
22 |
| - ctx.shadowOffsetY = 10; |
| 18 | + ctx.shadowOffsetX = -7; |
| 19 | + ctx.shadowOffsetY = 7; |
23 | 20 | ctx.shadowColor = 'rgba(255, 165, 0, 0.5)';
|
24 | 21 | ctx.shadowBlur = 3;
|
25 | 22 |
|
26 |
| - canvas2 = document.createElement("canvas"); |
27 |
| - ctx2 = canvas2.getContext("2d"); |
| 23 | + const canvas2 = document.createElement("canvas"); |
| 24 | + const ctx2 = canvas2.getContext("2d"); |
28 | 25 |
|
29 | 26 | ctx2.globalCompositeOperation = 'screen';
|
30 |
| - ctx2.fillStyle = 'rgba(225, 0, 0, 1)'; |
31 |
| - ctx2.fillRect(50, 50, 75, 50); |
| 27 | + ctx2.fillStyle = 'rgba(255, 0, 0, 1)'; |
| 28 | + ctx2.fillRect(10, 25, 40, 50); |
32 | 29 | ctx2.fillStyle = 'rgba(0, 255, 0, 1)';
|
33 |
| - ctx2.fillRect(70, 70, 75, 50); |
| 30 | + ctx2.fillRect(30, 5, 50, 40); |
34 | 31 |
|
35 | 32 | ctx.drawImage(canvas2, 0, 0);
|
36 | 33 | </script>
|
0 commit comments