Python画皮卡丘

博主分享了使用Python花费三天时间绘制的生动可爱的皮卡丘,重点在于皮卡丘的细节,如大眼睛和圆润的手部。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这只皮卡丘用了我三天时间,这只皮卡丘十分生动,可爱,大大的眼睛,手圆圆的。

展示代码:


# coding:utf-8
from turtle import *
import turtle as t
from random import *


def infoPrt():
    print('coordinate: ' + str(t.pos()))
    print('angle: ' + str(t.heading()))


t.pensize(3)
t.hideturtle()
t.colormode(255)
t.color("black")
t.setup(700, 650)
t.speed(1)
t.st()
#t.dot()
t.pu()
#t.goto(-150,100)
t.goto(-210, 86)
t.pd()
infoPrt()
# 头
print('头')
t.seth(85)
t.circle(-100, 50)
#t.seth(78)
#t.circle(-100,25)
infoPrt()
t.seth(25)
t.circle(-170, 50)
infoPrt()

# 右耳
print('右耳')
t.seth(40)
#t.circle(-250,52)
t.circle(-250, 30)
infoPrt()
# 右耳尖
t.begin_fill()
# 左
t.circle(-250, 22)
#t.fillcolor("pink")
# 右
t.seth(227)
t.circle(-270, 15)
prePos = t.pos()
infoPrt()
# 下
t.seth(105)
t.circle(100, 32
好的,要绘制皮,需要使用Python中的turtle库。以下是绘制皮的代码: ```python import turtle # 设置画布大小和背景颜色 turtle.setup(800, 600) turtle.bgcolor('#FFE4B5') # 画圆函数 def draw_circle(x, y, r, color): turtle.penup() turtle.goto(x, y - r) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() turtle.circle(r) turtle.end_fill() # 画矩形函数 def draw_rect(x, y, w, h, color): turtle.penup() turtle.goto(x - w / 2, y - h / 2) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() for i in range(2): turtle.forward(w) turtle.left(90) turtle.forward(h) turtle.left(90) turtle.end_fill() # 画皮的脸 draw_circle(0, 100, 200, '#FCD116') # 画皮的耳朵 draw_circle(-80, 220, 50, '#FCD116') draw_circle(80, 220, 50, '#FCD116') # 画皮的眼睛 draw_circle(-70, 140, 30, '#FFFFFF') draw_circle(70, 140, 30, '#FFFFFF') draw_circle(-70, 140, 10, '#000000') draw_circle(70, 140, 10, '#000000') # 画皮的腮红 draw_circle(-120, 60, 30, '#FF69B4') draw_circle(120, 60, 30, '#FF69B4') # 画皮的嘴巴 turtle.penup() turtle.goto(-150, 20) turtle.pendown() turtle.pensize(10) turtle.right(90) turtle.circle(150, 180) # 画皮的鼻子 draw_circle(0, 50, 20, '#000000') # 画皮的眉毛 turtle.penup() turtle.goto(-100, 180) turtle.pendown() turtle.pensize(20) turtle.right(45) turtle.forward(60) turtle.penup() turtle.goto(40, 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、付费专栏及课程。

余额充值