python的皮卡丘如何写代码,python画皮卡丘的代码

这篇文章主要介绍了怎么用python画一个皮卡丘,具有一定借鉴价值,需要的朋友可以参考下。希望大家阅读完这篇文章后大有收获,下面让小编带着大家一起了解一下。

给大家看看我的皮卡丘(电脑屏幕比较小,所以看不见假皮卡丘真实的身体):

话不说上代码:

import turtle as t
import random
t.speed(100)
t.pensize(3)
t.color('black')
t.pu()

#头
t.fillcolor('yellow')
t.setposition(-500,300)
t.begin_fill()
t.pd()      
t.left(120)
t.circle(600,-20)
t.pu()
t.left(150)
t.setposition(-500,300)
t.pd()
t.circle(600,25)
t.right(30)
t.circle(150,60)
t.left(15)
t.circle(200,30)
t.left(2)
t.circle(200,50)
t.left(15)
t.circle(150,60)
t.right(90)
t.circle(600,20)
t.left(140)
t.circle(600,25)
t.right(60)
t.circle(150,37)
t.end_fill()
t.pu()

#耳朵涂色

t.setposition(-88,173)
t.fillcolor('black')
t.begin_fill()
t.setposition(-160,162)
t.pd()
t.right(-60)
t.circle(60,50)
t.end_fill()

t.pu()
t.setposition(-500,300)
t.fillcolor('black')
t.begin_fill()
t.pd()
t.setposition(-460,215)
t.right(-90)
t.circle(60,-65)
t.end_fill()
t.pu()

#眼睛
t.fillcolor('black')
t.begin_fill()

t.setposition(-470,0)
t.pd()
t.circle(20,360)
t.end_fill()

t.pu()
t.fillcolor('black')
t.begin_fill()
t.setposition(-350,-5)
t.pd()
t.circle(20,360)
t.end_fill()
t.pu()


#眼睛白
t.fillcolor('white')
t.begin_fill()

t.setposition(-470,10)
t.pd()
t.circle(10,360)
t.end_fill()

t.pu()
t.fillcolor('white')
t.begin_fill()
t.setposition(-350,5)
t.pd()
t.circle(10,360)
t.end_fill()
t.pu()

#鼻子
t.pensize(8)
t.setposition(-410,-20)
t.pd()
t.goto(-395,-20)
t.pu()

#嘴巴
t.setposition(-450,-35)
t.fillcolor("red")
t.begin_fill()
t.pd()
t.circle(45,60)
t.right(53)
t.circle(45,60)
t.pu()
t.setposition(-445,-37)
t.right(115)
t.pd()
t.circle(300,17)
t.left(20)
t.circle(70,10)
t.left(15)
t.circle(70,10)
t.left(15)
t.circle(70,10)
t.left(15)
t.circle(70,10)
t.left(15)
t.circle(70,10)
t.left(5)
t.circle(70,10)
t.left(4)
t.circle(370,10)
t.end_fill()
t.up()

#腮红
t.pensize(5)
t.setposition(-290,-50)

t.fillcolor("red")
t.begin_fill()
t.pd()
t.circle(20,360)
t.left(20)
t.end_fill()
t.pu()


t.setposition(-480,-50)
t.pd()
t.fillcolor("red")
t.begin_fill()
t.circle(20,360)
t.left(20)
t.end_fill()
t.pu()

#身体
t.setposition(-480,-135)

t.fillcolor("yellow")
t.begin_fill()
t.pensize(3)

t.pd()
t.right(240)
t.circle(900,20)
t.pu()

t.setposition(-300,-129)
t.pd()
t.circle(900,25)
t.end_fill()
t.pu()

#尾巴
t.setposition(-285,-250)
t.pd()
t.fillcolor("yellow")
t.begin_fill()
t.goto(-260,-230)
t.goto(-210,-240)
t.goto(-140,-190)
t.goto(-60,-200)
t.goto(-65,-270)
t.goto(-145,-230)
t.goto(-215,-260)
t.goto(-260,-240)
t.goto(-285,-255)
t.end_fill()
t.done()
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Python皮卡丘代码: ```python import turtle # 设置布大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor('#FEE12B') # 圆函数 def draw_circle(x, y, r, color): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() turtle.circle(r) turtle.end_fill() # 矩形函数 def draw_rectangle(x, y, w, h, color): turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() for i in range(2): turtle.forward(w) turtle.right(90) turtle.forward(h) turtle.right(90) turtle.end_fill() # 皮卡丘的脸 draw_circle(0, 100, 200, '#FED55D') # 皮卡丘的耳朵 draw_circle(-120, 220, 60, '#FED55D') draw_circle(120, 220, 60, '#FED55D') # 皮卡丘的眼睛 draw_circle(-70, 140, 30, '#FFFFFF') draw_circle(70, 140, 30, '#FFFFFF') draw_circle(-70, 140, 15, '#000000') draw_circle(70, 140, 15, '#000000') # 皮卡丘的腮红 draw_circle(-120, 60, 40, '#FC4A5C') draw_circle(120, 60, 40, '#FC4A5C') # 皮卡丘的嘴巴 turtle.penup() turtle.goto(-100, 20) turtle.pendown() turtle.pensize(10) turtle.right(90) turtle.circle(100, 180) # 皮卡丘的鼻子 draw_circle(0, 60, 30, '#000000') # 皮卡丘的眉毛 turtle.penup() turtle.goto(-100, 180) turtle.pendown() turtle.pensize(20) turtle.right(45) turtle.forward(60) turtle.penup() turtle.goto(100, 180) turtle.pendown() turtle.right(90) turtle.forward(60) # 隐藏笔 turtle.hideturtle() # 等待用户关闭窗口 turtle.done() ```

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值