用 Processing 绘制 「太极图」| 数字艺术专栏

今天代码哥,要跟大家从传统文化 “太极” 聊起 ……

构思
translate(width/2, height/2);fill(230,5);rect(-width/2, -height/2, width, height);fill(0);arc(0, 0, width, height, PI/2, PI*3/2);fill(255);arc(0, 0, width, height, -PI/2, PI/2);noStroke();arc(width/4 * cos(-PI/2),height/4 * sin(-PI/2),width/2,width/2,PI/2, PI*3/2);fill(0);arc(width/4 * cos(PI/2),height/4 * sin(PI/2),width/2,width/2,-PI/2, PI/2);fill(255);ellipse(width/4 * cos(PI/2),height/4 * sin(PI/2),width/10, width/10);fill(0);ellipse(width/4 * cos(-PI/2),height/4 * sin(-PI/2),width/10,width/10);

30x 
60x 
90x 
随着旋转频率的增加,可以观察到有意思的现象。
代码
float deltaAngle = 0.0f;void setup(){size(800,800);}void draw(){translate(width/2, height/2);fill(230,5);rect(-width/2, -height/2, width, height);deltaAngle += -TWO_PI/360 * 1;// 绘制两个外半圆fill(0);arc(0, 0, width, height, PI/2 + deltaAngle, PI*3/2 + deltaAngle);fill(255);arc(0, 0, width, height, -PI/2 + deltaAngle, PI/2 + deltaAngle);// 绘制两个内半圆noStroke();arc(width/4 * cos(-PI/2 + deltaAngle),height/4 * sin(-PI/2 + deltaAngle),width/2,width/2,PI/2 + deltaAngle, PI*3/2 + deltaAngle);fill(0);arc(width/4 * cos(PI/2 + deltaAngle),height/4 * sin(PI/2 + deltaAngle),width/2,width/2,-PI/2 + deltaAngle, PI/2 + deltaAngle);// 绘制两个圆fill(255);ellipse(width/4 * cos(PI/2 + deltaAngle),height/4 * sin(PI/2 + deltaAngle),width/10,width/10);fill(0);ellipse(width/4 * cos(-PI/2 + deltaAngle),height/4 * sin(-PI/2 + deltaAngle),width/10,width/10);}

专栏作者:恒成立
上海理工大学 光电硕士
热爱折腾与创造
加入社群交流评论
