p5实现随机虹膜开启关闭动画效果代码
代码语言:html
所属分类:动画
代码描述:p5实现随机虹膜开启关闭动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background-color: rgb(10, 20, 30); display: flex; height: 100vh; overflow: hidden; align-items: center; justify-content: center; } </style> </head> <body translate="no"> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/p5-1.9.0.js"></script> <script > //genuary2024 - flocking; let friends; let separation; let attraction; function setup() { c = constrain(min(windowWidth, windowHeight) * 0.8, 400, 1000); cnv = createCanvas(c, c); rectMode(CENTER); angleMode(DEGREES); nFriends = int(random(20, 100)); nRot = floor(random(2, 14)); friends = []; separation = random(1, 2); attraction = random(20, 50); r1 = random(180, 225); g1 = random(180, 245); b1 = random(180, 245); background(r1 - 180, g1 - 180, b1 - 180); for (let i = 0; i < nFriends; i++) { friends[i] = { r: random(width / 10, width / 4), angle: random(0, 360), vr: random(-0.5, 0.5), va: random(-0.5, 0.5), fill: 255 }; } cnt = 0; } function draw() { translate(width / 2, height / 2); t = frameCount; fill(255); noStroke(); if (keyIsPressed && keyCode != 32) { background(r1 - 180, g1 - 180, b1 - 180, 10); } // background(10, 30, 40,2+2*sin(t/10)); for (i in friends) { fill(friends[i].fill); for (let k = 0; k < nRot; k++) { fill( r1 - abs(friends[.........完整代码请登录后点击上方下载按钮下载查看
网友评论0