Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Created September 16, 2018 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonderburg7/a85eae98f3b42af6749bf17b7c45afcf to your computer and use it in GitHub Desktop.
Save wonderburg7/a85eae98f3b42af6749bf17b7c45afcf to your computer and use it in GitHub Desktop.
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