Canvas shadowColor attribute

Definition and usage

shadowColor attribute.

注释:Please set or return the color for the shadow with the shadowBlur attribute together to create a shadow.

Hint:Please use the shadowOffsetX and shadowOffsetY Use the attribute to adjust the shadow effect.

Example

Draw a blue rectangle with a black shadow:

Your browser does not support the canvas tag.

JavaScript:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.shadowBlur=20;
ctx.shadowColor="black";
ctx.fillStyle="blue";
ctx.fillRect(20,20,100,80);

Try it yourself

Syntax

context.shadowColor=color;

Attribute value

Value Description
color For shadow CSS color value. The default value is #000000.

Technical details

Default value: #000000

Browser support

Table numbers indicate the first browser version to fully support this attribute.

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
4.0 9.0 3.6 4.0 10.1

注释:Internet Explorer 8 以及更早的版本不支持 <canvas> 元素。