Javascript examples for Canvas Reference:shadowOffsetY
The shadowOffsetY property sets or gets the vertical distance of the shadow from the shape.
shadowOffsety = 0 starts the shadow right behind the shape while shadowOffsetY = 20 starts the shadow 20 pixels below the shape's top position.
context.shadowOffsetY = number;
Value | Description |
---|---|
number | A positive or negative number that defines the vertical distance of the shadow from the shape |
Draw a rectangle with a shadow placed 20 pixels below the rectangle's top position:
JavaScript:
<!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="300" height="250" style="border:1px solid #d3d3d3;"> Your browser does not support the HTML5 canvas tag.</canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.shadowBlur = 10;//from www . j a v a 2s . c o m ctx.shadowOffsetY = 20; ctx.shadowColor = "black"; ctx.fillStyle = "red"; ctx.fillRect(20, 20, 100, 80); </script> </body> </html>