ArrayList<Line> lines;
void setup(){
size(500, 500);
frameRate(30);
background(0);
lines = new ArrayList<Line>();
lines.add(new Line(color(255, 182, 193, 50)));
lines.add(new Line(color(144, 238, 144, 50)));
lines.add(new Line(color(255, 255, 102, 50)));
}
void draw(){
for(Line line: lines){
line.display();
}
}
class Line{
float radianNoise;
float posXNoise;
float posYNoise;
float lenNoise;
int c;
Line(int c){
radianNoise = random(100);
posXNoise = random(100);
posYNoise = random(100);
lenNoise = random(100);
this.c = c;
}
void display(){
pushMatrix();
float time = frameCount * 0.005;
float radian = map(noise(radianNoise + time), 0, 1, 0, TWO_PI);
float posX = map(noise(posXNoise + time), 0, 1, -200, 200);
float posY = map(noise(posYNoise + time), 0, 1, -200, 200);
float len = map(noise(lenNoise + time), 0, 1, 100, 300);
translate(width / 2, height / 2);
float x1 = (len / 2) * cos(radian);
float y1 = (len / 2) * sin(radian);
float x2 = -x1;
float y2 = -y1;
translate(posX, posY);
stroke(c);
strokeWeight(1);
line(x1, y1, x2, y2);
popMatrix();
}
}