3 <title>A canvas globalCompositeOperation with shadow
</title>
6 testRunner
.dumpAsTextWithPixelResults();
9 'source-over', 'source-in', 'source-out', 'source-atop',
10 'destination-over', 'destination-in', 'destination-out', 'destination-atop',
11 'lighter', 'copy', 'xor', 'multiply', 'screen', 'overlay', 'darken',
12 'lighten', 'color-dodge', 'color-burn', 'hard-light', 'soft-light',
13 'difference', 'exclusion', 'hue', 'saturation', 'color', 'luminosity'
16 for (i
=0;i
<compositeTypes
.length
;i
++){
17 var label
= document
.createTextNode(compositeTypes
[i
]);
18 document
.getElementById('lab'+i
).appendChild(label
);
19 var canvas
= document
.getElementById('tut'+i
);
22 var ctx
= canvas
.getContext('2d');
25 ctx
.fillStyle
= "#09f";
26 ctx
.fillRect(5,5,45,45);
28 // set composite property
29 ctx
.globalCompositeOperation
= compositeTypes
[i
];
31 // draw rectangle with shadow
32 ctx
.fillStyle
= "#f30";
33 ctx
.shadowColor
= 'blue';
35 ctx
.shadowOffsetX
= 10;
36 ctx
.shadowOffsetY
= -10;
37 ctx
.fillRect(20,25,45,45);
41 <style type=
"text/css">
42 body
{ margin: 20px; font-family: arial
,verdana
,helvetica
; background: #fff;}
43 h1
{ font-size: 140%; font-weight:normal
; color: #036; border-bottom: 1px solid
#ccc; }
44 canvas
{ border: 2px solid
#000; margin-bottom: 5px; }
46 pre
{ float:left
; display:block
; background: rgb
(238,238,238); border: 1px dashed
#666; padding: 15px 20px; margin: 0 0 10px 0; }
49 <body onload=
"draw();">
53 <td><canvas id=
"tut0"></canvas><br/><label id=
"lab0"></label></td>
54 <td><canvas id=
"tut1"></canvas><br/><label id=
"lab1"></label></td>
55 <td><canvas id=
"tut2"></canvas><br/><label id=
"lab2"></label></td>
56 <td><canvas id=
"tut3"></canvas><br/><label id=
"lab3"></label></td>
57 <td><canvas id=
"tut4"></canvas><br/><label id=
"lab4"></label></td>
58 <td><canvas id=
"tut5"></canvas><br/><label id=
"lab5"></label></td>
59 <td><canvas id=
"tut6"></canvas><br/><label id=
"lab6"></label></td>
62 <td><canvas id=
"tut7"></canvas><br/><label id=
"lab7"></label></td>
63 <td><canvas id=
"tut8"></canvas><br/><label id=
"lab8"></label></td>
64 <td><canvas id=
"tut9"></canvas><br/><label id=
"lab9"></label></td>
65 <td><canvas id=
"tut10"></canvas><br/><label id=
"lab10"></label></td>
66 <td><canvas id=
"tut11"></canvas><br/><label id=
"lab11"></label></td>
67 <td><canvas id=
"tut12"></canvas><br/><label id=
"lab12"></label></td>
68 <td><canvas id=
"tut13"></canvas><br/><label id=
"lab13"></label></td>
71 <td><canvas id=
"tut14"></canvas><br/><label id=
"lab14"></label></td>
72 <td><canvas id=
"tut15"></canvas><br/><label id=
"lab15"></label></td>
73 <td><canvas id=
"tut16"></canvas><br/><label id=
"lab16"></label></td>
74 <td><canvas id=
"tut17"></canvas><br/><label id=
"lab17"></label></td>
75 <td><canvas id=
"tut18"></canvas><br/><label id=
"lab18"></label></td>
76 <td><canvas id=
"tut19"></canvas><br/><label id=
"lab19"></label></td>
77 <td><canvas id=
"tut20"></canvas><br/><label id=
"lab20"></label></td>
80 <td><canvas id=
"tut21"></canvas><br/><label id=
"lab21"></label></td>
81 <td><canvas id=
"tut22"></canvas><br/><label id=
"lab22"></label></td>
82 <td><canvas id=
"tut23"></canvas><br/><label id=
"lab23"></label></td>
83 <td><canvas id=
"tut24"></canvas><br/><label id=
"lab24"></label></td>
84 <td><canvas id=
"tut25"></canvas><br/><label id=
"lab25"></label></td>