Last active
June 14, 2016 16:27
-
-
Save Mizzlr/cfafa1e4d9c1e82ac4685606c15e1bbf to your computer and use it in GitHub Desktop.
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
PFont font; | |
void setup(){ | |
background(0); | |
size(500,500); | |
noLoop(); | |
// you can find this file in my LangtonAnt project | |
// at https://github.com/Mizzlr/LangtonAnt | |
// place FreeMonoBold.ttf in a directory named data | |
// under the Parent directory recursivePi | |
font = createFont("FreeMonoBold.ttf",24); | |
textFont(font); | |
textAlign(CENTER, CENTER); | |
} | |
void polygon(int sides){ | |
float step = radians(360.0/sides); | |
float scale = 200; | |
stroke(255); | |
strokeWeight(2); | |
line(0,height/2,width,height/2); | |
line(width/2,0,width/2,height); | |
pushMatrix(); | |
translate(width/2,height/2); | |
stroke(0,0,255); | |
noFill(); | |
ellipse(0,0,2*scale,2*scale); | |
stroke(0,255,0); | |
for (int i=0; i<sides; i++){ | |
float x1 = scale * cos(i*step); | |
float x2 = scale * cos((i+1)*step); | |
float y1 = scale * sin(i*step); | |
float y2 = scale * sin((i+1)*step); | |
line(x1,y1,x2,y2); | |
fill(255,0,0); | |
ellipse(x1,y1,10,10); | |
} | |
text("(1,0)", 200, 10); | |
text("(-1,0)", -200, 10); | |
text("(0,1)",0,-220); | |
text("(0,-1)",0,210); | |
text("(0,0)",0,0); | |
popMatrix(); | |
} | |
void draw(){ | |
polygon(4); | |
saveFrame("square.png"); | |
background(0); | |
polygon(8); | |
saveFrame("octagon.png"); | |
background(0); | |
polygon(16); | |
saveFrame("16-gon.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment