RosettaCodeData/Task/Julia-set/Processing/julia-set.processing

29 lines
613 B
Plaintext

float cX = -0.7;
float cY = 0.27015;
float zx, zy;
float maxIter = 300;
void setup() {
size(640, 480);
}
void draw() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
zx = 1.5 * (x - width / 2) / (0.5 * width);
zy = (y - height / 2) / (0.5 * height);
float i = maxIter;
while (zx * zx + zy * zy < 4 && i > 0) {
float tmp = zx * zx - zy * zy + cX;
zy = 2.0 * zx * zy + cY;
zx = tmp;
i -= 1;
}
colorMode(HSB);
color c = color(i / maxIter * 255, 255, i > 1 ? 255 : 0);
set(x, y, c);
}
}
noLoop();
}