原生js模拟粒子碰撞动画效果

代码语言:html

所属分类:粒子

代码描述:原生js模拟粒子碰撞动画效果

代码标签: 粒子 碰撞 动画 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">

<style>
body
{
   
margin: 0;
   
background: #000;
   
color: #fff;
   
overflow: hidden;
}

canvas
{
   
display: block;
   
width: 100vw;
   
height: 100vh;
}
</style>

</head>
<body translate="no">
<canvas></canvas>

<script >
const rand = (a, b) => a + Math.floor(Math.random() * (b - a + 1));
const canvas = document.querySelector("canvas");
const ctx = canvas.getContext("2d");

const numParticles = Math.floor(innerWidth * innerHeight * 7e-4);
const pixelSiz.........完整代码请登录后点击上方下载按钮下载查看

网友评论0