/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://accdf12.sketchpad.cc/sp/pad/view/ro.4oBGZSlEWp1/rev.2
*
* authors:
* Dansun Hwang
* Michael Kontopoulos
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
void setup(){
size(640,480);
smooth();
rectMode(CENTER);
strokeWeight(5);
}
void draw(){
background(150);
transformLines(mouseX);
transformRect(mouseX);
}
float angle=0, scaler=0;
void transformRect(float input){
float targetAngle = map(input, 0,width, 0, TWO_PI);
float targetScaler = map(input, 0,width, 1, 2.5);
angle += (targetAngle - angle) * 0.085;
scaler+= (targetScaler - scaler) * 0.075;
pushMatrix();
translate(width/2, height/2);
scale(scaler);
rotate(angle);
rect(0,0, 100, 50);
popMatrix();
}
void transformLines(float input){
float inc = map(input, 0,width, 5, 50);
inc = constrain(inc, 5, 50);
for(int i=height/2; i>=0; i-=inc){
line(0, i, width, i);
}
for(int i=height/2; i<=height; i+=inc){
line(0, i, width, i);
}
}