Created
May 1, 2017 01:48
-
-
Save iandioch/2e2dbbcf25b3a597110efe01acf17a53 to your computer and use it in GitHub Desktop.
repeal8.pde
This file contains hidden or 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
int iter = 0; | |
final int MAX_ITER = 120; | |
final String PHRASE = "Repeal"; | |
final int TEXT_SIZE = 96; | |
void setup() { | |
size(600, 600); | |
frameRate(60); | |
background(0); | |
noStroke(); | |
textFont(createFont("Deja Vu Sans", TEXT_SIZE, true, PHRASE.toCharArray()), TEXT_SIZE); | |
} | |
void draw() { | |
background(0); | |
iter ++; | |
if (iter <= MAX_ITER) { | |
for(int i = 0; i < iter; ++i) { | |
draw8Ellipse(i, MAX_ITER); | |
} | |
} else { | |
for (int i = MAX_ITER; i >= iter - MAX_ITER; --i) { | |
draw8Ellipse(i, MAX_ITER); | |
} | |
} | |
stroke(255); | |
textSize(TEXT_SIZE); | |
textAlign(CENTER); | |
text(PHRASE, width/2, height*9/10.0); | |
saveFrame(); | |
if (iter == MAX_ITER*2) { | |
exit(); | |
} | |
iter %= MAX_ITER*2; | |
} | |
void draw8Ellipse(int id, int total) { | |
final float size = width/10; | |
final float dist = width/8; | |
if (id < total/2) { | |
float angle = ((id+0f)/(total/2f))*TWO_PI + PI/2; | |
drawCircleEllipse(width/2, height*2/5.0 - dist, angle, dist, size); | |
} else { | |
float angle = - ((id-total/2+0f)/(total/2f))*TWO_PI + PI*3f/2; | |
drawCircleEllipse(width/2, height*2/5.0 + dist, angle, dist, size); | |
} | |
} | |
void drawCircleEllipse(float circleX, float circleY, float angle, float dist, float size) { | |
float x = circleX + cos(angle)*dist; | |
float y = circleY + sin(angle)*dist; | |
ellipse(x, y, size, size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment