In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how html5 draws rectangular animation. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Let's take a look at the simple geometry built into Canvas-the drawing of rectangles. In Canvas, there are three ways to draw a rectangle: fillRect, StrokeRect, and clearRect. Of course, we can also use "path" to depict all shapes, including rectangles.
The following is the API of the above three methods:
1.fillRect (xpendium, widthand height). Draw a solid rectangle with a width of width and a height of height, starting with (xQuery y).
2.strokeRect (xpendium, widthand height). Draw a rectangle with a width of width and a height of height, starting with (xQuery y). The rectangle is rendered into different styles depending on the strokeStyle, lineWidth, lineJoin, and miterLimit properties currently set.
3.clearRect (xpendium, widthand height). Clears a rectangular area with a width of width and a height of height, starting with (xQuery y), so that it is completely transparent.
Before calling the above method to draw the Canvas, we need to set the style of the fill and stroke. The most basic way to set these styles is to use 24-bit colors (represented by hexadecimal strings). Here is a simple example:
The copy code is as follows:
Context.fillStyle= "# 000000"
Context.strokeStyle= "# ff00ff"
In the following example, the fill color is set to black and the stroke color is set to purple:
The copy code is as follows:
Function drawScreen () {
Context.fillStyle= "# 000000"
Context.strokeStyle= "# ff00ff"
Context.lineWidth=2
Context.fillRect (10, 10, 40, 40)
Context.strokeRect (0,0,60,60)
Context.clearRect (20, 20, 20, 20)
}
Thank you for reading! This is the end of this article on "how to draw rectangular animation in html5". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Simply lay the groundwork and look at it first.
© 2024 shulou.com SLNews company. All rights reserved.