Learn how to write Python code to create mathematically-based artwork like the images on this site. This 206-page PDF e-book provides simple Python code, relying only on common libraries such as Numpy, Pillow, and Matplotlib, so the reader can fully understand the math behind the images. The book intends to bridge the gap between math, code, and design.
See more details and purchase the book from my Gumroad store using the button below.Buy the book
The images on this site are all defined and drawn by algorithms written in computer code. The code either defines a mathematical function that determines what color to draw each pixel in the image, or it defines a set of drawing instructions for placing lines, shapes, and curves. In this way, code becomes the canvas on which I draw the image.
Everything you see is generated by a mathematical algorithm. There is no hand-painting or “Photoshopping” done. The only manual post-processing involves minor final adjustments to brightness and contrast to optimize each image for the printing process.
I start with the algorithm that defines the shapes and forms in the image. While there can be a lot of experimentation and discovery in this process, I have done it long enough to have developed a feel for how different equations and coefficients affect things in the image. Adjusting certain numbers make shapes wider or narrower, while other parameters shift things vertically or horizontally. While I have reasonable control over what comes out, the math is really in charge. However, I do have full control of the colors in each image. I add colors, sometimes based on things I see in the shapes and forms, and sometimes the colors are inspired by the palettes of nature.
The computer code is all my own creation, written in Python, with the only dependencies being the common Numpy library for efficient numerical computing, and the Pillow library for converting these arrays of numbers into computer image formats like JPEG and PNG.
Commercial software for drawing fractals exists, but I have found these programs to be too limiting of the creative process, or they hide away the algorithms in a “black-box” and prevent a complete understanding of how the image was really made.
Most of the images are fractals. Although the formal definition of fractal is up for debate, fractal images are generally formed by computing a mathematical function, sometimes called the "recurrence" function, repeatedly and using the results of this function to define different colors in the image.
The most famous fractal is the Mandelbrot Set. It uses the recurrence function zₙ₊₁ = zₙ² + z₀. The variable z is a complex number array that represents the coordinates of every pixel in the image. In the classic Mandelbrot set, the recurrence equation is computed many times until the value of zₙ either becomes large, or the number of iterations exceeds some threshold. If the iteration threshold is reached, the pixel is colored black. Otherwise, a color is chosen based on how many iterations it took the pixel to "escape" to a large value. This method of coloring results in the typical Mandelbrot set fractals, like the left image.
However, there are other ways of coloring a fractal. One such method is to use "orbit traps." In this method, a region of the image, called a "trap,” is defined. As the value of z changes ("orbits") with each calculation of the recurrence function, if the point lands within the trap region, the pixel will be filled with a color based on how far the point falls from the center of that trap. For example, the same Mandelbrot recurrence function, but drawn with an orbit trap along the y-axis, results in this right image.
This artwork extends these ideas to other recurrence functions and orbit trap types. The art is in choosing a recurrence function along with defining one or more carefully selected orbit traps, and adding a color palette, to produce aesthetically interesting results.
Collin Delker is an engineer by day, but an artist at heart. With a PhD in engineering, he always had an interest in creative endeavors that blend science, math, arts, and music. Just as there is beauty in a renaissance painting or symphony performance, there can be as much beauty in an electrical schematic, a well-made software algorithm, or a mathematcial equation. His mathematical artwork combines aspects of all these fields to generate the abstract images.
Appreciating and creating art makes one a better engineer, being an engineer opens new possibilities for creating art.
© 2021-2022 Collin J. Delker, https://codeismycanvas.art