Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set Canvas Shadow and Transparency in HTML5

Shulou Source: shulou.com Published: 2022-06-01 10:48:38 09月21日 Update

This article mainly introduces how to set Canvas shadow and transparency in HTML5 related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this HTML5 article on how to set Canvas shadow and transparency, let's take a look.

Shadow effects mainly have the following attributes.

 shadowOffsetX = float

 shadowOffsetY = float

 shadowBlur = float

 shadowColor = color

ShadowBlur is a blur program used to set shadows. The default value is 0. ShadowColor is used to set the shadow color, which defaults to fully transparent black.

Let's learn about the production of shadow effects through an example. The sample code is as follows:

Ctx.shadowOffsetX = 10

Ctx.shadowOffsetY = 10

Ctx.shadowBlur = 5

Ctx.shadowColor = "rgba (0,0,0,0.9)"; / / Shadow color, transparency is 0.9

Ctx.font = "40px Times New Roman"

Ctx.fillStyle = "# FF0000"

Ctx.fillText ("HTML5 Research Group", 25130)

Ctx.fillStyle = "rgba"; / / set a RGBA fill color with a transparency of 0.3

Ctx.fillRect (0Pol 0300300); / / fill a rectangular area of 300mm 300

This is the end of the article on "how to set Canvas Shadow and Transparency in HTML5". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to set Canvas shadow and transparency in HTML5". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Shadow knowledge content special effects articles transparency color learning code value regions examples groups properties easy to operate articles easy to understand more see rectangle Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Apple Linux Shulou Information Shulou Tech Info