/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.hULq-k4vjn4/rev.614
*
* authors:
* Visa-Valtteri Pimiä
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
// Pressing Control-R will render this sketch.
int i = 0;
void setup() { // this is run once.
// set the background color
background(255);
// specify canvas size
size(300, 300);
// smooth edges
smooth();
// limit the number of frames per second
frameRate(30);
// set the width of the line.
strokeWeight(1);
noFill();
}
void box(int x, int y, int sx, int sy, int v) {
if (sx > 0 && sy > 0) {
int midx = x+sx/2;
int midy = y+sy/2
translate(midx+cos(millis()*0.001+x*0.01)*20, midy+sin(millis()*0.001+y*0.01)*20);
rotate((millis()*0.007+x*0.0001+y*0.0002)*y*0.0001-x*0.0001);
translate(-midx, -midy);
stroke(x*0.85);
rect(x,y,sx,sy);
box(x+v,y+v,sx-v,sy-v, v);
}
}
void draw() { // this is run repeatedly.
background(255);
stroke(0);
pushMatrix();
translate(width/2,height/2);
rotate(millis()*0.0006);
translate(-width/2,-height/2);
float bs = 180+sin(millis()*0.0001)*40;
noFill();
box(width/2-bs/2,height/2-bs/2,bs,bs, 2);
popMatrix();
}