Skip to content

Instantly share code, notes, and snippets.

@abigpotostew
Created May 19, 2015 00:16
Show Gist options
  • Save abigpotostew/3d58fe169b6a27272d22 to your computer and use it in GitHub Desktop.
Save abigpotostew/3d58fe169b6a27272d22 to your computer and use it in GitHub Desktop.
mischief makers code walkthrough 1
int frames = 80;
boolean save_frames = true;
color[] colors = {color(202,170,221), color(26,20,20)};
void setup(){
size(500,500);
smooth(8);
}
void draw(){
if(frameCount==frames){
frameCount = 0;
}
float k = 1.0* frameCount / frames;
float kp = k*TWO_PI;
background(55,143,193);
noFill();
//draw arcs
pushMatrix();
translate(width/2, height/2);
float[] A = {0,0};
int w2 = width;
int r = 9;
int N = w2/r;
for(int i=0;i<N;++i){
float j = 1.0*N/i/20 + k;
float jp = j*TWO_PI;
/*
angles[0] = TWO_PI * ((sin(jp)+1)/2);
angles[1] = angles[0]+PI;
*/
A[0] = 0;
A[1] = TWO_PI * ((sin(jp)+1)/2);
circular_arc(r+i*r, 3, A, colors);
}
popMatrix();
if (frameCount>=frames){
frameCount=0;
}
}
//angles is radians, where angles is increasing [0..TWO_PI]
void circular_arc(float radius, int weight, float[] angles, color[] colors){
int i = 1;
strokeWeight(weight);
float a, b=0;
while (i<angles.length){
a = angles[i-1];
b = angles[i];
stroke(colors[i]);
arc(0,0, radius, radius, a, b);
++i;
}
a = b;
b = a + angles[0] + TWO_PI-a;
stroke(colors[0]);
arc(0,0, radius,radius, a,b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment