Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use HTML5 to make fireworks effect

Shulou Source: shulou.com Published: 2022-06-01 11:08:39 10月27日 Update

This article mainly introduces "how to use HTML5 to make fireworks effect". In daily operation, I believe many people have doubts about how to use HTML5 to make fireworks effect. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use HTML5 to make fireworks effect". Next, please follow the editor to study!

The principle is simple. Just write a fireworks class and debris class, instantiate and let it fly, and then after reaching a certain point, set the dead property of the fireworks object to true, then instantiate a certain number of debris objects, and give the debris objects a random target point to reach, and then let all the debris objects fly over.

[fireworks]

XML/HTML Code copies content to the clipboard

VarBoom=function {/ / pyrotechnic object (x _ rer _ cmeno _ boomia _ shape)

This.booms=? []

This.x=?x

This.y=? (canvas.height+r)

This.r=?r

This.c=?c

This.shape=?shape? | |? false

This.boomArea=?boomArea

This.theta=0

This.dead=false

This.ba=parseInt (getRandom)

}

Boom.prototype=? {

_ paint:function () {

Ctx.save ()

Ctx.beginPath ()

Ctx.arc (this.x,this.y,this.r,0,2*Math.PI)

Ctx.fillStyle=this.c

Ctx.fill ()

Ctx.restore ()

}

_ move:function () {

Vardx=this.boomArea.x?-?this.x?,dy=this.boomArea.y?-?this.y

Thisthis.x=?this.x+dx*0.01

Thisthis.y=?this.y+dy*0.01

If (Math.abs (dx))

Tags: Objects fireworks crumbs effects production content that is learning that is clipboard shapes clippings pixels pictures examples arrays methods more canvases colors Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Redmi Shulou Technology MySQL Docker