I'm trying to learn processing by converting Java algorithms to Processing.
One of the toy projects I'm working on is converting the Sierspinski to Processing
http://www.cs.princeton.edu/introcs/22library/Sierpinski.java.html
However, I seem to be able to get just a single box instead of the iterated triangles.. I am not sure what's wrong....
void setup(){//size(400,400);
int N = 10000;
float[] cx = { 0.000, 1.000, 0.500 };
float[] cy = { 0.000, 0.000, 0.866 };
float x = 0.0, y = 0.0;
for (int i = 0; i < N; i++) {
int r = (int)random(3);
x = (x + cx[r]) / 2.0;
y = (y + cy[r]) / 2.0;
point((float)x,(float) y);
}
}
1