
Gerard
RechteckRum
beschreibung
lösung der hausaufgabe. kurz aber eher unpraktikabel.
kommentare
Neuer Kommentar...
code
void setup() {
size(200, 200);
background(0);
noStroke();
frameRate(60);
}
int position = 0;
int RECT_SIZE = 30;
void draw() {
background(0);
position = (position + 4) % ((width + height) * 2 - RECT_SIZE * 4);
if ( position < width + height - RECT_SIZE * 2 ) {
rect(constrain(position, 0, width - RECT_SIZE), constrain(position - width + RECT_SIZE, 0, height - RECT_SIZE), RECT_SIZE, RECT_SIZE);
}
else {
rect(width - RECT_SIZE - constrain(position - width - height + RECT_SIZE * 2, 0, width - RECT_SIZE), height - RECT_SIZE - constrain(position - width * 2 - height + RECT_SIZE * 3, 0, height - RECT_SIZE), RECT_SIZE, RECT_SIZE);
}
}