p5实现一个艺术目标转轮代码
代码语言:html
所属分类:其他
代码描述:p5实现一个艺术目标转轮代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> </head> <body translate="no"> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5.1.10.0.js"></script> <script > let t = 0; let isHovered = false; let hoverProgress = 0; let angularVelocity = 0; let inertia = 0; let isOverLines = false; function setup() { createCanvas(windowWidth, windowHeight); frameRate(30); } function draw() { background("#282C34"); // Dark background for better contrast noStroke(); let colors = ["#E63946", "#F1FAEE", "#A8DADC", "#457B9D", "#1D3557"]; // Vibrant color palette let circleSizes = [450, 350, 250, 150]; // Update hover progress for smooth transition if (isHovered) { hoverProgress = lerp(hoverProgress, 1, 0.02); // Slower transition for a smoother effect } else { hoverProgress = lerp(hoverProgress, 0, 0.02); // Slower transition for a smoother effect } // Apply inertia to angular velocity angularVelocity *= 0.98; // Damping to simulate friction t += angularVelocity; // Draw animated concentric circles push(); translate(width / 2, height / 2); for (let i = 0; i < circleSizes.length; i++) { let size = circleSizes[i] + 50 * sin(t + i) * hoverProgress; fill(colors[i % colors.length]); el.........完整代码请登录后点击上方下载按钮下载查看
网友评论0