Latest web development tutorials

HTML canvas shadowColor property

Canvas Object Reference Canvas object

Examples

Draw a red rectangle with a black shadow:

YourbrowserdoesnotsupporttheHTML5canvastag.

JavaScript:

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 9, Firefox, Opera, Chrome and Safari support shadowColor property.

Note: 8 and earlier versions of Internet Explorer do not support the <canvas> element.


Definition and Usage

shadowColor property sets or returns the color for the shadow.

Note: Please shadowColor property shadowBlur property used together to create a shadow.

Tip: By using shadowOffsetX and shadowOffsetY to adjust the shadow effect properties.

Defaults: # 000000
JavaScript syntax: context.shadowColor = color;

Property Value

描述
color 用于阴影的 CSS 颜色值 。默认值是 #000000。


Canvas Object Reference Canvas object