Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to draw the graphic effect of arc rotation by HTML

2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces HTML how to draw an arc rotation graphic effect of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this HTML how to draw an arc rotation graphics effect article will have a harvest, let's take a look at it.

The code is as follows:

Var cxt=document.getElementById ('demo'). GetContext ("2d")

Cxt.beginPath ()

Cxt.arc / * draw a semicircle with center coordinates 100100; the start Radian is 0.75 and the end Radian is 1.75; the last parameter False = clockwise, true = counterclockwise, of course, this parameter is optional * /

Cxt.fillStyle= "# F00"; / * choose the color to use * /

Cxt.fill (); / * the step of actually drawing a figure on the canvas, drawing the first semicircle * /

/ * draw the second semicircle in the same way * /

Cxt.beginPath ()

Cxt.arc (170pje 100pr 50gm. PIQR 1.25ct Math.PIQR 0.25pr false)

Cxt.fillStyle= "# F00"

Cxt.fill (); / * draw the drawing on the canvas * /

Cxt.beginPath ()

/ * rotate the canvas 45 degrees clockwise, and the parameter of the rotate function is radians, so convert it * /

Cxt.rotate (45*Math.PI/180)

Cxt.fillRect (141.1 fuzz 50100100); / * the start coordinate is 141.1 meme 50, and the width and height are both 100cm /

Cxt.fillStyle= "# F00"

Cxt.fill ()

Cxt.beginPath ()

/ * rotate the canvas to a normal angle * /

Cxt.rotate (- 45*Math.PI/180)

Cxt.font= "60px Microsoft Yahei"

Cxt.strokeStyle= "# f00"

Cxt.strokeText ("I love html5", 0300); / * two parameters, the first is the x-axis coordinate to start drawing the text, and the second is the Y coordinate to start drawing the text * /

Cxt.stroke ()

/ * create a gradient * /

Var grd=cxt.createLinearGradient / * the four parameters are the start point of the gradient x, the end point of the gradient x, and the end point of the gradient x, y

Grd.addColorStop (0, "# FF0000")

Grd.addColorStop (0.25, "# FFFF00")

Grd.addColorStop (0.5, "# 00FF00")

Grd.addColorStop (.75, "# 00FFFF")

Grd.addColorStop (1, "# FFFF00")

Cxt.strokeStyle=grd

Cxt.strokeText ("I love canvas", 0400); / * two parameters, the first is the x-axis coordinate to start drawing the text, and the second is the Y coordinate to start drawing the text * /

Cxt.stroke ()

This is the end of the article on "how to draw the graphic effect of arc rotation by HTML". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to draw the graphic effect of arc rotation in HTML". If you want to learn more knowledge, you are welcome to follow 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report