【发布时间】:2015-11-04 17:13:11
【问题描述】:
我想知道如何在圆内绘制随机(法线或曲线)线,这意味着这些线不会越过圆的边界。
下面是画圆的代码:
size(900, 900);
background(80, 89, 81);
int n = 50; // aantal (element count)
for (int i = 0; i <n; i++) {
float x1 = 20*i;
float x2 =-10+20*i;
float x3 =x2+20;
float x11 = 10+20*i;
float x22 = x1;
float x33= x22+20;
for (int j = 0; j < n; j++) {
float y1 = 30+30*j;
float y2 = 30*j;
float y3 = y2;
float y11 = y2;
float y22 = y1;
float y33 = y1;
float a = random(10, 90);
if (j%2==0) {
noStroke();
fill(0);
triangle(x1, y1, x2, y2, x3, y3);
fill(255, 255, 255, a);
triangle(x11, y11, x22, y22, x33, y33);
} else {
noStroke();
fill(255, 255, 255, a);
triangle(x1, y1, x2, y2, x3, y3);
fill(0);
triangle(x11, y11, x22, y22, x33, y33);
}
}
}
for (int t=0; t<40; t++) {
ellipse(450, 450, 800-20*t, 800-20*t);
fill(0+t*2, 0+t*2, 0+t*2);
}
该代码生成此图像:
【问题讨论】:
标签: processing