In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you how to achieve rounded rectangle HTML5 related knowledge points, detailed content, clear logic, I believe that most people still know too much about this knowledge, so share this article for your reference, I hope you will learn something after reading this article, let's take a look at it.
The code is as follows:
/ / rounded rectangle
CanvasRenderingContext2D.prototype.roundRect = function (x, y, w, h, r) {
If (w < 2 * r) r = w / 2
If (h < 2 * r) r = h / 2
This.beginPath ()
This.moveTo (xonomr, y)
This.arcTo (x, y, x, y, r)
This.arcTo (x, y, h, x, y, r)
This.arcTo (x, y, r)
This.arcTo (x, y, x, w, y, r)
/ / this.arcTo (xfantr, y)
This.closePath ()
Return this
}
The parameters of this function are x coordinate, y coordinate, width, height, fillet radius. Special attention should be paid to this last parameter-fillet radius.
This method uses arcTo four times to draw a rounded rectangle, each of which has the same Radian. The coordinate point of this rounded rectangle is the same as the upper left corner of the rectangle, but his starting point is not here, but:
You can remove one of the lines and see how this method works.
Of course, as a reminder, no matter what figure you draw, remember to close the path-closePath, to avoid leaving hidden dangers.
There is a return this at the end of this method so that you can use chained syntax, such as:
Ctx.roundRect (200, 300, 200, 120, 20). Stroke (); you can remove him if you don't need it.
If you don't want to extend the ContextRenderingContext2D prototype, you can also use this method as a separate function.
These are all the contents of the article "how to achieve rounded rectangles in HTML5". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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
© 2024 shulou.com SLNews company. All rights reserved.