HTML canvas shadowColor Property


The shadowColor property of the HTML canvas is used to set the color for shadow. The default value is #000000.

Following is the syntax −

ctx.shadowColor=color;

Above, set the color for shadow.

Let us now see an example to implement the shadowColor property of canvas −

Example

 Live Demo

<!DOCTYPE html>
<html>
<body>
<canvas id="newCanvas" width="600" height="350" style="border:2px solid orange;">
</canvas>
<script>
   var c = document.getElementById("newCanvas");
   var ctx = c.getContext("2d");
   ctx.shadowBlur = 20;
   ctx.shadowColor = "gray";
   ctx.fillStyle = "blue";
   ctx.fillRect(40, 40, 200, 250);
</script>
</body>
</html>

Output

Updated on: 12-Jun-2020

91 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements