Some generic remarks:
- Your
length
variable is actually used as height of the sketch...
-
width
and
height
are already predefined variables: just use numerical values in size(), and find them back in these variables. It is useful when you export to applet: Processing uses these numerical values to define the size of the applet.
- size() must be the first call in setup(). See its reference.
- "
Translate and rotate sentences doesnt seems to work with set.
" Little point in vocabulary: these are not sentences, but functions. And I never tried set() with transformations, but it is somehow logical, as it means "colorize a pixel on a surface", with absolute coordinates on the surface. I think point() will work better with respect to the transformations.
- "
random are not really random numbers.
" Not sure why you write that. If you run your sketch with, say, 300 iterations, each run will look different, so random does its work.
- "
It seems too few points, but if I try to add more, there is a message that there are too much recursion.
" Actually, you don't need recursion on this one (although that's a typical case where tail recursion would work well, if Java used it).
I played a bit with your code, here it is with the suggestions above (and some other changes):
void setup() {
size(800, 800, P2D);
background(255);
}
float x;
float y;
color col = color(255, 0, 0);
int iterations;
int maxiterations = 30000;
void draw() {
translate(width / 2, height);
rotate (PI);
stroke(col);
for (int i = 0; i < maxiterations; i++) {
transform();
}
noLoop();
}
void transform() {
float chance;
float a=0, b=0, c=0, d=0, e=0, f=0;
point(50 * x, 50 * y);
//println(str(x)+" "+str(y));
chance = random(0, 1);
if (chance <= 0.01) {
a = 0;
b = 0;
c = 0;
d = 0.6;
e = 0;
f = 0;
} else if (chance <= 0.86) {
a = 0.85;
b = 0.04;
c = -0.04;
d = 0.85;
e = 0;
f = 1.6;
} else if (chance <= 0.93) {
a = 0.2;
b = -0.26;
c = 0.23;
d = 0.22;
e = 0;
f = 1.6;
} else {
a = -0.15;
b = 0.28;
c = 0.26;
d = 0.24;
e = 0;
f = 0.44;
}
x = a*x + b * y + e;
y = c*x + d * y + f;
}
A little variant would call stroke() with different colors on each case...