Summary

Resources

hirst_painting-final

Notes\ Code

These are the colors we extracted from a Damien Hirst dot painting in the last lesson.


color_list = [(229, 225, 221), (231, 206, 85), (218, 229, 219), (231, 222, 226), (224, 150, 89), (215, 224, 230), (120, 166, 185), (159, 14, 21), (34, 110, 157), (232, 82, 46), (124, 176, 144), (8, 97, 38), (171, 21, 16), (199, 65, 28), (185, 186, 27), (31, 128, 47), (12, 41, 74), (15, 63, 40), (242, 202, 5), (138, 82, 95), (85, 15, 22), (51, 166, 77), (44, 26, 22), (6, 65, 137), (173, 135, 149), (232, 170, 160), (48, 150, 195), (219, 66, 71), (74, 135, 186), (169, 206, 175)]

Now lets use turtle to make a spot painting of our own with turtle. Here are our requirements.

  1. We need 10 rows and 10 columns of spots.
  2. Each dot should have a radius of 20
  3. The space between the dots should be 50 paces

After a lot of research and testing, here is how I completed this project:

import turtle as t
import random

#Colorgram code that grabbed colors from image.jpg
# import colorgram
#
# rgb_colors = []
# colors = colorgram.extract('image.jpg', 30)
# for color in colors:
#     r = color.rgb.r
#     g = color.rgb.g
#     b = color.rgb.b
#     new_color = (r, g, b)
#     rgb_colors.append(new_color)
#
# print(rgb_colors)

color_list = [(229, 225, 221), (231, 206, 85), (218, 229, 219), (231, 222, 226), (224, 150, 89), (215, 224, 230), (120, 166, 185), (159, 14, 21), (34, 110, 157), (232, 82, 46), (124, 176, 144), (8, 97, 38), (171, 21, 16), (199, 65, 28), (185, 186, 27), (31, 128, 47), (12, 41, 74), (15, 63, 40), (242, 202, 5), (138, 82, 95), (85, 15, 22), (51, 166, 77), (44, 26, 22), (6, 65, 137), (173, 135, 149), (232, 170, 160), (48, 150, 195), (219, 66, 71), (74, 135, 186), (169, 206, 175)]

t.colormode(255)
yertle = t.Turtle()
screen = t.Screen()
screen.setup(width=600, height=600)
yertle.speed("fastest") # Set speed to fastest
yertle.hideturtle() # Hide the turtle icon

dot_size = 20
spacing = 50
grid = 10

def draw_dot(x, y, color):
    yertle.penup()
    yertle.goto(x, y)
    yertle.pendown()
    yertle.dot(dot_size, color)

start_x = -(grid - 1) * spacing / 2
start_y = (grid - 1) * spacing / 2

for row in range(grid):
    for col in range(grid):
        x = start_x + col * spacing
        y = start_y - row * spacing
        draw_dot(x, y, random.choice(color_list))

screen.exitonclick()

And here is my dot painting: