/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.cOmBABQ5wxr/rev.5
*
* authors:
* GoToLoop
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/**
* Square Flower (v2.1)
* by Jordan Orelli (2013/Dec)
* mod GoToLoop
*
* http://jordanorelli.tumblr.com/post/70910152988/square-flower
* https://gist.github.com/jordanorelli/8100924
*
* studio.processingtogether.com/sp/pad/export/ro.9AzN8ufMfio2x/latest
*/
static final int DIM = 040, CURVE = -010;
static final int NUM = 050, FRAMES = 0200;
static final float RAD = 0200, LARGE = 0120, FORM = 5;
static final color BG = -1, FG = #0000FF;
static final boolean SAVE_FRAMES = true;
static String path;
void setup() {
size(500, 500);
frameRate(60);
smooth(4);
rectMode(CENTER);
strokeWeight(2);
stroke(FG);
fill(BG);
//path = dataPath("###.png");
}
void draw() {
background(BG);
translate(width>>1, height>>1);
for (int i = 0; i != NUM; drawRect(i++));
//if (SAVE_FRAMES & frameCount <= FRAMES) saveFrame(path);
}
void drawRect(int i) {
final float n1 = norm(i, 0, NUM) * TWO_PI;
final float n2 = norm(frameCount, 0, FRAMES) * TWO_PI;
final float offset = sin(FORM*n1 + n2) * LARGE + RAD;
pushMatrix();
rotate(n1);
rect(offset, 0, DIM, DIM, CURVE);
popMatrix();
}