Dies war eine der ersten Übungen, bei der wir strahlen erstellen sollten.
void setup(){
size(1024,768);
smooth();
}
void draw(){
int i = 0;
background(0);
int blau = (mouseX/12);
int rot = (mouseY/12);
for (int x = 0; x <= 1024; x = x+int(random(120))) {
for (int y = 0; y <= 680; y = y+int(random(120))) {
drawHalfWay(x,y);
stroke(random(rot),random(90),blau);
}
}
}
void drawHalfWay(int theX, int theY){
int myHalfX = getAverage(mouseX, theX);
int myHalfY = getAverage(mouseY, theY);
strokeWeight(2);
line(random(mouseX*PI)*PI, random(mouseX*PI), myHalfX, myHalfY);
}
int getAverage(int theA, int theB){
int myHalfWay = ((theA + theB) / 2);
return myHalfWay;
}