In this section, we are going to print the same image from the wall poster as a little piece of ASCII art in the terminal:
- First, we include all the headers and declare that we use the std namespace:
#include <iostream> #include <algorithm> #include <iterator> #include <complex> #include <numeric> #include <vector> using namespace std;
- The Mandelbrot set and formula operate on complex numbers. So, we define a type alias, cmplx to be of class std::complex, specializing on double values.
using cmplx = complex<double>;
- It is possible to hack together all the code for an ASCII Mandelbrot image in something around 20 lines of code, but we will implement each logical step in a separate form, and then assemble all the steps ...