Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas shadowOffsetY attribute

HTML canvas shadowOffsetY attribute

HTML canvas Reference HTML canvas Reference Manual

Example

Draw a rectangle with a shadow offset 20 pixels downward (from the rectangle's top position):

YourbrowserdoesnotsupporttheHTML5canvastag.

JavaScript:

var c=document.getElementById("myCanvas");

var ctx=c.getContext("2d");

ctx.shadowBlur=10;

ctx.shadowOffsetY=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 the shadowOffsetY attribute.

**Note:** Internet Explorer 8 and earlier versions do not support .


Definition and Usage

The shadowOffsetY attribute sets or returns the vertical distance between the shadow and the shape.

shadowOffsety=0 indicates the shadow is directly below the shape.

shadowOffsetY=20 indicates the shadow is 20 pixels below the shape's top position.

shadowOffsetY=-20 indicates the shadow is 20 pixels above the shape's top position.

**Tip:** To adjust the horizontal distance between the shadow and the shape, use shadowOffsetX attribute.

Default value: 0
JavaScript syntax: context.shadowOffsetY=number;

Attribute values

Value Description
number a positive or negative value to define the vertical distance between the shadow and the shape.

HTML canvas Reference HTML canvas Reference Manual