今天教大家绘制哆啦A梦啦!!!
代码如下:
from turtle import *
setup(1000,700)
tracer(0)
ht()
#无轨迹跳跃
def my_goto(x, y):
penup()
goto(x, y)
pendown()
#脸
def 脸():
my_goto(200,0)
pensize(4)
#外圈
fillcolor('deepskyblue')
begin_fill()
for i in range(1000):
lt(360/1000)
fd(1)
end_fill()
#内圈
fillcolor('white')
begin_fill()
for i in range(300):
lt(0.36)
fd(1)
for i in range(170):
lt(0.6)
fd(1)
fd(90)
for i in range(363):
lt(0.36)
fd(0.72)
end_fill()
#嘴巴
my_goto(320,193)
lt(120)
for i in range(110):
rt(2)
fd(1)
for i in range(320):
fd(1)
rt(0.3)
my_goto(270,100)
lt(315)
for i in range(160):
fd(0.8)
lt(0.2)
#隐藏
my_goto(320,193)
pencolor('white')
pensize(20)
fd(20)
pencolor('white')
lt(-37)
my_goto(350,170)
for i in range(45):
lt(360/1000)
fd(1)
pensize(4)
pencolor('black')
#围巾
def 围巾():
my_goto(50,100)
fillcolor('red')
lt(180)
pensize(1)
begin_fill()
for i in range(300):
lt(360/1000)
fd(1)
pensize(4)
lt(190)
for i in range(630):
rt(0.2)
fd(0.5)
end_fill()
#身子
def 身子():
my_goto(45,120)
fillcolor('deepskyblue')
begin_fill()
lt(70)
for i in range(230):
fd(0.8)
lt(0.4)
lt(180)
fd(20)
lt(90)
for i in range(50):
fd(0.6)
lt(0.9)
for i in range(40):
fd(1)
lt(0.5)
for i in range(320):
fd(0.4)
lt(0.5)
rt(70)
for i in range(180):
fd(1)
lt(0.3)
lt(110)
fd(20)
rt(180)
fd(30)
for i in range(120):
fd(1)
lt(1)
lt(20)
for i in range(30):
fd(1)
lt(1)
fd(10)
rt(-56)
pensize(4)
for i in range(400):
rt(0.2)
fd(0.5)
lt(20)
for i in range(60):
rt(0.36)
fd(0.5)
end_fill()
#手
def 手():
my_goto(200,-7)
pencolor('black')
fillcolor('white')
begin_fill()
circle(30)
end_fill()
my_goto(210,-10)
fillcolor('deepskyblue')
begin_fill()
rt(110)
fd(50)
for i in range(90):
fd(1)
lt(1)
lt(130)
for i in range(45):
fd(1)
rt(1)
lt(60)
for i in range(130):
rt(0.2)
fd(0.5)
end_fill()
my_goto(320,20)
lt(190)
for i in range(65):
fd(1)
lt(1.5)
#铃铛
def 铃铛():
my_goto(250,-10)
fillcolor('yellow')
begin_fill()
circle(25)
end_fill()
my_goto(240,-10)
fillcolor('black')
begin_fill()
circle(5)
end_fill()
#脚
def 脚():
my_goto(-80,40)
lt(40)
fd(20)
lt(30)
for i in range(150):
fd(0.8)
lt(0.3)
lt(20)
for i in range(100):
fd(1)
lt(1.5)
#尾巴
def 尾巴():
my_goto(-30,100)
lt(40)
for i in range(100):
fd(0.8)
lt(0.2)
my_goto(-20,180)
fillcolor('red')
begin_fill()
circle(20)
end_fill()
#肚子袋子
def 袋子肚子():
my_goto(90,-80)
fillcolor('white')
begin_fill()
for i in range(140):
fd(1)
lt(1)
lt(83)
for i in range(120):
fd(1)
lt(0.5)
end_fill()
my_goto(70,-80)
lt(90)
for i in range(140):
fd(0.5)
lt(1)
#眼睛
def 眼睛():
#左眼
pensize(4)
my_goto(190,245)
fillcolor('white')
begin_fill()
rt(-20)
tracer(False)
a = 2.5
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#左眼珠
my_goto(185,240)
fillcolor('black')
begin_fill()
tracer(False)
a = 1.7
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#左眼珠瞳孔
my_goto(185,240)
fillcolor('white')
begin_fill()
tracer(False)
a = 1.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#右眼
my_goto(240,280)
fillcolor('white')
begin_fill()
lt(5)
tracer(False)
a = 2.5
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#右眼珠
my_goto(235,270)
fillcolor('black')
begin_fill()
tracer(False)
a = 1.7
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#右眼珠瞳孔
my_goto(235,270)
fillcolor('white')
begin_fill()
tracer(False)
a = 1.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a -= 0.05
lt(3)
fd(a)
else:
a += 0.05
lt(3)
fd(a)
tracer(True)
end_fill()
#鼻子
my_goto(240,230)
fillcolor('red')
begin_fill()
circle(20)
end_fill()
#鼻尖
my_goto(236,228)
pencolor('white')
fillcolor('white')
begin_fill()
circle(8)
end_fill()
#胡须
def 胡须():
pensize(2)
my_goto(90,200)
lt(90)
fd(100)
my_goto(90,150)
lt(10)
fd(100)
my_goto(100,70)
lt(20)
fd(100)
my_goto(320,160)
rt(10)
fd(100)
my_goto(330,190)
rt(-10)
fd(100)
my_goto(290,200)
lt(10)
fd(100)
my_goto(500,900)
lt(90)
fd(100)
circle(0.5)
脸()
围巾()
身子()
手()
铃铛()
脚()
尾巴()
袋子肚子()
胡须()
眼睛()
done()
小编要提醒大家不要乱改代码哟!
最后记得给小编点赞哟!