Python Hirst Colors

You may or may not know Damien Hirst. He is an English artist whose masterpieces sell for millions of dollars.

Some of the art he is known for are "spot paintings", which are rows of randomly colored circles.

An example:

With a little Python coding skill, you can create your own Hirst color space masterpieces.

The colors are randomly chosen based on a color palette. The palette can be created using any image. Each time the program is run, a unique masterpiece will be generated.

This is a sample of what the code produces:

Here’s the code I wrote in Python:

import colorgram

import turtle as t

import random

colors = colorgram.extract('image.jpg', 20)

tim = t.Turtle()

tim.hideturtle()

tim.speed("fastest")

t.colormode(255)

tim.penup()

x_pos = -350

y_pos = -300

tim.setposition(x_pos, y_pos)

for i in range(10):

for x in range(15):

dot_color = random.randint(0, 19)

rgb = colors[dot_color].rgb

r = rgb.r

g = rgb.g

b = rgb.b

tim.dot(30, (r, g, b))

tim.penup()

tim.forward(60)

y_pos += 60

tim.penup()

tim.setposition(x_pos, y_pos)

screen = t.Screen()

screen.exitonclick()


Play around with the code and the image used to generate the colors to make your own work of art.

You may need to install colorgram as it is not part of the standard Python library.

Case Muller