processor 發表於 2018-2-23 22:30:54

畫出六角形的方法

void setup(){
size(600,600);
}
void draw(){
background(255);
hexagon(200,200,80);
}
void hexagon(float x, float y, float r){
pushMatrix();
translate(x,y);
beginShape(POLYGON);
for(float angle = 0;angle<=PI*2;angle+=PI/3){
    vertex(r*cos(angle),r*sin(angle));
}
endShape();
popMatrix();
}
頁: [1]
查看完整版本: 畫出六角形的方法