membuat segi lima dengan processing
January 10, 2017
albas
membuat segi lima dengan processing grafika komputer
tugas grafika komputer membuat objek segi lima
void setup() {
size(500, 500);
background (220, 250, 220);
fill(200, 0, 220);
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();
}
0 Comments