Add outer shadow to Canvas - Javascript Canvas Reference

Javascript examples for Canvas Reference:getImageData

Description

Add outer shadow to Canvas

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=function(){/*from  www. j a va2s  . c  o m*/
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.shadowColor = 'black';
ctx.shadowBlur = 15;
var imgdata = ctx.getImageData(20, 30, 150, 75);
ctx.strokeRect(20, 30, 150, 75);
ctx.putImageData(imgdata, 20, 30);
    }

      </script> 
   </head> 
   <body> 
      <canvas id="myCanvas"></canvas>  
   </body>
</html>

Related Tutorials