4 <title>Check shadow rendering rect and image with source-in.
</title>
5 <style type=
"text/css">
6 canvas
{ border: 1px solid
#999; }
7 #source-canvas { display: none
; }
12 <canvas id=
"canvas-for-color" width=
"200" height=
"200"></canvas>
14 <canvas id=
"canvas-for-image" width=
"200" height=
"200"></canvas>
15 <canvas id=
"source-canvas" width=
"100" height=
"100"></canvas>
17 var canvas_color
= document
.getElementById("canvas-for-color");
18 var ctx_color
= canvas_color
.getContext("2d");
19 setupContext(ctx_color
);
20 ctx_color
.fillStyle
= 'teal';
21 ctx_color
.fillRect(100, 100, 100, 100);
23 var source_canvas
= document
.getElementById('source-canvas');
24 var source_ctx
= source_canvas
.getContext('2d');
25 source_ctx
.fillStyle
= 'teal';
26 source_ctx
.fillRect(0, 0, 100, 100);
28 var canvas_image
= document
.getElementById("canvas-for-image");
29 var ctx_image
= canvas_image
.getContext("2d");
30 setupContext(ctx_image
);
31 ctx_image
.drawImage(source_canvas
, 100, 100, 100, 100);
33 function setupContext(ctx
) {
34 ctx
.globalCompositeOperation
= 'source-over';
35 ctx
.fillStyle
= 'black';
36 ctx
.fillRect(50, 50, 200, 100);
37 ctx
.globalCompositeOperation
= 'source-in';
38 ctx
.shadowColor
= 'blue';
40 ctx
.shadowOffsetX
= -10;
41 ctx
.shadowOffsetY
= -10;