HTML canvas shadowColor Property

HTMLWeb DevelopmentFront End Technology

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

raja
Updated on 12-Jun-2020 08:00:20

Advertisements