canvas实现粒子文字交互聚集消散动画效果代码
代码语言:html
所属分类:粒子
代码描述:canvas实现粒子文字交互聚集消散动画效果代码
代码标签: canvas 粒子 文字 交互 聚集 消散 动画
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
*, *::before, *::after{
box-sizing: border-box;
margin: 0;
padding: 0;
}
html{ font-size: 10px; }
html, body{
display: block;
position: relative;
width: 100%;
height: 100%;
}
canvas{
display: block;
cursor: crosshair;
}
</style>
</head>
<body>
<!-- partial:index.partial.html -->
<canvas></canvas>
<!-- partial -->
<script >
(function (universe) {
///////////////////////////////////////////////////////////////////////////////
// HEAVILY INSPIRED BY: https://codepen.io/ImagineProgramming/full/LpOJzM //
// //
// HERE ARE SOME TRULY AMAZING RESOURCES I USED TO LEARN ABOUT PERLIN NOISE: //
// https://www.scratchapixel.com/ //
// http://staffwww.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf //
///////////////////////////////////////////////////////////////////////////////
function perlinSmooth(t) {return t * t * t * (10 + (6 * t - 15) * t);}
function lerp(t, v0, v1) {return v0 * (1 - t) + v1 * t;}
class Vec3D {
constructor(x = 0, y = 0, z = 0) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
dot(x, y, z) {return this.x * x + this.y * y + this.z * z;}}
const Perlin3D = function () {
//private constants
const _scrambledIndexes = [151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38,.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0