您的位置:首页 > 其它

Processing 练习(5)- Random bubbles fade out!!

2015-09-07 10:21 323 查看


代码:

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);
}


-----
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: