Skip to content

Commit 661f28f

Browse files
committed
.
1 parent 4214ca6 commit 661f28f

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

Fractal Images/main.cpp

+24-7
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,37 @@ int main() {
3939

4040
histogram[iterations]++;
4141
}
42-
4342

44-
uint8_t color = (uint8_t)(256 * (double)iterations / Mandelbrot::MAX_ITERATIONS);
43+
}
44+
}
45+
46+
int total = 0;
47+
for (int i = 0; i < Mandelbrot::MAX_ITERATIONS; i++) {
48+
total += histogram[i];
49+
}
50+
51+
for (int y = 0; y < HEIGHT; y++) {
52+
for (int x = 0; x < WIDTH; x++) {
53+
54+
int iterations = fractal[y * WIDTH + x];
55+
56+
4557

46-
color = color * color * color; // it will range from 0 to 255 because uint8_t has the range from 0 to 255 only
58+
double hue = 0.0;
59+
for (int i = 0; i <= iterations; i++) {
60+
hue += ((double)histogram[i])/total;
61+
}
62+
63+
uint8_t red = 0;
64+
uint8_t green = hue*255;
65+
uint8_t blue = 0;
4766

48-
bitmap.setPixel(x, y, 0, color, 0);
4967

50-
if (color < min) min = color;
51-
if (color > max) max = color;
68+
bitmap.setPixel(x, y, red, green, blue);
5269

70+
5371
}
5472
}
55-
5673

5774
int count = 0;
5875
for (int i = 0; i < Mandelbrot::MAX_ITERATIONS; i++) {

test.bmp

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)