Skip to content

Instantly share code, notes, and snippets.

@cdr6934
Created March 1, 2021 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cdr6934/c92ec25d729dfd332dd206d2fb36fe21 to your computer and use it in GitHub Desktop.
Save cdr6934/c92ec25d729dfd332dd206d2fb36fe21 to your computer and use it in GitHub Desktop.
Spiraling Arc
/*
Programing: Explorations in the Arc Realm
Name: Chris Ried
*/
ArcLine[][] al;
float start_arc, stop_arc, r, diff, margin, x, y, nf;
float noise_factor;
int n;
void setup()
{
size(1000,1000);
background(255);
n = 1;
r = 2000;
noise_factor = 0.002;
diff = width / float(n);
margin = (diff) / 2;
al = new ArcLine[n][n];
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
x = (i * diff)+margin;
y = (j * diff)+margin;
nf = noise(x*noise_factor,y*noise_factor);
al[i][j] = new ArcLine(x,y+random(-5,5)*(x/width), r*nf);
}
}
}
void draw() {
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
al[i][j].draw();
al[i][j].update();
}
}
}
void saveImage() {
int seed = 100;
String timestamp = year() + nf(month(), 2) + nf(day(), 2) + "-" + nf(hour(), 2) + nf(minute(), 2) + nf(second(), 2);
saveFrame(timestamp+"-"+seed+".png");
}
class ArcLine {
float x, y, r;
float start_arc, stop_arc;
color c;
ArcLine(float _x, float _y, float _r)
{
x = _x;
y = _y;
r = _r;
start_arc = random(TWO_PI);
stop_arc = random(start_arc, TWO_PI);
}
void draw()
{
while(r > 0)
{
fill(color(int(random(255)));
stroke(0,200);
pushMatrix();
translate(x,y);
rotate(random(TWO_PI));
arc(0,0, r,r,start_arc,stop_arc);
popMatrix();
r -= random(5);
start_arc = random(TWO_PI);
stop_arc = random(start_arc, TWO_PI);
}
}
void update()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment