苦海 发表于 2015-8-8 23:33:07

Processing系列 花环图形

http://yuanren.cc/wp-content/uploads/2015/03/Wreath.png
参数化绘图 花环图形


代码如下:
void setup() {
size(300, 300);
translate(width/2, height/2);
background(55);
stroke(255);
noFill();

int n = 16, radius = 125;
Point[] points = new Point;
for (int i=0; i<n; i++) {
    float x = cos(TWO_PI/n*i)*radius;
    float y = sin(TWO_PI/n*i)*radius;
    points = new Point(x, y);
}
for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      line(points.x, points.y, points.x, points.y);
    }
}
}

class Point {
float x, y;
Point(float x, float y) {
    this.x = x;
    this.y = y;
}
}
授权转载自 任远媒体实验室
页: [1]
查看完整版本: Processing系列 花环图形