HTML5 Game - Shadow a circle

Introduction

we can apply shadow to any shape.

Demo

ResultView the demo in separate window

<!DOCTYPE html>
<html>
  <head>
    <title>Pushing canvas further</title>
    <meta charset="utf-8">
    /* www .j ava  2 s  . c o  m*/
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    
    <script type="text/javascript">
      $(document).ready(function() {  
        let canvas = $("#myCanvas");
        let context = canvas.get(0).getContext("2d");
        
   context.shadowColor = "rgb(255, 0, 0)"; // Red  
   context.shadowBlur = 50;  
   context.shadowOffsetX = 0;  
   context.shadowOffsetY = 0;  
   context.beginPath();  
   context.arc(400, 100, 50, 0, Math.PI*2, false);  
   context.closePath();  
   context.fill();  

      });
    </script>
  </head>
  
  <body>
    <canvas id="myCanvas" width="500" height="500">
      <!-- Insert fallback content here -->
    </canvas>
  </body>
</html>

Related Topic