Python—— 使用turtle库画皮卡丘

Python 画皮卡丘

import turtle

# 画鼻子

def drawNose():
    turtle.penup()
    turtle.seth(90)
    turtle.fd(100)
    turtle.pendown()
    turtle.begin_fill()
    turtle.fillcolor('black')
    turtle.seth(45)
    turtle.fd(25)
    turtle.seth(135)
    turtle.circle(25, 95)
    turtle.seth(315)
    turtle.fd(25)
    turtle.end_fill()

# 画眼睛

def drawEyes(seth, fd, r):
    turtle.penup()
    turtle.seth(seth)
    turtle.fd(fd)
    turtle.pendown
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,我可以为您展示如何使用PythonTurtle库来画皮卡丘。 下面是绘制皮卡丘Python代码: ```python import turtle # 创建一个新窗口 win = turtle.Screen() win.bgcolor("white") # 画布的大小 win.setup(width=600, height=600) # 将画笔移到屏幕中央,准备画脸 face = turtle.Turtle() face.color("black") face.fillcolor("yellow") face.penup() face.goto(0, -100) face.pendown() face.begin_fill() face.circle(200) face.end_fill() # 画左耳 left_ear = turtle.Turtle() left_ear.color("black") left_ear.fillcolor("black") left_ear.penup() left_ear.goto(-150, 180) left_ear.pendown() left_ear.begin_fill() left_ear.right(135) left_ear.circle(100, -90) left_ear.left(90) left_ear.circle(100, -45) left_ear.end_fill() # 画右耳 right_ear = turtle.Turtle() right_ear.color("black") right_ear.fillcolor("black") right_ear.penup() right_ear.goto(150, 180) right_ear.pendown() right_ear.begin_fill() right_ear.left(135) right_ear.circle(-100, -90) right_ear.right(90) right_ear.circle(-100, -45) right_ear.end_fill() # 画左眼 left_eye = turtle.Turtle() left_eye.color("black") left_eye.fillcolor("white") left_eye.penup() left_eye.goto(-80, 50) left_eye.pendown() left_eye.begin_fill() left_eye.circle(40) left_eye.end_fill() # 画右眼 right_eye = turtle.Turtle() right_eye.color("black") right_eye.fillcolor("white") right_eye.penup() right_eye.goto(80, 50) right_eye.pendown() right_eye.begin_fill() right_eye.circle(40) right_eye.end_fill() # 左眼珠 left_pupil = turtle.Turtle() left_pupil.color("black") left_pupil.fillcolor("black") left_pupil.penup() left_pupil.goto(-80, 20) left_pupil.pendown() left_pupil.begin_fill() left_pupil.circle(20) left_pupil.end_fill() # 画右眼珠 right_pupil = turtle.Turtle() right_pupil.color("black") right_pupil.fillcolor("black") right_pupil.penup() right_pupil.goto(80, 20) right_pupil.pendown() right_pupil.begin_fill() right_pupil.circle(20) right_pupil.end_fill() # 画鼻子 nose = turtle.Turtle() nose.color("black") nose.fillcolor("black") nose.penup() nose.goto(0, 60) nose.pendown() nose.begin_fill() nose.circle(30) nose.end_fill() # 画嘴巴 mouth = turtle.Turtle() mouth.color("black") mouth.penup() mouth.goto(-100, -40) mouth.pendown() mouth.right(90) mouth.circle(100, 180) # 使窗口保持打开状态 turtle.done() ``` 运行上述代码后,您可以在Turtle窗口中看到绘制的皮卡丘

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值