/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.0Hh4MHYBarq/rev.9
*
* authors:
* GoToLoop
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
/**
* Spiral Flow Field (v2.11)
* by TfGuy44 (2014/Oct/30)
* mod GoToLoop
*
* forum.processing.org/two/discussion/7860/spiral-flow-field
* studio.processingtogether.com/sp/pad/export/ro.9$u0c$3ioIJIw/latest
*/
static final int QTY = 5120, FPS = 60;
final Par[] pars = new Par[QTY];
void setup() {
size(448, 448, JAVA2D);
frameRate(FPS);
noSmooth();
for (int i = 0; i != QTY; pars[i++] = new Par());
}
void draw() {
if (!mousePressed) background(0);
for (Par p : pars) p.display();
}
class Par {
static final short HOLE = 32;
static final float STEP = .05;
static final color OFF = -1, ON = #FF0000;
final int cx, cy;
float t = random(TWO_PI);
Par() {
float r = sq(random(sqrt(HOLE), sqrt(width/2 - HOLE)));
cx = (int)(width/2 + r*cos(t));
cy = (int)(height/2 + r*sin(t));
}
void display() {
set(cx + (int)(HOLE*cos(t += STEP)), cy + (int)(HOLE*sin(t)), OFF);
if (mousePressed) set(cx, cy, ON);
}
}