Created
September 16, 2018 12:22
-
-
Save wonderburg7/a85eae98f3b42af6749bf17b7c45afcf to your computer and use it in GitHub Desktop.
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
void setup() { | |
size(4000, 4000); | |
background(102); | |
// background(0); | |
strokeWeight(12); | |
} | |
void draw() { | |
pushMatrix(); | |
polygon(4000/2, 4000/2, 1800, 7); // Heptagon | |
popMatrix(); | |
pushMatrix(); | |
polygon(4000/2, 4000/2, 1800, 6); // Heptagon | |
popMatrix(); | |
pushMatrix(); | |
polygon(4000/2, 4000/2, 1800, 5); // Triangle | |
popMatrix(); | |
pushMatrix(); | |
polygon(4000/2, 4000/2, 1800, 4); // Icosahedron | |
popMatrix(); | |
pushMatrix(); | |
polygon(4000/2, 4000/2, 1800, 3); // Heptagon | |
popMatrix(); | |
save("shapesinshapes1.png"); | |
} | |
void polygon(float x, float y, float radius, int npoints) { | |
float angle = TWO_PI / npoints; | |
beginShape(); | |
for (float a = 0; a < TWO_PI; a += angle) { | |
float sx = x + cos(a) * radius; | |
float sy = y + sin(a) * radius; | |
vertex(sx, sy); | |
} | |
endShape(CLOSE); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment