Coders Packet

Hirst-Painting with Python

By Sairam Patil

Millions of worth of Damien Hirst's paintings are now in Python. We'll replicate it to learn about the turtle library.

Damien Hirst is reportedly the United Kingdom's richest living artist, with his wealth estimated at $384 million in the 2020 Sunday Times Rich List.

We are going to replicate one of his famous artistic works of Damien Hirst. You can google it if you want to know more about Hirst-paintings.

 

Download any image of a painting from Google.

We are going to use exact colors as used in actual art-piece, for that we're going to use a Python library called colorgram.py.

First, we have to install this library in the terminal.

pip install colorgram.py

 

After installing just import it and use it. The syntax for it is 

colorgram.extract(image, number_of_colors)

 

Replace image with a string of file-path of image and number_of_colors with an integer i.e. how many relevant colors you want to extract from an image.

Now we have the exact RGB color pallet as an actual image so put all that in a list variable this is what I've got.

colors_rgb = [(198, 12, 32), (250, 237, 17), (39, 76, 189), (38, 217, 68), (238, 227, 5), (229, 159, 46),
              (27, 40, 157), (215, 74, 12), (15, 154, 16), (199, 14, 10), (242, 246, 252), (243, 33, 165),
              (229, 17, 121), (73, 9, 31), (60, 14, 8), (224, 141, 211), (10, 97, 61), (221, 160, 9), (17, 18, 43), 
              (46, 214, 232), (11, 227, 239), (81, 73, 214), (238, 156, 220), (74, 213, 167), (77, 234, 202), 
              (52, 234, 243), (3, 67, 40), (218, 87, 49), (174, 178, 231), (237, 169, 164), (6, 245, 223), 
              (247, 9, 42), (10, 79, 112), (16, 54, 243), (240, 16, 16)]

 

 

Hirst-Painting

 

In this project, we are going to use the Python turtle library.

We set our turtle object to put a dot every time after a specific interval and every time while deploying a

dot pick a random color from a list colors_rgb.

Then put the turtle object again original position but separate it with some distance according to your preference.

 

This is the best and easiest project, to begin with, turtle library and also to explore some new things to learn.

Keep learning and keep exploring.

Download Complete Code

Comments

No comments yet