Created
February 11, 2013 16:10
-
-
Save josephtaylor/4755411 to your computer and use it in GitHub Desktop.
This is the code that produced this Tumblr post: http://jtoprocessing.tumblr.com/post/42811336056/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PVector center; | |
float x1, y1, theta, r1, r2, x2, y2; | |
float bigTheta; | |
void setup() { | |
size(500, 500); | |
background(255); | |
smooth(); | |
stroke(0,0,0,255); | |
fill(0); | |
center = new PVector(100, 0); | |
r1 = 100; | |
r2 = -100; | |
theta = 1; | |
bigTheta = 0; | |
} | |
void draw() { | |
//this is for fading out | |
fill(255,255,255,20); | |
rect(-20,-20,width+20,height+20); | |
fill(0); | |
//move to the middle | |
translate(width / 2, height / 2); | |
//rotate the whole thing | |
rotate(bigTheta); | |
//calculate the next point for the two circles. | |
//NOTE: there's an error in here, the y's are being | |
//updated using center.x instead of center.y | |
//i'm leaving it in so it matches what I posted. | |
x1 = center.x + r1 * cos(theta); | |
y1 = center.x + r1 * sin(theta); | |
x2 = center.x + r2 * cos(theta); | |
y2 = center.x + r2 * sin(theta); | |
//draw the circles | |
ellipse(x1, y1, 20, 20); | |
ellipse(x2, y2, 20, 20); | |
//update the angles. | |
theta -= 2 * PI / 32; | |
bigTheta += 2 * PI / 128; | |
//this was used to capture frames for the animation. | |
if(bigTheta >= 2 * PI && bigTheta <= 4 * PI) { | |
//noLoop(); | |
//saveFrame("nestedAnimation######.png"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment