
processing sketch: many circles v1
2 years ago
from Bill Van Loo:
This is the first version of a Processing sketch I've been working on called (unsurprisingly) "many circles". I still have some stuff to work out; namely, how to get the lines to draw only to the edge of the circles instead of to the midpoint.
My wife and I worked out some of the math, but it makes my head hurt, so I haven't tried to implement it yet.
This is the first version of a Processing sketch I've been working on called (unsurprisingly) "many circles". I still have some stuff to work out; namely, how to get the lines to draw only to the edge of the circles instead of to the midpoint.
My wife and I worked out some of the math, but it makes my head hurt, so I haven't tried to implement it yet.
-
Vimeo: About / Blog / Developers / Jobs / Community Guidelines / Community Forums / Help Center / Site Map / Merchandise
/ Get Vimeo

Previous Week
My question for you: how did you get the fading look later in the video? And the changing to single colors so late in the sketch? Was this done post-processing or using several versions or did you just count the frames for the entirety?
void setup(){
size(800,600);
background(0);
frameRate(10);
}
void draw(){
smooth();
circle(random(-width/2,width/2),random(-height/2,height/2),random(20,60));
}
void circle(float x, float y, float size){
pushMatrix();
translate(width/2,height/2);
scale(1,-1);
fill(random(0,255),random(0,255),random(0,255),130);
strokeWeight(1);
stroke(255,160);
ellipse(x,y,size,size);
stem(x,y,size);
popMatrix();
}
void stem(float x, float y, float size){
float radius = size/2;
float dist = sqrt(sq(x)+sq(y));
if (x == 0) {
line(0,0,0,y-radius);
}
else {
float distNew = dist - radius;
float slope = y/x;
float x2 = sqrt(sq(distNew)/(sq(slope)+1));
float y2 = slope*x2;
if (x < 0) {
x2 = -x2;
y2 = -y2;
}
line(0,0,x2,y2);
}
}