import turtle as t
import math
t.setup(650, 500, 700, 300)
t.speed(5)
t.penup()
t.goto(-290, 120)
t.pendown()
# 头部轮廓
t.fillcolor("black")
t.begin_fill()
t.pensize(2)
t.seth(40)
t.circle(-450, 80)
t.seth(-90)
t.circle(-150, 55)
t.seth(-90)
t.circle(-120, 90)
t.fd(20)
t.penup()
t.fd(140)
t.pendown()
t.fd(20)
t.circle(-120, 70)
t.seth(156)
t.circle(-170, 70)
t.penup()
t.goto(-280, 115)
t.end_fill()
# 以下值这种值均用于第二重循环时的调整
M = 0
X1 = 1
X2 = 1
Y1 = 1
# 耳朵(耳朵为两只故二重循环,为了视觉效果,第二重比第一重小)
t.fillcolor("green")
for i in range(2):
t.begin_fill()
if i == 1: # 如果循环是第二重,则做以下调整
M = 1
X1 = M * 2 / 3
X2 = 3 / 2
Y1 = 0.87
t.penup()
t.setx(280)
t.seth(M * 180 + math.pow(-1, M) * 20) # 以此举例:第一重循环为原值(20)第二重循环为调整值(180-20)即(160),以此调整角度或大小
t.pendown()
t.circle(math.pow(-1, M + 1) * 150, 35 * X1)
t.seth(M * 180 + math.pow(-1, M) * (-105))
t.circle(math.pow(-1, M) * 350, 24 * X1)
t.seth((M * 180 + math.pow(-1, M) * 150) * X2)
t.circle(math.pow(-1, M + 1) * 170, 59 * X1 * Y1)
t.end_fill()
# 眼睛(二重循环,第二重的眼睛(右眼)也比第一重小)
S = -140 # 用于眼睛起始的X坐标
Z1 = 1
t.fillcolor("white")
for i in range(2):
t.begin_fill()
if i == 1:
S = 60
Z1 = 0.95
t.penup()
t.setx(S)
t.pendown()
t.seth(90)
t.circle(-70 * Z1, 180)
t.seth(-75)
t.circle(-150 * Z1, 30)
t.seth(-90)
t.circle(-70 * Z1, 180)
t.seth(-75 - 180)
t.circle(-150 * Z1, 30)
t.end_fill()
# 瞳孔(二重循环,第二重的瞳(左瞳)比第一重大)
T1 = 113 # 瞳孔起始位置x
T2 = 130 # 瞳孔起始位置y
Z2 = 1
t.fillcolor("black")
for i in range(2):
t.begin_fill()
if i == 1:
T1 = -85
Z2 = 1.05
t.penup()
t.goto(T1, T2)
t.pendown()
t.seth(90)
t.circle(-35 * Z2, 180)
t.seth(-75)
t.circle(-150 * Z2, 30)
t.seth(-90)
t.circle(-35 * Z2, 180)
t.seth(-75 - 180)
t.circle(-150 * Z2, 30)
t.end_fill()
# 身体
M2 = 0
t.fillcolor("black")
for i in range(2):
t.penup()
t.goto(-90, -120)
t.begin_fill()
if i == 1:
M2 = 1
t.goto(120, -120)
t.seth(M2 * 180 + math.pow(-1, i) * (-110))
t.pendown()
t.circle(math.pow(-1, i) * 350, 25)
t.end_fill()
# 身体补丁
t.fillcolor("black")
t.begin_fill()
t.setx(-110)
t.goto(-90, -120)
t.end_fill()
t.done()