
円弧の回転
ARC-0100 半円の円弧を回転させます。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
//=========================================== // 円弧を回転する //=========================================== // CreationDate: 2025年3月10日 月曜日21:46:3 //=================【環境設定】================ size(400, 400); //画面サイズ translate(width/2, height/2); //原点を移動 //=================【初期設定】================ noFill(); //塗りつぶしなし float start=radians(45); //円弧の開始角度 float stop=radians(135);//円弧の終了角度 int w=500; //円弧の幅 int h=500; //円弧の高さ float a=radians(10); //回転角度 //==================メイン==================== for ( int i=0; i<36;i++ ) { rotate(a); arc(0,-150,w,h,start,stop,OPEN); } |




ARC-0101 開始・終了角度を変えると違ったパターンが生まれます。


ARC-0102 色を付けてみます。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
//=========================================== // 円弧を回転する //=========================================== // CreationDate: 2025年3月14日 金曜日18:44:35 //=================【環境設定】================ size(400, 400); //画面サイズ translate(width/2, height/2); //原点を移動 //=================【初期設定】================ background(0); colorMode(HSB,360,100,100,100); color c1=color(0,100,100,20); color c2=color(275,50,100,10); noStroke(); float start=radians(0); //円弧の開始角度 float stop=radians(270);//円弧の終了角度 int w=500; //円弧の幅 int h=500; //円弧の高さ float a=radians(10); //回転角度 scale(.5,.5); //==================メイン==================== for ( int i=0; i<36;i++ ) { rotate(a); fill(lerpColor(c1,c2,norm(i,0,35))); arc(0,-300,w,h,start,stop); } |

ARC-0103 CIRCLE-0700で同心円上に並ぶ円のプログラムで円を円弧に変えてみます。円弧の向きを互い違いにしています。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
//=========================================== // 同心円上に並ぶ円弧の半径を次第に大きくしていく //=========================================== // CreationDate: 2025年3月10日 月曜日15:10:51 //=================【環境設定】================ size(400, 400); //画面サイズ translate(width/2, height/2); //原点を移動 //=================【初期設定】================ noFill(); //塗りつぶしなし ellipseMode(RADIUS); int r=20; //最初の円弧の中心 int r1=5; //最初の円弧の半径初期値 int a=4; // 次の円弧の直径初期値 float dt=radians(10);//回転角度 float x,y; float start=0; //円弧の始め float stop=PI; //円弧の終わり //==================メイン==================== for (int k=1; k<8; k++) { for (float th=0; th<TWO_PI-dt; th+=dt ) { x=r*cos(th); //円の方程式 y=r*sin(th); //円弧の向きを交互にする if (k%2==0) { start=PI; stop=TWO_PI;} else { start=0; stop=PI;} arc(x, y, r1, r1, start+th, stop+th,OPEN); //円弧の描画 } r=r+r1+r1+a/2; //次の円弧の中心 r1=r1+a/2; //次の円弧の半径 a+=6; //次の円弧の拡大 } |


ARC-0104 回転角度を広くして色を付けてみます。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
//=========================================== // 同心円上に並ぶ円弧の半径を次第に大きくしていく //=========================================== // CreationDate: 2025年3月15日 土曜日16:37:20 //=================【環境設定】================ size(400, 400); //画面サイズ translate(width/2, height/2); //原点を移動 //=================【初期設定】================ background(0); colorMode(HSB,360,100,100,100); color c1=color(184,40,80,100); color c2=color(291,50,90,100); ellipseMode(RADIUS); int r=20; //最初の円弧の中心 int r1=5; //最初の円弧の半径初期値 int a=4; // 次の円弧の直径初期値 float dt=radians(20);//回転角度 float x,y; float start=0; //円弧の始め float stop=PI; //円弧の終わり noStroke(); //==================メイン==================== for (int k=1; k<8; k++) { fill(lerpColor(c1,c2,norm(k,1,7))); for (float th=0; th<TWO_PI-dt; th+=dt ) { x=r*cos(th); //円の方程式 y=r*sin(th); //円弧の向きを交互にする if (k%2==0) { start=PI; stop=TWO_PI;} else { start=0; stop=PI;} arc(x, y, r1, r1, start+th, stop+th); //円弧の描画 } r=r+r1+r1+a/2; //次の円弧の中心 r1=r1+a/2; //次の円弧の半径 a+=6; //次の円弧の拡大 } |

ARC-0105 円弧を2つ合わせて回転して花のような図形を描きます。回転の補正をしないと微妙に傾いた図形になって気持ち悪いです。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//=========================================== // 円弧による花 //=========================================== // CreationDate: 2025年3月19日 水曜日19:31:22 //=================【環境設定】================ size(400, 400); //画面サイズ translate(width/2, height/2); //原点を移動 //=================【初期設定】================ noFill(); //塗りつぶしなし ellipseMode(RADIUS); float r=120; // 円弧の大きさ、位置 float s1=radians(270); //円弧の開始角度 float e1=radians(360); //円弧の終了角度 float s2=radians(90); float e2=radians(180); //==================メイン==================== rotate(radians(9)); //回転の補正 for ( int i=0; i<10; i++ ) { arc(0,r,r,r,s1,e1); arc(r,0,r,r,s2,e2); rotate(radians(36)); } |



コメント