paint2d-shadows-ref.html (485B)
1 <!DOCTYPE html> 2 <html> 3 <body> 4 <canvas id ="output" width="200" height="100"></canvas> 5 <script> 6 var canvas = document.getElementById('output'); 7 var ctx = canvas.getContext('2d'); 8 9 ctx.shadowColor = 'black'; 10 ctx.shadowOffsetY = 10; 11 ctx.shadowOffsetX = 10; 12 ctx.fillStyle = 'green' 13 ctx.fillRect(10, 10, 50, 50); 14 15 ctx.shadowColor = 'blue'; 16 ctx.shadowBlur = 10; 17 ctx.shadowOffsetX = 5; 18 ctx.shadowOffsetY = 5; 19 ctx.fillStyle = 'green'; 20 ctx.fillRect(110, 10, 50, 50); 21 </script> 22 </body> 23 </html>