Skip to content

Commit 703a41f

Browse files
committed
fix dimensions for mandelbrot processing#123
1 parent 7e18f20 commit 703a41f

File tree

1 file changed

+11
-11
lines changed
  • content/examples/Topics/Fractals and L-Systems/Mandelbrot

1 file changed

+11
-11
lines changed

content/examples/Topics/Fractals and L-Systems/Mandelbrot/Mandelbrot.pde

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55
* Simple rendering of the Mandelbrot set.
66
*/
77

8+
size(640, 360);
9+
noLoop();
10+
background(255);
811

912
// Establish a range of values on the complex plane
1013
// A different range will allow us to "zoom" in or out on the fractal
11-
// float xmin = -1.5; float ymin = -.1; float wh = 0.15;
12-
float xmin = -3;
13-
float ymin = -1.25;
14+
15+
// It all starts with the width, try higher or lower values
1416
float w = 5;
15-
float h = 2.5;
17+
float h = (w * height) / width;
1618

17-
size(640, 360);
18-
noLoop();
19-
background(255);
19+
// Start at negative half the width and height
20+
float xmin = -w/2;
21+
float ymin = -h/2;
2022

2123
// Make sure we can write to the pixels[] array.
2224
// Only need to do this once since we don't do any other drawing.
@@ -39,7 +41,7 @@ float y = ymin;
3941
for (int j = 0; j < height; j++) {
4042
// Start x
4143
float x = xmin;
42-
for (int i = 0; i < width; i++) {
44+
for (int i = 0; i < width; i++) {
4345

4446
// Now we test, as we iterate z = z^2 + cm does z tend towards infinity?
4547
float a = x;
@@ -62,8 +64,7 @@ for (int j = 0; j < height; j++) {
6264
// If we never got there, let's pick the color black
6365
if (n == maxiterations) {
6466
pixels[i+j*width] = color(0);
65-
}
66-
else {
67+
} else {
6768
// Gosh, we could make fancy colors here if we wanted
6869
pixels[i+j*width] = color(n*16 % 255);
6970
}
@@ -72,4 +73,3 @@ for (int j = 0; j < height; j++) {
7273
y += dy;
7374
}
7475
updatePixels();
75-

0 commit comments

Comments
 (0)