C++C++11C++14C++17Learn C++

Tutorial: Learn To Print Mandelbrot In Text Form In C++

In mathematics, fractals are a self-similar subset of Euclidean space whose fractal dimensions strictly exceeds its topological dimension. So when you draw these functions in their topological height, fractals appear the same at different levels, as illustrated in successive magnifications of the Mandelbrot set.

Mandelbrot set is a good example to see how fractals are changing in every x,y and z planes. Drawing a Mandelbrot set exhibit an elaborate and infinitely complicated boundary that reveals progressively ever-finer recursive details at increasing zooming that makes the boundary of the Mandelbrot set as in fractal curves. The Mandelbrot set basically defined as a function of f(z)=z^2+c where z and c are complex numbers.

C++ Builder is easy to draw or print these kind of graphics, it includes compilers for Win32, Win64, Android and iOS. C++Builder has both CLANG Enhanced C/C++ Compiler and a Borland C/C++ Compiler. It also features a modern, high-productivity RAD Studio IDE, debugger tools, and enterprise connectivity for to accelerate cross-platform UI development. You can develop GUI based applications easily, as it comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for cross-platform UIs. There is a free C++ Builder Community Edition that can be used by students, beginners and startups with limitations.

You can download Free the C++ Builder Community Edition (CE) here: https://www.embarcadero.com/products/cbuilder/starter.
Professional developers can use the Professional, Architect or Enterprise versions of C++ Builder. You can download and use the trial version for one month with the same capabilities as the full version . Please visit https://www.embarcadero.com/products/cbuilder.

In this post we want to show you how you can printout a Mandelbrot set in text form in C++ Builder. While we are able to draw as shown above in graphics we want to have fun with printing it in text form.

1.Create a new Multi-Device C++ Builder Console project, Save all unit and project files into a folder.

2. Let’s do as simple as possible. Clear all codes, add these library includes.

3. Now let’s create our own text_mandelbrot(…) function to draw a Mandelbrot set in text form as a console.

As given in here we defined two complex numbers

We loop in row and column as x and y coordinates, and we calculate height of this function with complex numbers related with these row and column,

4. Finally we need to define our main function to run our text_mandelbrot(…) function.

5. Hit F9 to run your codes or run your code from Run button.

That’s all. This simple code compatible with most of C++ compilers, you may need few changes in some compilers. You can improve this code by drawing a part of this function (like zooming to a portion of it). Or you can use Bitmaps and directly draw it with full details. Don’t worry about calculations and speed about to draw these kind of functions in math. Because C++ is faster to calculate and draw these things. You can also use parallel programming methods to use all of your CPU and GPU cores draw anything multiple times faster.

Full Lines of VCL Console Application in C++ Builder should be like this;

And the result will be like this;

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17Language FeatureLearn C++

How To Use The SVG Image Format With Skia In C++ Builder

C++C++17Language FeatureLearn C++

How To Use Skia Images in C++ Builder?

C++C++17Code SnippetGame DevelopmentLanguage FeatureLearn C++

What Is Skia In Modern C++?

C++C++17Learn C++

How To Use Skia in C++ Builder 12?