Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize Wave effect Map by html5

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

This article mainly introduces html5 how to achieve wave effect map related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this html5 how to achieve wave effect map article will have a harvest, let's take a look at it.

First draw a simple circle to make a new shake straight microcircle.

Var ctx = document.getElementById ('myCanvas'). GetContext (' 2d')

Ctx.lineWidth = 1

Ctx.strokeStyle = "orange"

Ctx.arc (100, 100, 100, 90, 0, 10, 7, 2, 9, 9, 2, 9, 2, 9, 2, 9, 2, 9, 2, 4, 2, 4, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,

Ctx.stroke ()

Rolling up and down in the circle is the line that direct friends can read and move.

Var ctx = document.getElementById ('myCanvas'). GetContext (' 2d')

Var y = 100

Var flag = 0

Function init () {

/ / clear canvas

Ctx.clearRect (0Pol 0200200)

/ / calculate the corresponding x value as the y value moves up and down on the left semicircle

/ / var y = 30

Var expression = 8100-Math.pow ((100mury), 2)

Var x = 100-Math.sqrt (expression)

Ctx.beginPath ()

Ctx.lineWidth = 1

Ctx.strokeStyle = "orange"

Ctx.arc (100, 100, 100, 90, 0, 10, 7, 2, 9, 9, 2, 9, 2, 9, 2, 9, 2, 9, 2, 4, 2, 4, 2, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,

Ctx.stroke ()

Ctx.lineWidth = 1

Ctx.strokeStyle = "green"

Ctx.beginPath ()

Ctx.moveTo (XBI y)

Ctx.lineTo (200murx, y)

Ctx.stroke ()

If (flag = = 0) {

Y + = 1

If (y = = 130) {

Flag = 1

}

} else {

Y-= 1

If (y = = 70) {

Flag = 0

}

}

Window.requestAnimationFrame (init)

}

In the whole process, the simulated water needs more ups and downs than the need to shake friends.

Var ctx = document.getElementById ('myCanvas'). GetContext (' 2d')

Var y = 100

Var flag = 0

Function init () {

/ / clear canvas

Ctx.clearRect (0Pol 0200200)

/ / calculate the corresponding x value as the y value moves up and down on the left semicircle

Var expression = 8100-Math.pow ((100mury), 2)

Var x = 100-Math.sqrt (expression)

Ctx.lineWidth = 1

Ctx.strokeStyle = "green"

Ctx.beginPath ()

Ctx.moveTo (XBI y)

Ctx.lineTo (200murx, y)

Ctx.stroke ()

/ / calculate the point at which the starting point of the circle (the right endpoint of the diameter parallel to the X axis) and the given Y coordinate on the left side of the circle

Var distance = Math.sqrt (Math.pow ((190murx), 2) + Math.pow ((100mury), 2))

/ / sina=d/2r an is half of the angle 2a is the center angle of two points Math.asin the final result is radians such as asin (1) = 1/2*PI

Var angle = Math.asin (distance/180) * 2

Ctx.beginPath ()

If (y)

Tags: Coordinate Radian semicircle effect effect up and down right Wave move Center Angle Angle diameter knowledge Endpoint result parallel start two content Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Shulou Tech Info OPPO Reno vpn Redmi