Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.