Last active
March 11, 2019 04:57
-
-
Save sasaki-shigeo/7827243 to your computer and use it in GitHub Desktop.
drawing a pentagon in Processing /
Processing で正5角形を描く
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(500, 500); | |
fill(255, 255, 0); // YELLOW | |
pentagon(250, 250, 100); | |
} | |
/** drawing a pantagon inscribed a circle as radius r ans its center is placed at (x, y). | |
*/ | |
void pentagon(float x, float y, float r) { | |
pushMatrix(); | |
translate(x, y); | |
scale(1, -1); | |
rotate(HALF_PI); | |
beginShape(); | |
for (int i = 0; i < 5; i++) { | |
vertex(r * cos(TWO_PI * i / 5), r * sin(TWO_PI * i / 5)); | |
} | |
endShape(CLOSE); | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Processing で5角形を描く
点 (x, y) を中心とする半径 r の円に内接する正5角形を描く