案例代码:
# -*- coding utf-8 -*-
from turtle import *
hideturtle()
delay(0)
# 嘴
# 1.外形
# 1.1.右半边
pensize(3)
n = 33
while n != 1:
n -= 1
left(0.7)
forward(3)
seth(270)
n = 0
while n != 56:
n += 1
if n < 12:
right(0.3)
elif n < 22:
right(1.5)
elif n == 22:
right(20)
elif n < 32:
right(3)
elif n < 60:
right(0.7)
forward(3)
# 1.2.左半边
penup()
goto(0, 0)
pendown()
seth(180)
n = 27
while n != 1:
n -= 1
right(0.7)
forward(4)
seth(270)
n = 0
while n != 56:
n += 1
if n < 12:
left(0.3)
elif n < 22:
left(1.5)
elif n == 22:
left(20)
elif n < 32:
left(3)
elif n < 60:
left(0.7)
forward(3)
# 2.牙齿
# 2.1.中间
pensize(2)
penup()
goto(0, 0)
pendown()
seth(250)
n = 0
while n != 27:
n += 1
if n < 20:
left(2)
else:
left(0.5)
if n == 15:
seth(270)
forward(3)
# 2.2.右边
penup()
goto(30, -5)
pendown()
seth(260)
n = 0
while n != 22:
n += 1
left(2)
if n == 10:
seth(265)
forward(3)
penup()
goto(65, 3)
pendown()
seth(260)
n = 0
while n != 20:
n += 1
left(1)
forward(3)
penup()
goto(85, -10)
pendown()
seth(260)
n = 0
while n != 5:
n += 1
left(1)
forward(3)
# 2.3.中间
penup()
goto(-95, -33)
pendown()
seth(-5)
n = 0
while n != 40:
n += 1
left(0.1)
forward(3)
seth(5)
n = 0
while n != 23:
n += 1
left(0.7)
forward(3)
# 2.4.左边
penup()
goto(-40, -5)
pendown()
seth(280)
n = 0
while n != 22:
n += 1
right(2)
if n == 10:
seth(280)
forward(3)
penup()
goto(-69, 3)
pendown()
seth(280)
n = 0
while n != 23:
n += 1
right(1)
forward(3)
penup()
goto(-95, -5)
pendown()
seth(280)
n = 0
while n != 12:
n += 1
right(1)
forward(3)
# 3.脸形
pensize(4)
penup()
goto(-101, -60)
pendown()
seth(-40)
n = 0
while n != 73:
n += 1
left(1)
if n == 25:
left(5)
if n == 50:
left(6)
forward(3)
seth(0)
n = 0
while n != 20:
n += 1
left(6)
if n == 6:
left(10)
if n == 10:
left(10)
if n == 15:
left(40)
if n == 18:
left(40)
forward(6)
penup()
goto(110, -35)
pendown()
seth(70)
forward(35)
right(40)
forward(10)
penup()
goto(115, 10)
pendown()
seth(75)
forward(20)
left(10)
forward(90)
goto(120, 70)
goto(60, 160)
goto(80, 70)
goto(10, 190)
goto(15, 130)
goto(-10, 190)
penup()
goto(-30, 190)
pendown()
goto(10, 90)
goto(-50, 175)
penup()
goto(-85, 170)
pendown()
goto(-95, 60)
goto(-110, 125)
seth(240)
n = 0
while n != 80:
n += 1
left(0.65)
forward(1)
goto(-120, 100)
seth(240)
n = 0
while n != 80:
n += 1
left(0.65)
forward(1)
forward(20)
penup()
goto(-105, -60)
pendown()
seth(180)
n = 0
while n != 20:
n += 1
right(6)
if n == 6:
right(10)
if n == 10:
right(10)
if n == 15:
right(40)
if n == 18:
right(40)
forward(6)
penup()
goto(-115, -45)
pendown()
seth(110)
forward(35)
left(40)
forward(15)
penup()
goto(-150, 10)
pendown()
seth(100)
forward(20)
goto(-170, 0)
goto(-155, 65)
goto(-155, 65)
goto(-195, 35)
goto(-165, 75)
goto(-205, 50)
seth(55)
n = 0
while n != 25:
n += 1
right(0.5)
forward(5)
goto(-150, 170)
goto(-100, 160)
seth(30)
n = 0
while n != 40:
n += 1
right(1.5)
forward(5)
goto(140, 156)
goto(115, 136)
goto(160, 115)
goto(140, 110)
goto(170, 40)
goto(140, 60)
goto(155, 25)
goto(140, 50)
goto(145, 10)
goto(135, 20)
goto(130, 8)
# 4.帽子
penup()
goto(-250, 70)
pendown()
seth(75)
n = 0
while n != 215:
n += 1
if n == 90:
seth(5)
if n == 130:
seth(-7)
if n < 90:
right(0.8)
elif n >= 130:
right(0.8)
elif n >= 90:
right(0.3)
forward(3)
penup()
goto(-160, 190)
pendown()
seth(80)
n = 0
while n != 150:
if n == 40:
seth(20)
if n == 110:
seth(-40)
n += 1
if n < 40:
right(1)
elif n > 110:
right(1)
elif n > 40:
right(0.6)
forward(3)
# 5.脸部表情
# 5.1.眼睛
pensize(5)
penup()
goto(-90, 38)
pendown()
seth(45)
n = 0
while n != 55:
n += 1
right(1.8)
forward(1)
penup()
goto(40, 38)
pendown()
seth(45)
n = 0
while n != 55:
n += 1
right(1.8)
forward(1)
# 5.2.鼻子
pensize(3)
penup()
goto(-35, 35)
pendown()
seth(15)
forward(30)
n = 0
while n != 20:
n += 1
right(0.2)
forward(0.3)
seth(-15)
forward(30)
seth(-80)
n = 0
while n != 15:
n += 1
right(1)
forward(1)
penup()
goto(-35, 20)
pendown()
seth(15)
forward(30)
n = 0
while n != 20:
n += 1
right(0.2)
forward(0.3)
seth(-15)
forward(30)
penup()
goto(-35, 20)
pendown()
seth(125)
n = 0
while n != 20:
n += 1
right(2.1)
forward(1)
penup()
goto(-10, 15)
pendown()
seth(20)
forward(5)
penup()
goto(0, 15)
pendown()
forward(10)
seth(90)
forward(10)
penup()
goto(10, 42)
pendown()
forward(15)
penup()
goto(-55, 60)
pendown()
seth(-30)
forward(28)
penup()
goto(30, 50)
pendown()
seth(30)
n = 0
while n != 30:
n += 1
right(1)
forward(1)
# 眉毛
pensize(2)
penup()
goto(-90, 80)
pendown()
seth(45)
n = 0
while n != 55:
n += 1
right(1.8)
forward(1)
penup()
goto(30, 80)
pendown()
seth(45)
n = 0
while n != 55:
n += 1
right(1.8)
forward(1)
# 创可贴
pensize(3)
penup()
goto(-65, 95)
pendown()
seth(100)
forward(20)
n = 0
while n != 40:
n += 1
right(0.1)
forward(1)
seth(20)
n = 0
while n != 10:
n += 1
right(0.1)
forward(1)
seth(-80)
n = 0
while n != 60:
n += 1
left(0.05)
forward(1)
penup()
goto(-65, 95)
pendown()
seth(20)
n = 0
while n != 15:
n += 1
right(0.1)
forward(1)
penup()
goto(-90, 95)
pendown()
seth(20)
forward(25)
penup()
forward(15)
pendown()
seth(19)
forward(20)
seth(100)
n = 0
while n != 10:
n += 1
left(0.1)
forward(1)
seth(190)
n = 0
while n != 19:
if n == 7:
penup()
if n == 12:
pendown()
n += 1
left(0.1)
forward(3)
penup()
goto(-90, 125)
pendown()
seth(20)
forward(20)
penup()
forward(14)
pendown()
seth(19)
forward(20)
seth(100)
n = 0
while n != 10:
n += 1
left(0.1)
forward(1)
seth(190)
n = 0
while n != 18:
if n == 7:
penup()
if n == 11:
pendown()
n += 1
left(0.1)
forward(3)
# 伤疤
penup()
goto(45, 25)
pendown()
seth(10)
n = 0
while n != 13:
n += 1
left(0.5)
forward(3)
penup()
goto(55, 20)
pendown()
seth(90)
forward(20)
penup()
goto(75, 20)
pendown()
seth(90)
forward(20)
penup()
goto(-100, -200)
pendown()
done()
领取专属 10元无门槛券
私享最新 技术干货