代码:
int t = 0;
void setup(){
size(500, 500);
noStroke();
smooth();
background(0);
frameRate(60);
}
void draw(){
fill(0, 1);
rect(0, 0, width, height);
// 通过不断叠加半透明的黑色矩形,使得所画图像不断变暗;
if(t == 10){ // That's evey two seconds, 每到两秒触发画图。
popUpBubble();
t = 0;
} else {
t += 1;
}
}
void popUpBubble(){
float diameter = random(1) * 195 + 5;
float radious = diameter / 2.0;
float x = random(width - radious);
float y = random(height - radious);
fill(
255 * random(0,1),
255 * random(0,1),
255 * random(0,1),100
);
arc(x, y, diameter, diameter, 0.0, PI*2);
}
-----
本文详细介绍了如何使用纯代码在画布上动态生成并更新圆形波纹效果,通过调整参数实现图像随时间变化而变暗的效果。代码通过不断叠加半透明的黑色矩形来实现渐变,每两秒触发一次画图操作,从而达到视觉上的动态变化。
- Random bubbles fade out!!&spm=1001.2101.3001.5002&articleId=48252589&d=1&t=3&u=adda15b973a74cb5b9caa6f785623439)
1万+

被折叠的 条评论
为什么被折叠?



