How I Used Turtle Graphics to Create Dot Paintings
I remember the day when I first started to code with "Processing". Do you know it? Of course, you do. If not, get a glance at their website. "Processing" is the go-to software when you want to be called a coding artist. It gives you plenty of prebuilt tools to make your art.
But today's blog post is not about "Processing", it is about making art with code. Since I'm currently learning python, I asked myself if there are modules for python that let me create drawings as you can do with "Processing".
And yes, there is one! It's called Turtle Graphics. It's not as professional and versatile as Processing, but it's enough for the project.
So, what are we going to build today?
We are going to write a program that creates a dot painting. Similar to the one made by Damien Hirst, which he sold for $30,000. This is what my code generated.
I'm not an art specialist. But I'm surprised by the amount of money Damien's client paid for that painting. I'm currently reading a book that explains how art is defined and priced. It's called "The 12 Million Stuffed Shark". When I've finished it, I will definitely make a blog post about that. But for now, let's leave the art analysis away, and let's talk about the actual coding. Something, I do understand ;).
As always, before I start any project, I first create a list of requirements that my project should fulfill.
First, the program asks the user for the file path of an image, from which he wants to extract the dominant colors. After that, the user can specify how big the gap between two dots should be. The program also asks for the background color and a linear function. By defining this function, you will get a diamond shape. From here on, the program becomes autonomous. Based on the inputs you gave, it prints your replica of Hirst's Dot painting. In the end, it takes a screenshot of the drawn image and saves it in your downloads folder.
That's it! Not that difficult to implement. You can replicate a $30,000 painting in under 5 seconds! Or you can create a completely new painting in the style of Pointillism. Here's another version that my program created. In this examples it uses the linear function f(x) = x.
But what does the actual code look like? Here it is. The code should be self-explanatory.
For more details on certain parts, you can always contact me via my website or social media.
If you liked this post, it would mean the world to me if you could share it with others who might be interested as well! Thanks for reading, and see you next time!