Processing資料(6) 様々な図形
-
Upload
reona396 -
Category
Technology
-
view
170 -
download
3
description
Transcript of Processing資料(6) 様々な図形
様々な図形
Processing資料(6)
極座標
θ
r
(r*cos(θ),r*sin(θ))
円運動
正多角形
void setup() { size(400, 400);}
void draw() { background(255);
int vertex_num = 6; //頂点数(六角形を描画 ) int R = 180; //頂点から中心までの距離 (半径) int x = width/2; //x座標の位置 int y = height/2; //y座標の位置
pushMatrix(); translate(x, y); beginShape(); for (int i = 0; i < vertex_num; i++) { vertex(R*cos(radians(360*i/vertex_num)), R*sin(radians(360*i/ vertex_num))); } endShape(CLOSE); popMatrix();}
pushMatrix,translate,popMatrix
● pushMatrix:座標の保存
● translate:座標の始点の変更指定座標が(0,0)となる
● popMatrix:保存した座標の復元
beginShape,vertex,endShape
● beginShape:頂点の記録の開始
● vertex:頂点座標の決定
● endShape:頂点の記録の終了endShape(CLOSE)することで始点と終点を閉じる
正多角形の考え方
半径Rの円を描く
正多角形の考え方
円上に等間隔に6点打つ
正多角形の考え方
6点を線でつなぐ
正多角形の考え方
六角形完成
応用 - 星
円上に等間隔に10点打つ点を偶数奇数で分ける
応用 - 星
奇数の点をより小さな円上に再配置
応用 - 星
偶数奇数に関わらず順番通りに点をつなぐ
応用 - 星
完成
応用 - 星
左へ90度回転