/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.uF$uvk8veLr/rev.2861
*
* authors:
* Matthew
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
float i = 0.0;
float x;
float y;
float wobbleX = 0.0;
float wobbleY = 0.0;
int fadeCounter = 0;
color bg = color(230);
float[] ink = new float[20];
float[] spread = new float[3];
void setup() {
background(bg);
size(300, 300);
smooth();
frameRate(60);
fill(0);
noStroke();
x = width/2;
y = height/2;
for (int j = 0; j < 30; j++)
ink[j] = random(1.0,2.0);
spread[0] = 6.0;
spread[1] = 4.0;
spread[2] = 2.0;
}
void draw() { // this is run repeatedly.
if (fadeCounter % 30 == 0) {
fill(bg,6);
rect(0,0,width,height);
}
fadeCounter++;
newPosition();
brush();
}
void brush() {
for (float c = 0.0; c <= 2; c += 0.2) {
bristle(spread[0], 0.5 * c * PI, x, y, ink[int(c)]);
bristle(spread[1], c * PI, x, y, ink[int(c)+10]);
bristle(spread[2], 2.0 * c * PI, x, y, ink[int(c)+20]);
}
for (int j = 0; j < 30; j++)
ink[j] = constrain(ink[j]+random(-0.125,0.125),0.25,3);
for (int j = 0; j < 3; j++)
spread[j] = constrain(spread[j] + random(-0.125,0.125),5 - (2.4 * j), 8 - (2.5 * j));
}
void bristle(float radius, float theta, float xPos, float yPos, float bw) {
fill(32,64);
ellipse(radius * sin(-1 * theta) + xPos,
radius * cos(-1 * theta) + yPos,
bw, bw);
}
void newPosition() {
wobbleX = constrain(wobbleX + random(-0.35, 0.35), -25, 25);
wobbleY = constrain(wobbleY + random(-0.35, 0.35), -25, 25);
x = 75 * sin(-0.2 * i) + width/2 + wobbleX;
y = 75* cos(-0.2 * i) + height/2 + wobbleY;
i += 0.06;
}