python turtle画多啦a梦_python 海龟绘图画哆啦A梦

这篇博客通过Python的turtle模块详细展示了如何绘制哆啦A梦,包括头部、眼睛、胡须、手、脚、身体、口袋和铃铛等各个部分的绘制步骤,适合初学者了解turtle库和图形编程。
摘要由CSDN通过智能技术生成

import turtle as t

#定位

def my_goto(x,y):

t.up()

t.goto(x,y)

t.down()

#眼睛

def eyes():

t.tracer(False)

a = 2.5

for i in range(120):

if 0

a -= 0.05

t.lt(3)

t.fd(a)

else:

a += 0.05

t.lt(3)

t.fd(a)

t.tracer(True)

#胡须

def beard(x,y,s,f):

my_goto(x, y)

t.seth(s)

t.fd(f)

#画手

def hand(s,color,c):

t.seth(s)

t.fillcolor(color)

t.begin_fill()

t.circle(c)

t.end_fill()

#画脚

def foot(x,y,s,color,f1,c1,c2,f2,c3,c4,f4):

my_goto(x, y)

t.seth(s)

t.fillcolor(color)

t.begin_fill()

t.fd(f1)

t.circle(c1, c2)

t.fd(f2)

t.circle(c3, c4)

t.fd(f4)

t.end_fill()

#头

t.pensize(3)

t.up()

t.circle(150,40)

t.down()

t.fillcolor("#007fff")

t.begin_fill()

t.circle(150,280)

t.end_fill()

#围巾

t.fillcolor("#ff7f00")

t.begin_fill()

t.seth(0)#绝对角度

t.fd(200)#前进200

t.circle(-5,90)

t.fd(10)

t.circle(-5,90)

t.fd(207)

t.circle(-5,90)

t.fd(10)

t.circle(-5,90)

t.end_fill()

#脸

t.fd(183)

t.fillcolor('#ffffff')

t.begin_fill()

t.lt(45)

t.circle(120, 100)

t.seth(90)

eyes()

t.seth(180)

t.up()

t.fd(60)

t.down()

t.seth(90)

eyes()

t.up()

t.seth(180)

t.fd(64)

t.down()

t.seth(215)

t.circle(120, 100)

t.end_fill()

#鼻子

my_goto(-10,158)

t.fillcolor("#ffcc00")

t.begin_fill()

t.circle(20)

t.end_fill()

#嘴巴

my_goto(5,148)

t.seth(270)

t.fd(100)

t.seth(0)

t.circle(120,50)

t.seth(230)

t.circle(-120,100)

# 画胡须

beard(-37,135,165,60)

beard(-37,125,180,60)

beard(-37,115,193,60)

beard(37,135,15,60)

beard(37,125,0,60)

beard(37,115,-13,60)

#画身体

my_goto(0, 0)

t.seth(0)

t.up()

t.circle(150, 50)

t.down()

t.seth(30)

t.fd(40)

t.seth(70)

t.circle(-30, 270)

t.fillcolor('#00a0de')

t.begin_fill()

t.seth(230)

t.fd(80)

t.seth(90)

t.circle(1000, 1)

t.seth(-89)

t.circle(-1000, 10)

t.seth(180)

t.fd(70)

t.seth(90)

t.circle(30, 180)

t.seth(180)

t.fd(70)

t.seth(100)

t.circle(-1000, 9)

t.seth(-86)

t.circle(1000, 2)

t.seth(230)

t.fd(40)

t.circle(-30, 230)

t.seth(45)

t.fd(81)

t.seth(0)

t.fd(203)

t.circle(5, 90)

t.fd(10)

t.circle(5, 90)

t.fd(7)

t.seth(40)

t.circle(150, 10)

t.seth(30)

t.fd(40)

t.end_fill()

# 左手

hand(70,'#ffffff',-30)

# 右手

my_goto(-133.97, -91.81)

hand(50,'#ffffff',30)

# 脚

foot(103.74,-182.59,0,'#ffffff',15,-15,180,90,-15,180,10)

foot(-96.26,-182.59,180,'#ffffff',15,15,180,90,15,180,10)

# 口袋

my_goto(-103.42, 15.09)

t.seth(0)

t.fd(38)

t.seth(230)

t.begin_fill()

t.circle(90, 260)

t.end_fill()

my_goto(5, -40)

t.seth(0)

t.fd(70)

t.seth(-90)

t.circle(-70, 180)

t.seth(0)

t.fd(70)

#铃铛

my_goto(-103.42, 15.09)

t.fd(90)

t.seth(70)

t.fillcolor('#ffd200')

t.begin_fill()

t.circle(-20)

t.end_fill()

t.seth(170)

t.fillcolor('#ffd200')

t.begin_fill()

t.circle(-2, 180)

t.seth(10)

t.circle(-100, 22)

t.circle(-2, 180)

t.seth(180-10)

t.circle(100, 22)

t.end_fill()

t.goto(-13.42, 15.09)

t.seth(250)

t.circle(20, 110)

t.seth(90)

t.fd(15)

t.dot(10)#dot绘制一个指定直径和颜色的圆点.

my_goto(0, -150)

# 眼睛

t.seth(0)

my_goto(-20, 195)

t.fillcolor('#000000')

t.begin_fill()

t.circle(13)

t.end_fill()

t.pensize(6)

my_goto(20, 205)

t.seth(75)

t.circle(-10, 150)

t.pensize(3)

my_goto(-17, 200)

t.seth(0)

t.fillcolor('#ffffff')

t.begin_fill()

t.circle(5)

t.end_fill()

my_goto(0, 0)

t.exitonclick()#不关闭窗体

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值