画一个史迪仔
from turtle import * #画一个史迪仔
setup(650,650)
penup()
pensize(5)
speed(10)
pencolor("#065693")
seth(180)
fd(140)
seth(-90)
fd(50)
pendown() #起点
fillcolor("#0079C6")
begin_fill()
seth(170)
circle(-40,100)
seth(180)
fd(50)
seth(180)
circle(-10,46)
seth(130)
circle(-300,40)#耳朵外廓大圆
circle(-100,45)
right(10)
circle(-50,30)
right(10)
circle(-30,30)
left(1)
fd(2)
right(1)
fd(3)
right(4)
fd(3)
right(3)
fd(5)
right(4)
fd(6)
right(4)
fd(10)
right(4)
fd(10)
right(3)
fd(15)
right(2)
fd(20)
right(2)
fd(20)
right(4)
fd(20)
right(3)
fd(30)
right(1)
fd(40)
right(1)
fd(60)
seth(-115)
fd(5) #脸左侧开始逆时针
circle(200,30)
end_fill()
begin_fill()
left(8)
fd(20)
left(10)
fd(20)
left(14)
circle(100,30)
left(10)
circle(150,20)
right(2)
fd(55)
left(5)
fd(40)
left(3)
fd(25)
right(3)
circle(150,20)
left(7)
circle(100,30)
fd(5)#右侧耳朵下部开始
left(3)
circle(80,30)
right(3)
circle(80,30)
right(9)
circle(100,30)
left(2)
circle(200,20)
left(3)
fd(20)
seth(108)#小毛尖儿1
circle(30,5)
right(3)
circle(200,3)
left(7)
circle(20,5)
circle(15,10)
left(5)
circle(15,20)
left(11)
circle(15,20)
left(10)
circle(15,20)
left(9)
circle(13,15)
left(10)
circle(13,15)
left(8)
circle(20,15)
seth(135) #小毛尖2
fd(20)
circle(8,168)
right(180) #小毛尖3
circle(7,170)
seth(-176) #顶部结尾
fd(3)
circle(100,10)
right(5)
circle(70,15)
fd(3)
right(5)
circle(100,10)
right(4)
circle(80,10)
left(5)
circle(100,5)
right(6)
circle(100,5)
left(1)
circle(50,10)
right(10)
fd(9)
seth(-115)
fd(5)
circle(200,30)
end_fill() #脸廓结束
penup() #眼睛左开始
seth(0)
fd(15)
seth(-60)
pendown()
fillcolor("#69C4EF")
begin_fill()
circle(50,20)
left(4)
circle(55,20)
right(4)
circle(50,20)
right(4)
circle(50,20)
left(13)
circle(50,20)
left(15)
circle(50,30)
right(10)
circle(80,20)
right(10)
circle(80,20)
right(7)
circle(80,20)
left(10)
circle(80,15)
left(17)
circle(80,15)
left(30)
circle(80,15)
left(10)
circle(80,15)
circle(80,15)
right(8)
circle(80,15)
right(7)
circle(80,15)
right(7)
circle(80,6)
end_fill()
penup() #左眼内部(黑)开始
seth(0)
fd(34)
seth(90)
fd(10)
seth(-60)
pendown()
fillcolor("black")
begin_fill()
pencolor("black")
pensize(1)
circle(80,7)
left(20)
circle(80,9)
left(25)
circle(80,9)
left(30)
circle(80,9)
left(35)
circle(80,9)
left(10)
circle(80,3)
right(15)
fd(13)
left(15)
circle(80,10)
left(20)
circle(80,15)
left(25)
circle(80,10)
left(30)
circle(80,9)
left(35)
circle(80,15)
left(10)
circle(80,9)
circle(80,15)
end_fill() #左眼内部(黑)结束
penup() #左眼内部(白)开始
seth(90)
fd(47)
seth(0)
fd(12)
pendown()
fillcolor("white")
begin_fill()
circle(-10,360)
end_fill() #左眼整体结束
penup() #右眼开始
seth(0)
fd(237)
seth(-90)
pensize(5)
pencolor("#065693")
fillcolor("#69C4EF")
begin_fill()
pendown()
right(10)
circle(80,11)
right(30)
circle(80,11)
right(35)
circle(80,15)
right(35)
circle(80,12)
right(20)
circle(80,9)
right(37)
circle(80,9)
right(40)
circle(80,9)
right(38)
circle(80,9)
right(15)
circle(80,9)
fd(7)
right(11)
circle(80,9)
right(11)
circle(80,9)
right(12)
circle(80,9)
right(14)
circle(80,9)
right(16)
circle(80,5)
right(16)
circle(80,5)
right(18)
circle(80,5)
right(23)
circle(80,5)
right(25)
circle(80,5)
right(28)
circle(80,5)
right(5)
circle(80,5)
right(12)
circle(80,5)
right(15)
circle(80,5)
right(17)
circle(80,5)
right(15)
circle(80,5)
right(13)
circle(80,5)
right(13)
circle(80,9)
right(11)
circle(80,9)
right(11)
circle(80,5)
right(10)
circle(80,5)
right(10)
circle(80,9)
end_fill() #右眼外框结束
penup() #右眼内部开始
seth(180)
fd(70)
seth(87)
pensize(1)
pencolor("black")
fillcolor("black")
begin_fill()
pendown()
circle(80,8)
right(15)
circle(80,7)
right(18)
circle(80,5)
right(23)
circle(80,5)
right(23)
circle(80,5)
right(23)
circle(80,5)
right(28)
circle(80,5)
right(35)
circle(80,5)
right(35)
circle(80,6)
right(37)
circle(80,6)
fd(5)
left(5)
circle(80,5)
right(3)
fd(5)
right(10)
circle(80,5)
right(15)
circle(80,5)
right(18)
circle(80,5)
right(25)
circle(80,5)
right(37)
circle(80,5)
right(38)
circle(80,7)
right(42)
circle(80,9)
right(38)
circle(80,9)
right(40)
fd(5)
end_fill()
penup() #右眼内部(白)开始
seth(0)
fd(22)
seth(90)
fd(10)
pendown()
pensize(1)
pencolor("white")
fillcolor("white")
begin_fill()
circle(10,360)
end_fill()#右眼内部(白)结束
penup() #鼻子外开始
seth(180)
fd(167)
seth(-90)
fd(60)
pencolor("#07548C")
seth(0)
pendown()
fillcolor("#07548C")
begin_fill()
left(83)
circle(-80,30)
right(15)
circle(-80,30)
fd(5)
left(2)
circle(-80,15)
circle(-80,10)
circle(-80,20)
left(2)
circle(-80,9)
right(20)
circle(-80,20)
right(25)
circle(-80,20)
right(10)
circle(-80,15)
right(8)
circle(-80,12)
seth(-175)
fd(9)
left(2)
fd(6)
left(2)
fd(8)
right(3)
circle(-80,10)
right(3)
circle(-80,12)
circle(-80,10)
right(3)
circle(-80,10)
right(7)
circle(-80,10)
right(6)
circle(-80,8)
right(6)
circle(-80,8)
right(7)
circle(-80,7)
end_fill()#鼻子外结束
penup()#鼻子内开始
seth(8)
fd(20)
seth(-90)
fd(45)
pensize(1)
pencolor("#0A3873")
pendown()
fillcolor("#0A3873")
begin_fill()
seth(-30)
fd(20)
seth(110)
fd(20)
left(70)
circle(10,100)
end_fill()
penup()
seth(3)
fd(87)
seth(-90)
fd(5)
seth(47)
begin_fill()
pendown()
fd(20)
seth(227)
fd(20)
right(150)
fd(20)
right(70)
circle(-10,100)
end_fill()#鼻子结束
penup()#右耳朵开始
seth(0)
fd(95)
seth(90)
fd(45)
pendown()
fillcolor("#0079C6")
begin_fill()
pensize(5)
pencolor("#065693")
seth(20)
circle(40,95)
right(100)
fd(50)
circle(10,46)
seth(45)
circle(300,40)
circle(100,45)
left(10)
circle(50,30)
left(10)
circle(30,30)
right(1)
fd(2)
left(1)
fd(3)
left(4)
fd(3)
left(3)
fd(5)
left(4)
fd(6)
left(4)
fd(10)
left(4)
fd(10)
left(3)
fd(15)
left(2)
fd(20)
left(2)
fd(20)
left(4)
fd(20)
left(3)
fd(30)
left(1)
fd(40)
left(1)
fd(60)
left(3)
fd(51)
left(70)
pensize(1)
fd(8)
right(3)
fd(8)
right(3)
fd(8)
right(3)
fd(5)
right(3)
fd(5)
right(2)
fd(5)
right(2)
fd(5)
right(3)
fd(9)
right(3)
fd(10)
right(3)
fd(9)
right(5)
fd(9)
right(6)
fd(6)
right(6)
fd(6)
right(7)
fd(6)
right(7)
fd(6)
end_fill()#右耳朵外廓完成
penup()#右耳内廓开始
seth(0)
fd(6)
seth(90)
fd(20)
seth(45)
pendown()
pensize(1)
pencolor("#F7CEDC")
fillcolor("#F7CEDC")
begin_fill()
circle(40,75)
right(106)
fd(53)
circle(10,40)
seth(47)
circle(310,40)
left(10)
circle(80,45)
left(25)
circle(40,30)
left(23)
circle(30,20)
seth(-145)
right(1)
fd(2)
left(1)
fd(3)
left(4)
fd(3)
left(3)
fd(5)
left(4)
fd(6)
left(4)
fd(10)
left(4)
fd(10)
left(3)
fd(15)
left(2)
fd(20)
left(2)
fd(20)
left(3)
fd(20)
left(2)
fd(30)
left(2)
fd(30)
left(2)
fd(40)
left(3)
fd(30)
left(1)
fd(7)
left(2)
fd(7)
left(12)
fd(2)
left(8)
fd(20)
left(10)
fd(10)
left(15)
fd(10)
right(2)
fd(20)
right(10)
fd(15)
right(8)
fd(10)
end_fill()#右耳内廓结束
penup()
seth(180)
fd(327)
seth(-90)
fd(34)
pendown()
begin_fill()
seth(140)
circle(-40,75)
left(113)
fd(53)
circle(-7,40)
seth(130)
circle(-310,40)
right(17)
circle(-80,45)
right(20)
circle(-40,30)
right(23)
circle(30,20)
seth(-47)
left(3)
fd(2)
right(2)
fd(3)
right(2)
fd(3)
right(3)
fd(5)
right(4)
fd(6)
right(4)
fd(10)
right(4)
fd(10)
right(3)
fd(15)
right(1)
fd(20)
right(1)
fd(20)
right(1)
fd(30)
right(1)
fd(40)
right(1)
fd(40)
right(11)
fd(2)
right(15)
left(20)
right(10)
fd(20)
right(15)
fd(10)
left(5)
fd(20)
right(5)
fd(20)
left(10)
fd(20)
left(3)
fd(20)
end_fill()#脸部结束
penup()#身体开始
seth(0)
fd(70)
seth(-90)
fd(80)
pensize(5)
pencolor("#065693")
fillcolor("#0079C6")
begin_fill()
seth(-112)
pendown()
circle(220,22)
right(86)
circle(70,40)
right(90)
fd(8)
right(33)
circle(10,160)
right(9)
fd(8)
right(50)
fd(9)
right(28)
fd(6)
circle(8,160)
left(5)
fd(6)
right(85)
fd(9)
right(28)
fd(6)
circle(6,110)
fd(4)
right(23)
fd(5)
left(2)
circle(80,10)
left(2)
circle(80,5)
left(4)
circle(80,10)
left(7)
circle(80,10)
left(7)
circle(80,10)
right(2)
fd(5)
right(1)
circle(80,10)
left(4)
circle(80,10)
right(10)
circle(-80,10)
right(8)
circle(-80,10)
right(11)
circle(-80,10)
right(90)
fd(5)
right(5)
circle(10,180)
fd(2)
right(130)
fd(5)
left(5)
circle(10,130)
fd(5)
right(80)
fd(5)
circle(10,180)
seth(0)
fd(65)
right(180)
circle(10,190)
fd(5)
right(90)
fd(5)
circle(10,150)
left(10)
fd(5)
right(90)
fd(2)
circle(10,180)
right(20)
fd(3)
right(125)
circle(-80,10)
right(11)
circle(-80,10)
right(8)
circle(-80,10)
right(10)
circle(80,10)
left(4)
circle(80,10)
right(1)
fd(5)
right(2)
circle(80,10)
left(7)
circle(80,10)
left(7)
circle(80,10)
left(4)
circle(80,5)
left(2)
circle(80,10)
left(2)
fd(5)
right(23)
fd(4)
circle(6,110)
fd(6)
right(28)
fd(9)
right(85)
fd(6)
left(5)
circle(8,160)
fd(6)
right(28)
fd(9)
right(50)
fd(8)
right(9)
circle(10,160)
right(33)
fd(8)
right(90)
circle(70,40)
right(92)
circle(210,22)
fd(16)#身体外廓结束
left(90)
circle(-80,5)
right(1)
circle(-80,5)
right(1)
circle(80,5)
right(1)
circle(80,5)
right(2)
fd(5)
right(1)
fd(5)
right(1)
fd(5)
right(3)
fd(5)
right(2)
fd(5)
right(3)
fd(7)
right(2)
fd(7)
right(2)
fd(7)
left(2)
fd(5)
left(2)
fd(7)
right(3)
fd(7)
left(2)
fd(7)
right(2)
fd(7)
left(2)
fd(7)
right(2)
fd(7)
left(2)
fd(7)
right(2)
fd(7)
left(2)
fd(7)
right(2)
fd(7)
left(2)
fd(7)
right(5)
fd(7)
left(2)
fd(7)
right(7)
fd(7)
left(2)
fd(7)
right(8)
fd(6)
end_fill()#身体外廓结束
penup()#身体内部开始
seth(0)
fd(48)
right(65)
pendown()
fillcolor("#69C4EF")
begin_fill()
circle(-300,24)
circle(10,90)
seth(0)
fd(50)
circle(10,90)
left(9)
circle(-300,26)
fd(3)
seth(-167)
fd(5)
right(1)
fd(7)
left(1)
fd(7)
right(2)
fd(7)
left(1)
fd(7)
right(3)
fd(7)
left(2)
fd(7)
right(3)
fd(7)
right(3)
fd(7)
left(2)
fd(7)
right(4)
fd(7)
left(2)
fd(7)
right(3)
fd(7)
left(2)
fd(7)
right(2)
fd(7)
left(3)
fd(7)
left(3)
fd(5)
end_fill()#身体外廓中间结束
penup()
seth(-90)
fd(154)
seth(0)
fd(4)
pensize(1)
fillcolor("#065693")
pencolor("#065693")
pendown()
begin_fill()
seth(-155)
fd(8)
right(120)
fd(8)
right(90)
circle(-10,50)
end_fill()
penup()
seth(0)
fd(16)
seth(-120)
pendown()
fd(8)
begin_fill()
right(113)
fd(8)
right(90)
circle(-10,57)
end_fill()
penup()
seth(0)
fd(10)
seth(90)
fd(10)
pendown()
begin_fill()
seth(-45)
fd(8)
right(120)
fd(8)
right(90)
circle(-10,57)
end_fill()
penup()
seth(0)
fd(72)
seth(-90)
fd(2)
seth(-115)
pendown()#
begin_fill()
fd(8)
left(90)
circle(10,57)
end_fill()
penup()
seth(0)
fd(4)
seth(-90)
fd(6)
seth(-70)
pendown()
begin_fill()
fd(8)
left(90)
circle(10,57)
end_fill()
penup()
seth(0)
fd(4)
seth(90)
fd(5)
seth(0)
pendown()
begin_fill()
fd(8)
left(90)
circle(10,57)
end_fill()#手结束
penup()#左脚掌开始
seth(180)
fd(237)
seth(-90)
fd(10)
seth(180)
pendown()
fillcolor("#065693")
begin_fill()
circle(-17,360)
end_fill()#左脚掌结束
seth(180)#左脚丫开始
penup()
fd(20)
seth(90)
fd(7)
seth(180)
right(15)
pendown()
begin_fill()
fd(9)
right(120)
fd(9)
right(120)
fd(9)
end_fill()
penup()
seth(90)
fd(20)
seth(180)
right(53)
pendown()
begin_fill()
fd(9)
right(120)
fd(9)
right(120)
fd(9)
end_fill()
penup()
seth(0)
fd(10)
seth(90)
fd(10)
right(20)
pendown()
begin_fill()
fd(9)
right(120)
fd(9)
right(120)
fd(9)
end_fill()#左脚丫结束
penup()#右脚掌开始
seth(0)
fd(345)
seth(-90)
fd(12)
seth(0)
pendown()
begin_fill()
circle(17,360)
end_fill()#右脚掌结束
penup()#右脚丫开始
fd(23)
seth(90)
fd(4)
seth(0)
left(90)
pendown()
begin_fill()
fd(9)
right(120)
fd(9)
right(120)
fd(9)
end_fill()
penup()
seth(90)
fd(25)
seth(0)
left(127)
pendown()
begin_fill()
fd(9)
right(120)
fd(9)
right(120)
fd(9)
end_fill()
penup()
seth(180)
fd(27)
seth(90)
fd(12)
seth(0)
pendown()
begin_fill()
left(4)
fd(9)
left(120)
fd(9)
left(120)
fd(9)
end_fill()
penup()#右脚丫结束
fd(200)
done()
画玫瑰花
import turtle #画玫瑰花
# 设置初始位置
turtle.penup() # 提起画笔
turtle.left(90) # 逆时针旋转九十度
turtle.fd(200) # 向前移动一段距离 fd=forward
turtle.pendown() # 放下画笔移动画笔开始绘制
turtle.right(90) # 顺时针旋转九十度
# 花蕊
turtle.fillcolor("red") # 填充颜色
turtle.begin_fill() # 开始填充
turtle.circle(10, 180) # 画一圆,10是半径,180是弧度
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill() # 结束填充
# 花瓣1
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60) # urtle.setheading(angle) 或 turtle.seth(angle):改变行进方向 angle:行进方向的绝对角度,可以为负值
turtle.circle(80, 98)
turtle.circle(-90, 40)
# 花瓣2
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
# 叶子1
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
# 叶子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
# 设置成画完不会自动退出
turtle.done()
画皮卡丘
import turtle as t
import time
# 皮卡丘
# 基础设置
t.screensize(800, 600)
t.pensize(2) # 设置画笔的大小
t.speed(10) # 设置画笔速度为10
# 画左偏曲线函数
def radian_left(ang, dis, step, n):
for i in range(n):
dis += step # dis增大step
t.lt(ang) # 向左转ang度
t.fd(dis) # 向前走dis的步长
def radian_right(ang, dis, step, n):
for i in range(n):
dis += step
t.rt(ang) # 向左转ang度
t.fd(dis) # 向前走dis的步长
# 画耳朵
def InitEars():
t.color("black", "yellow")
# 左耳朵曲线
t.pu() # 提笔
t.goto(-50, 100) # 笔头初始位置
t.pd() # 下笔
t.setheading(110) # 画笔角度
t.begin_fill()
radian_left(1.2, 0.4, 0.1, 40)
t.setheading(270) # 画笔角度
radian_left(1.2, 0.4, 0.1, 40)
t.setheading(44) # 画笔角度
t.forward(32)
t.end_fill()
# 右耳朵曲线
t.pu() # 提笔
t.goto(50, 100) # 笔头初始位置
t.pd() # 下笔
t.setheading(70) # 画笔角度
t.begin_fill()
radian_right(1.2, 0.4, 0.1, 40)
t.setheading(270) # 画笔角度
radian_right(1.2, 0.4, 0.1, 40)
t.setheading(136) # 画笔角度
t.forward(32)
t.end_fill()
# 耳朵黑
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(88, 141) # 笔头初始位置
t.pd() # 下笔
t.setheading(35) # 画笔角度
radian_right(1.2, 1.6, 0.1, 16)
t.setheading(270) # 画笔角度
radian_right(1.2, 0.4, 0.1, 25)
t.setheading(132) # 画笔角度
t.forward(31)
t.end_fill()
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(-88, 141) # 笔头初始位置
t.pd() # 下笔
t.setheading(145) # 画笔角度
radian_left(1.2, 1.6, 0.1, 16)
t.setheading(270) # 画笔角度
radian_left(1.2, 0.4, 0.1, 25)
t.setheading(48) # 画笔角度
t.forward(31)
t.end_fill()
# 画尾巴
def InitTail():
# 尾巴
t.begin_fill()
t.fillcolor("yellow")
t.pu() # 提笔
t.goto(64, -140) # 笔头初始位置
t.pd() # 下笔
t.setheading(10) # 画笔角度
t.forward(20)
t.setheading(90) # 画笔角度
t.forward(20)
t.setheading(10) # 画笔角度
t.forward(10)
t.setheading(80) # 画笔角度
t.forward(100)
t.setheading(35) # 画笔角度
t.forward(80)
t.setheading(260) # 画笔角度
t.forward(100)
t.setheading(205) # 画笔角度
t.forward(40)
t.setheading(260) # 画笔角度
t.forward(37)
t.setheading(205) # 画笔角度
t.forward(20)
t.setheading(260) # 画笔角度
t.forward(25)
t.setheading(175) # 画笔角度
t.forward(30)
t.setheading(100) # 画笔角度
t.forward(13)
t.end_fill()
# 画脚
def InitFoots():
# 脚
t.begin_fill()
t.fillcolor("yellow")
t.pensize(2)
t.pu() # 提笔
t.goto(-70, -200) # 笔头初始位置
t.pd() # 下笔
t.setheading(225) # 画笔角度
radian_left(0.5, 1.2, 0, 12)
radian_left(35, 0.6, 0, 4)
radian_left(1, 1.2, 0, 18)
t.setheading(160) # 画笔角度
t.forward(13)
t.end_fill()
t.begin_fill()
t.fillcolor("yellow")
t.pensize(2)
t.pu() # 提笔
t.goto(70, -200) # 笔头初始位置
t.pd() # 下笔
t.setheading(315) # 画笔角度
radian_right(0.5, 1.2, 0, 12)
radian_right(35, 0.6, 0, 4)
radian_right(1, 1.2, 0, 18)
t.setheading(20) # 画笔角度
t.forward(13)
t.end_fill()
# 画身体
def InitBody():
# 外形轮廓
t.begin_fill()
t.pu() # 提笔
t.goto(112, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(112, 180)
t.setheading(250) # 画笔角度
radian_left(1.6, 1.3, 0, 50)
radian_left(0.8, 1.5, 0, 25)
t.setheading(255) # 画笔角度
radian_left(0.4, 1.6, 0.2, 27)
radian_left(2.8, 1, 0, 45)
radian_right(0.9, 1.4, 0, 31)
t.setheading(355) # 画笔角度
radian_right(0.9, 1.4, 0, 31)
radian_left(2.8, 1, 0, 45)
radian_left(0.4, 7.2, -0.2, 27)
t.setheading(10) # 画笔角度
radian_left(0.8, 1.5, 0, 25)
radian_left(1.6, 1.3, 0, 50)
t.end_fill()
def InitEyes():
# 左眼睛
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(-46, 10) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(5, 360)
t.end_fill()
# 右眼睛
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(46, 10) # 笔头初始位置
t.pd() # 下笔
t.setheading(-90) # 画笔角度
t.circle(5, 360)
t.end_fill()
# 画脸
def InitFace():
# 脸蛋
t.begin_fill()
t.fillcolor("red")
t.pu() # 提笔
t.goto(-63, -10) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(10, 360)
t.end_fill()
t.begin_fill()
t.fillcolor("red")
t.pu() # 提笔
t.goto(63, -10) # 笔头初始位置
t.pd() # 下笔
t.setheading(-90) # 画笔角度
t.circle(10, 360)
t.end_fill()
# 嘴巴
t.pensize(2.2)
t.pu() # 提笔
t.goto(0, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(235) # 画笔角度
radian_right(5, 0.8, 0, 30)
t.pu() # 提笔
t.goto(0, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(305) # 画笔角度
radian_left(5, 0.8, 0, 30)
# 画手
def InitHands():
# 左手
t.pensize(2)
t.pu() # 提笔
t.goto(-46, -100) # 笔头初始位置
t.pd() # 下笔
t.setheading(285) # 画笔角度
radian_right(0.4, 1.2, 0, 26)
radian_right(5, 0.35, 0, 26)
radian_right(0.3, 1.2, 0, 15)
# 右手
t.pu() # 提笔
t.goto(46, -100) # 笔头初始位置
t.pd() # 下笔
t.setheading(255) # 画笔角度
radian_left(0.4, 1.2, 0, 26)
radian_left(5, 0.35, 0, 26)
radian_left(0.3, 1.2, 0, 15)
def CloseEyes():
# 左眼睛
t.pu() # 提笔
t.goto(-46, 12) # 笔头初始位置
t.pd() # 下笔
t.setheading(180) # 画笔角度
t.forward(10)
# 右眼睛
t.pu() # 提笔
t.goto(46, 12) # 笔头初始位置
t.pd() # 下笔
t.setheading(0) # 画笔角度
t.forward(10)
# 初始化
def Init():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
InitEyes()
# 眨眼睛
def Upgarde():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
CloseEyes()
def Upgarde_Init():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
InitEyes()
def main():
Init()
t.tracer(False)
# 眨眼睛动画
for i in range(30):
if i % 2 == 0:
t.reset()
t.hideturtle()
Upgarde()
t.update()
time.sleep(0.3)
else:
t.reset()
t.hideturtle()
Upgarde_Init()
t.update()
time.sleep(1)
main()
# 结束画笔
t.done()
画low版星空
from turtle import * #画星空
from random import random,randint
screen = Screen()
width ,height = 800,600
screen.setup(width,height)
screen.bgcolor("black")
screen.mode("logo")
screen.delay(0)#这里要设为0,否则很卡
t = Turtle(visible = False,shape='circle')
t.pencolor("white")
t.fillcolor("white")
t.penup()
t.setheading(-90)
t.goto(width/2,randint(-height/2,height/2))
stars = []
for i in range(200):
star = t.clone()
s =random() /3
star.shapesize(s,s)
star.speed(int(s*10))
star.setx(width/2 + randint(1,width))
star.sety( randint(-height/2,height/2))
star.showturtle()
stars.append(star)
while True:
for star in stars:
star.setx(star.xcor() - 3 * star.speed())
if star.xcor()<-width/2:
star.hideturtle()
star.setx(width/2 + randint(1,width))
star.sety( randint(-height/2,height/2))
star.showturtle()