/* built with Studio Sketchpad:
* https://sketchpad.cc
*
* observe the evolution of this sketch:
* https://studio.sketchpad.cc/sp/pad/view/ro.-OZif9hDFrk/rev.275
*
* authors:
* Bruno Buccolo
*
*
* license (unless otherwise specified):
* creative commons attribution-share alike 3.0 license.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
Pill[] pills = new Pill[50];
void setup() {
background(255);
size(600, 600);
smooth();
frameRate(30);
for (var i = 0; i < 50; i++){
pills[i] = new Pill(i*15 + 10);
}
}
void draw() {
//background(255);
for (var i = 0; i < 50; i++){
pills[i].update();
}
}
class Pill {
int rand = random(255);
float arc_length = 2*PI*(rand/255);
float start_pos = rand*PI;
float end_pos = arc_length;
int size;
float vel = (rand/255)*0.4;
int weigth = random(15) + 10;
int color = rand - 50;
int direction = (random(2) > 1 ? 1 : -1);
Pill(int size_input) {
this.size = size_input;
stroke(color, 100, 100);
strokeWeight(weigth);
arc(300, 300, size, size, start_pos, end_pos);
noFill();
}
void update() {
if (direction > 0){
start_pos = end_pos;
end_pos = (end_pos + PI/8*vel);
} else {
end_pos = start_pos;
start_pos = (start_pos -PI/8*vel);
}
stroke(random(color), random(255-color), 100);
strokeWeight(weigth);
arc(300, 300, size, size, start_pos, end_pos);
}
}