計算機專業(yè)冷知識:為什么歐美的程序員越老越吃香而中國的程序員35歲就中年危...
2023-06-26 00:36 作者:分享冷知識的ikun小丑 | 我要投稿

import turtle
window = turtle.Screen()
window.bgcolor('black') # 設置背景顏色為黑色
t = turtle.Turtle()
t.speed(1) # 設置畫筆速度
def draw_heart(turtle, x, y, color):
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.color(color)
turtle.left(140)
turtle.forward(180)
turtle.circle(-100, 200)
turtle.left(120)
turtle.circle(-100, 200)
turtle.forward(180)
colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] # 顏色列表
x = -250
for color in colors:
draw_heart(t, x, -100, color)
x += 100
turtle.done()
標簽: