python简单代码画皮卡丘-用python画一只可爱的皮卡丘实例

本文介绍了使用Python的turtle库绘制皮卡丘的详细步骤,包括脸部、眼睛、脸颊、鼻子、嘴巴、耳朵等部分的代码实现。
摘要由CSDN通过智能技术生成

效果图

20191121105837.jpg

#!/usr/bin/env python

# -*- coding:utf-8 -*-

from turtle import *

'''

绘制皮卡丘头部

'''

def face(x,y):

"""画脸"""

begin_fill()

penup()

# 将海龟移动到指定的坐标

goto(x, y)

pendown()

# 设置海龟的方向

setheading(40)

circle(-150, 69)

fillcolor("#FBD624")

# 将海龟移动到指定的坐标

penup()

goto(53.14, 113.29)

pendown()

setheading(300)

circle(-150, 30)

setheading(295)

circle(-140, 20)

print(position())

forward(5)

setheading(260)

circle(-80, 70)

print(position())

penup()

goto(-74.43,-79.09)

pendown()

penup()

# 将海龟移动到指定的坐标

goto(-144,103)

pendown()

setheading(242)

circle(110, 35)

right(10)

forward(10)

setheading(250)

circle(80, 115)

print(position())

penup()

goto(-74.43,-79.09)

pendown()

setheading(10)

penup()

goto(-144, 103)

pendown()

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要用Python一个皮卡丘,需要用到Python的turtle库。以下是一个简单的代码示例: ```python import turtle turtle.speed(10) # 皮卡丘的头 turtle.color('yellow') turtle.begin_fill() turtle.circle(100) turtle.end_fill() # 皮卡丘的眼睛 turtle.penup() turtle.goto(-40, 120) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.circle(20) turtle.end_fill() turtle.penup() turtle.goto(40, 120) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.circle(20) turtle.end_fill() # 皮卡丘的眼珠 turtle.penup() turtle.goto(-40, 130) turtle.pendown() turtle.color('white') turtle.begin_fill() turtle.circle(8) turtle.end_fill() turtle.penup() turtle.goto(40, 130) turtle.pendown() turtle.color('white') turtle.begin_fill() turtle.circle(8) turtle.end_fill() # 皮卡丘的鼻子 turtle.penup() turtle.goto(0, 70) turtle.pendown() turtle.color('black') turtle.begin_fill() turtle.circle(15) turtle.end_fill() # 皮卡丘的嘴巴 turtle.penup() turtle.goto(-60, 10) turtle.pendown() turtle.color('black') turtle.right(45) turtle.circle(80, 90) # 皮卡丘的脸颊 turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.color('red') turtle.begin_fill() turtle.circle(50) turtle.end_fill() # 皮卡丘的耳朵 turtle.penup() turtle.goto(-90, 160) turtle.pendown() turtle.color('yellow') turtle.begin_fill() turtle.right(45) turtle.circle(60, 90) turtle.goto(-90, 160) turtle.end_fill() turtle.penup() turtle.goto(90, 160) turtle.pendown() turtle.color('yellow') turtle.begin_fill() turtle.right(180) turtle.circle(-60, 90) turtle.goto(90, 160) turtle.end_fill() # 完成 turtle.done() ``` 运行上述代码,即可在turtle绘图窗口中看到一个皮卡丘的图像。可以根据需要调整一些参数,如颜色、大小、位置等,以得到更符合自己想象的效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值