【发布时间】:2014-11-08 09:35:45
【问题描述】:
在处理中工作,我正在尝试构建我的第一个生成补丁。我想要发生的是开始在屏幕上的某个地方画一个圆圈(一个沿着圆圈路径的点),但是在随机的时间后,圆圈会破裂,线会在随机的方向上随机移动一段时间,并开始在别处画一个新的圆圈。
现在我画了一个圆圈,我有一个切换机制,可以在随机时间后打开和关闭。我不知道如何让它从原来的圈子“打破”,更不用说让它在其他地方开始一个新的圈子了。有人会对如何做到这一点有一些建议吗?我认为它可能有一个有趣的视觉效果。
Rotor r;
float timer = 0;
boolean freeze = false;
void setup() {
size(1000,600);
smooth();
noFill();
frameRate(60);
background(255);
timeLimit();
r = new Rotor(random(width),random(height),random(40,100));
}
void draw() {
float t = frameCount / 100.0;
timer = timer + frameRate/1000;
r.drawRotor(t);
if(timer > timeLimit()){
timer = 0;
timeLimit();
if(freeze == true){
freeze = false;
}else{
freeze = true;
}
background(255);
}
}
float timeLimit(){
float timeLimit = random(200);
return timeLimit;
}
转子类:
class Rotor {
color c;
int thickness;
float xPoint;
float yPoint;
float radius;
float angle = 0;
float centerX;
float centerY;
Rotor(float cX, float cY, float rad) {
c = color(0);
thickness = 1;
centerX = cX;
centerY = cY;
radius = rad;
}
void drawRotor(float t) {
stroke(c);
strokeWeight(thickness);
angle = angle + frameRate/1000;
xPoint = centerX + cos(angle) * radius;
yPoint = centerY + sin(angle) * radius;
ellipse(xPoint, yPoint,thickness,thickness);
}
}
【问题讨论】:
标签: geometry processing