canvas实现流线文本汇聚动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现流线文本汇聚动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: black;
overflow: hidden;
}
canvas {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
p, a {
color: white;
}
p {
max-width: 30%;
padding: 20px;
}
</style>
</head>
<body >
<canvas id="canvas1"></canvas>
<canvas id="canvas1"></canvas>
<script >
const canvas = document.getElementById('canvas1');
const ctx = canvas.getContext('2d');
canvas.width = 1700;
canvas.height = 500;
// canvas settings
ctx.fillStyle = 'white';
ctx.strokeStyle = 'white';
ctx.lineWidth = 1;
ctx.letterSpacing = '30px';
class Particle {
constructor(effect) {
this.effect = effect;
this.x = Math.floor(Math.random() * this.effect.width);
this.y = Math.floor(Math.random() * this.effect.height);
this.speedX;
this.speedY;
this.speedModifier = Math.floor(Math.random() * 2 + 1);
this.history = [{ x: this.x, y: this.y }];
this.maxLength = Math.floor(Math.random() * 40 + 10);
this.angle = 0;
this.newAngle = 0;
this.angleCorrector = Math.random() * 0.5 + 0.01;
this.timer = this.maxLength * 2.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0