
第 19 章 Processing
200
範例 19-2
圓圈要多少有多少
int numberOfCircles = 10;
int[] x = new int[numberOfCircles];
int[] y = new int[numberOfCircles];
int[] dim = new int[numberOfCircles];
int[] colour = new
int[numberOfCircles];
int[] pitch = new int[numberOfCircles];
void setup()
{
size(500, 200);
int distance = height /
numberOfCircles;
int temp = distance / 2;
for (int i = 0; i <
numberOfCircles;i++)
{
y[i] = temp;
temp =
temp + distance;
dim[i] = int(random(5, 2.5 *
distance));
colour[i] = int(random(255));
pitch[i] = int(random(1, 15));
}
}
void draw()
{
background(200);
for (int i = 0; i < numberOfCircles;
i++)
{
x[i] = x[i] + pitch[i];
fill(colour[i]);
ellipse(x ...