用python画图代码比卡丘-Python选修课第二届Turtle绘图大赛 (皮卡丘)

(a)

20181004116 徐虎

20181004113 何磊

(b)

import turtle as t

def y(a,b):

t.pu()

t.goto(a,b)

t.pd()

def y1(a,b):

t.pu()

t.goto(t.xcor()+a,t.ycor()+b)

t.pd()

t.setup(width=1920,height=1080)

t.speed(70)

t.pensize(3)

#身体轮廓

y(-200,180)

t.seth(85)

t.circle(-150,50)

t.seth(25)

t.circle(-280,50)

t.seth(40)

t.circle(-390,30)

t.begin_fill()

t.circle(-390,22)

t.seth(227)

t.circle(-420, 15)

t.seth(105)

t.circle(150, 32)

t.end_fill()

y(347.23,302.78)

t.seth(212)

t.circle(-420, 28)

y1(5,-2)

t.seth(280)

t.circle(800, 30)

t.circle(-270, 11)

t.circle(-270, 44)

y(358.29,-177.98)

#尾巴

y1(5,-2)

t.begin_fill()

t.seth(50)

t.fd(40)

t.seth(-50)

t.fd(48)

t.seth(-140)

t.fd(52)

t.end_fill()

t.seth(39)

t.fd(108)

t.seth(125)

t.fd(72)

t.seth(40)

t.fd(79.5)

t.seth(88)

t.fd(67.5)

t.seth(35)

t.fd(157.5)

t.seth(105)

t.circle(1275, 8)

t.seth(215)

t.circle(1275, 11)

t.seth(280)

t.fd(165)

t.seth(220)

t.fd(78)

t.seth(309)

t.fd(84)

#底

y(382.94,-378.76)

y1(5,-2)

t.seth(20)

t.circle(180, -45)

t.seth(330)

t.circle(-225, -30)

t.seth(230)

t.circle(-105, 120)

#两脚

y(382.94,-378.76)

t.seth(-86)

t.fd(45)

t.seth(-93)

t.fd(46.6)

t.seth(-225)

t.circle(-180, 30)

y(-46.30,-311.03)

t.seth(-105)

y1(127.5,-64.5)

t.fd(75)

t.seth(-225)

t.circle(-180, 30)

y(-41.30,-313.03)

t.seth(90)

t.circle(675, 13)

t.circle(675, 5)

t.pu()

t.circle(675, 5)

t.pd()

t.left(8)

t.circle(675, 10)

t.seth(322)

t.circle(115, -78)

t.seth(30)

t.circle(-32, 120)

t.seth(-70)

t.circle(-40, 140)

#左手

y(-58.60,-161.19)

t.seth(160)

t.circle(225, 30)

t.seth(180)

t.circle(-45, 150)

t.fd(99)

y1(-60,-90)

t.seth(200)

t.circle(-7.5, 180)

#右手

y(-58.60,-161.19)

y1(270,7.5)

t.seth(200)

t.circle(-75, 90)

t.pu()

t.circle(-75, 14)

t.pd()

t.circle(-75, 65)

y(180,-100)

t.seth(80)

t.fd(15)

t.seth(165)

t.circle(15, 60)

t.seth(90)

t.fd(7.5)

t.seth(165)

t.circle(15, 60)

t.seth(95)

t.fd(7.5)

t.seth(185)

t.circle(15, 60)

t.seth(105)

t.fd(15)

t.seth(230)

t.fd(30)

t.seth(145)

t.fd(15)

t.seth(285)

t.fd(30)

#脸颊

y1(-60,205)

t.circle(40.5, 360)

#嘴巴

y1(-65,42)

t.seth(280)

t.circle(-195, 30)

t.seth(270)

t.circle(-9, 160)

t.seth(130)

t.circle(-195, 30)

y1(-7.5,7.5)

t.seth(160)

t.circle(-30, -70)

t.seth(160)

t.circle(-45, -60)

y1(0,-42)

t.seth(200)

t.circle(71, 58)

#左眼

y1(-65,185)

t.begin_fill()

t.seth(190)

t.circle(30, 130)

t.seth(310)

t.circle(15, 15)

t.seth(0)

t.circle(33, 133)

t.seth(90)

t.circle(20, 15)

t.end_fill()

y1(3,-22.5)

t.color("white")

t.begin_fill()

t.circle(10.5)

t.end_fill()

#右眼

y1(135,37.5)

t.color("black")

t.begin_fill()

t.seth(190)

t.circle(30, 130)

t.seth(310)

t.circle(15, 15)

t.seth(0)

t.circle(33, 133)

t.seth(90)

t.circle(20, 15)

t.end_fill()

y1(-10.5,-22.5)

t.color("white")

t.begin_fill()

t.circle(10.5)

t.end_fill()

#左耳

t.color("black")

y(-200,180)

y1(22.5,62)

t.seth(90)

t.circle(-375,30)

t.begin_fill()

t.circle(-375,18)

t.seth(270)

t.circle(-405, 12)

t.seth(180)

t.circle(150, 30)

t.end_fill()

y(-62.27,431.48)

t.seth(270)

t.circle(-400, 18)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个简单的Python代码来画一个皮卡丘: ```python import turtle # 设置画笔颜色和填充颜色 turtle.color('black', 'yellow') # 开始画圆形 turtle.begin_fill() turtle.circle(100) turtle.end_fill() # 调整画笔位置和朝向 turtle.penup() turtle.goto(-40, 120) turtle.pendown() turtle.right(90) # 继续填充颜色 turtle.color('black', 'black') turtle.begin_fill() # 画皮卡丘的左耳朵 turtle.forward(60) turtle.left(120) turtle.forward(60) turtle.left(120) turtle.forward(60) # 结束填充颜色 turtle.end_fill() # 调整画笔位置和朝向 turtle.penup() turtle.goto(40, 120) turtle.pendown() turtle.left(180) # 继续填充颜色 turtle.color('black', 'black') turtle.begin_fill() # 画皮卡丘的右耳朵 turtle.forward(60) turtle.right(120) turtle.forward(60) turtle.right(120) turtle.forward(60) # 结束填充颜色 turtle.end_fill() # 调整画笔位置和朝向 turtle.penup() turtle.goto(0, 60) turtle.pendown() # 绘制皮卡丘的眼睛 turtle.dot(30, 'black') turtle.penup() turtle.goto(-20, 70) turtle.pendown() turtle.dot(10, 'white') turtle.penup() turtle.goto(20, 70) turtle.pendown() turtle.dot(10, 'white') # 调整画笔位置和朝向 turtle.penup() turtle.goto(0, 20) turtle.pendown() # 绘制皮卡丘的鼻子 turtle.dot(20, 'black') # 调整画笔位置和朝向 turtle.penup() turtle.goto(-40, 0) turtle.pendown() # 绘制皮卡丘的嘴巴 turtle.right(90) turtle.circle(40, 180) # 隐藏画笔 turtle.hideturtle() # 显示画布 turtle.done() ``` 运行代码后,你将获得一个漂亮的皮卡丘图像!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值