Gets or sets the color to use for shadows.
This property is read/write.
![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: String
The CSS color.
Standards information
- HTML Canvas 2D Context, Section 7
Remarks
Any values of the p parameter that are not CSS colors are ignored.
Examples
The following code example draws a series of squares that have different colors for shadowColor.
<html>
<head>
<script type="text/javascript">
function draw() {
var canvas = document.getElementById("MyCanvas");
if (canvas.getContext) {
var ctx = canvas.getContext("2d");
// Define the shadow parameters.
ctx.shadowColor = "black";
ctx.shadowBlur = "5";
ctx.shadowOffsetX = "5";
ctx.shadowOffsetY = "5";
ctx.strokeRect(25, 25, 200, 200);
ctx.shadowColor = "red";
ctx.strokeRect(75, 75, 200, 200);
ctx.shadowColor = "green";
ctx.strokeRect(125, 125, 200, 200);
ctx.shadowColor = "blue";
ctx.strokeRect(175, 175, 200, 200);
ctx.shadowColor = "purple";
ctx.strokeRect(225, 225, 200, 200);
}
}
</script>
</head>
<body onload="draw();">
<canvas id="MyCanvas" width="600" height="500">This browser or document mode doesn't support canvas</canvas>
</body>
</html>
See also
Send comments about this topic to Microsoft
Build date: 11/28/2012
.png)
.png)