您的当前位置:首页正文

怎样用canvas做出粒子喷泉动画的效果

2020-11-27 来源:爱够旅游网

这次给大家带来用canvas做出粒子喷泉动画的效果,怎样用canvas做出粒子喷泉动画,canvas座粒子喷泉动画需要注意哪些方面,接下来先做一个小案例

<!DOCTYPE html>
<html >
<head>
 <meta charset="UTF-8">
 <title>canvas粒子喷泉动画</title>
 <meta name="keywords" content=" canvas粒子喷泉动画" />
 <meta name="description" content=" canvas粒子喷泉动画" />
 <link rel="stylesheet" href="css/style.css">
</head>
<body>
<div>鼠标点击,增加粒子喷泉效果</div>
<canvas id="fireworks"></canvas>
<script src="js/index.js"></script>
</body>
</html>
Css部分:
body,
html,
canvas {
 margin: 0;
 padding: 0;
 background-color: #111;
 overflow: hidden;
}
 
canvas {
 background-color: transparent;
 position: relative;
 z-index: 2;
}
 
.text {
 position: absolute;
 left: 0;
 top: 20px;
 width: 100%;
 text-align: center;
 font-size: 3.7vw;
 color: #fff;
 z-index: 1;
 opacity: 0.2;
}
显示全文