Languages
[Edit]
EN

JavaScript - draw shadow

0 points
Created by:
Ela-Davey
663

In this article, we would like to show you how to draw shadow on HTML canvas element using JavaScript.

To add shadow to drawings we use the following properties:

  1. shadowOffsetX - specifies the distance in pixels that shadows will be offset horizontally,
  2. shadowOffsetY - specifies the distance in pixels that shadows will be offset vertically,
  3. shadowColor - specifies the color of the shadow,
  4. shadowBlur - specifies the amount of blur applied to shadow.

1. Shadow for filled objects

Edit

In this section, we present how to add shadows to the filled square drawings.

2. Shadow for not filled objects (empty objects, frames)

Edit

In this section, we present how to add shadows to the empty square drawings.

3. Shadow for text

Edit

In this section, we present how to add shadows to the text on canvas.

References

Edit
  1. shadowOffsetX - Web APIs | MDN
  2. shadowOffsetY - Web APIs | MDN
  3. shadowColor - Web APIs | MDN
  4. shadowBlur - Web APIs | MDN

Alternative titles

  1. JavaScript - how to draw shadow on HTML canvas element
  2. JavaScript - how to add shadows to drawings on HTML canvas element
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

JavaScript - HTML5 canvas tutorial

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join