canvas实现生成式ai艺术动画效果代码
代码语言:html
所属分类:动画
代码描述:canvas实现生成式ai艺术动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Barlow+Semi+Condensed:wght@100&display=swap'> <style> body { margin: 0; overflow: hidden; background-color: #f0f8ff; /* 水をイメージした背景色 */ } canvas { display: block; } </style> </head> <body translate="no"> <canvas id="canvas"></canvas> <script> const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); canvas.width = window.innerWidth; canvas.height = window.innerHeight; const numCircles = 50; const circles = []; const mouse = { x: 0, y: 0 }; const flowSpeedX = 1; // 残像効果のパラメータ const trailLength = 30; const trailFade = 0.05; class Circle { constructor() { this.x = Math.random() * canvas.width; this.y = Math.random() * canvas.height; this.radius = Math.random() * 20 + 10; this.speed = Math.random() * 2 + 1; this.amplitude = Math.random() * 5 + 2; this.phase = Math.random() * Math.PI * 2; this.color = `rgba(0, 128, 255, ${Math.random() * 0.5 + 0.2})`; this.trail = []; } update() { this.phase += this.speed * 0.01; this.y += Math.sin(this.phase) * this.amplitude; } draw() { const perspective = 1 - this.y / canvas.height; ctx.globalAlpha = perspective * (1 - trailFade); for (let i = 0; i < this.trail.length; i++) { const trailPerspective = 1 - this.trail[i].y / can.........完整代码请登录后点击上方下载按钮下载查看
网友评论0