day 18
用龟画了个龟
import colorgram
import turtle as turtle_module
from turtle import Turtle, Screen
import random
colors = colorgram.extract('hirst.jpg', 30)
first_color = colors[0]
rgb = colors[0].rgb
# colorlist = []
# for i in colors:
# rgb = i.rgb
# print(rgb)
colorlist = [(i.rgb.r, i.rgb.g, i.rgb.b) for i in colors]
turtle_module.colormode(255)
tim = turtle_module.Turtle()
tim.dot(20, random.choice(colorlist))
number_of_dots = 100
for dot_count in range(1, number_of_dots + 1):
tim.penup()
tim.dot(20, random.choice(colorlist))
tim.forward(50)
if dot_count % 10 == 0:
tim.setheading(90)
tim.forward(50)
tim.setheading(180)
tim.forward(500)
tim.setheading(0)
screen = Screen()
screen.exitonclick()