4884浏览
查看: 4884|回复: 0

[项目] Processing系列 花环图形

[复制链接]

参数化绘图 花环图形


代码如下:
  1. void setup() {
  2.   size(300, 300);
  3.   translate(width/2, height/2);
  4.   background(55);
  5.   stroke(255);
  6.   noFill();
  7.   int n = 16, radius = 125;
  8.   Point[] points = new Point[n];
  9.   for (int i=0; i<n; i++) {
  10.     float x = cos(TWO_PI/n*i)*radius;
  11.     float y = sin(TWO_PI/n*i)*radius;
  12.     points[i] = new Point(x, y);
  13.   }
  14.   for (int i=0; i<n; i++) {
  15.     for (int j=i+1; j<n; j++) {
  16.       line(points[i].x, points[i].y, points[j].x, points[j].y);
  17.     }
  18.   }
  19. }
  20. class Point {
  21.   float x, y;
  22.   Point(float x, float y) {
  23.     this.x = x;
  24.     this.y = y;
  25.   }
  26. }
复制代码

授权转载自 任远媒体实验室
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail