File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ int main() {
22
22
double min = 99999 ;
23
23
double max = -99999 ;
24
24
25
- unique_ptr<int []> histogram (new int [Mandelbrot::MAX_ITERATIONS + 1 ]());
25
+ unique_ptr<int []> histogram (new int [Mandelbrot::MAX_ITERATIONS]());
26
26
27
27
for (int y = 0 ; y < HEIGHT; y++) {
28
28
for (int x = 0 ; x < WIDTH; x++) {
@@ -31,8 +31,13 @@ int main() {
31
31
32
32
int iterations = Mandelbrot::getIteration (xFractal, yFractal);
33
33
34
- histogram[iterations]++;
34
+
35
+ if (iterations != Mandelbrot::MAX_ITERATIONS) {
36
+
37
+ histogram[iterations]++;
38
+ }
35
39
40
+
36
41
uint8_t color = (uint8_t )(256 * (double )iterations / Mandelbrot::MAX_ITERATIONS);
37
42
38
43
color = color * color * color; // it will range from 0 to 255 because uint8_t has the range from 0 to 255 only
@@ -48,7 +53,7 @@ int main() {
48
53
cout << endl;
49
54
50
55
int count = 0 ;
51
- for (int i = 0 ; i <= Mandelbrot::MAX_ITERATIONS; i++) {
56
+ for (int i = 0 ; i < Mandelbrot::MAX_ITERATIONS; i++) {
52
57
cout << histogram[i] << " " << flush;
53
58
count += histogram[i];
54
59
}
You can’t perform that action at this time.
0 commit comments