@@ -51,16 +51,41 @@ void display_julia(std::size_t width, std::size_t height, std::complex<double> c
51
51
auto x_step = X_DIM * 2 / static_cast <double >(width);
52
52
auto y_step = Y_DIM * 2 / static_cast <double >(height);
53
53
54
+ for (std::size_t j = 0 ; j < height; ++j) {
55
+ for (std::size_t i = 0 ; i < width; ++i) {
56
+ double x = -X_DIM + i * x_step;
57
+ double y = -Y_DIM + j * y_step;
58
+
59
+ auto iterations = compute_iterations ({x, y}, constant, MAX_ITERATIONS);
60
+
61
+ display.set_pixel (
62
+ i, j,
63
+ static_cast <int >(iterations / static_cast <double >(MAX_ITERATIONS) * 255 )
64
+ );
65
+ }
66
+ }
67
+
68
+ display.display_window ();
69
+ }
70
+
71
+ void display_mandelbrot (
72
+ std::size_t width, std::size_t height, std::complex<double > constant
73
+ )
74
+ {
75
+ fractal::BasicDisplay display;
76
+
77
+ auto x_step = X_DIM * 2 / static_cast <double >(width);
78
+ auto y_step = Y_DIM * 2 / static_cast <double >(height);
79
+
54
80
for (std::size_t j = 0 ; j < height; ++j) {
55
81
for (std::size_t i = 0 ; i < width; ++i) {
56
82
// Compute complex coordinates from pixel index
57
83
double x = -X_DIM + i * x_step;
58
84
double y = -Y_DIM + j * y_step;
59
85
60
86
// Compute the number of iterations
61
- auto iterations = compute_iterations ({x, y}, constant , MAX_ITERATIONS);
87
+ auto iterations = compute_iterations (constant, {x, y}, MAX_ITERATIONS);
62
88
63
- // Draw the pixel
64
89
display.set_pixel (
65
90
i, j,
66
91
static_cast <int >(iterations / static_cast <double >(MAX_ITERATIONS) * 255 )
@@ -97,7 +122,7 @@ int main(int argc, char** argv)
97
122
auto width = program.get <int >(" width" );
98
123
auto height = program.get <int >(" height" );
99
124
100
- display_julia (width, height, {1.0 / 4 , 0 });
125
+ display_mandelbrot (width, height, {0 , 0 });
101
126
102
127
return 0 ;
103
128
}
0 commit comments