canvas可以实现不同动画效果,本文主要记录几种不同节日烟花效果实现。
实现一
html
css
body {
background: #000;
margin: 0;
}
canvas {
cursor: crosshair;
display: block;
}
js
// when animating on canvas, it is best to use requestAnimationFrame instead of setTimeou
代码:
[removed]
function clickEffect() {
let balls = [];
let longPressed = false;
let longPress;
let multiplier = 0;
let width, height;
let origin;
let normal;
let ctx;
const colours = [#F73859, #14FFEC, #00E0FF, #FF99FE, #FAF15D];