突发奇想,拿python画个小猪佩奇,大家可以运行着玩玩

draw.py

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

from turtle import *

def nose(x,y):#鼻子

penup()#提起笔

goto(x,y)#定位

pendown()#落笔,开始画

setheading(-30)#将乌龟的方向设置为to_angle/为数字(0-东、90-北、180-西、270-南)

begin_fill()#准备开始填充图形

a=0.4

for i in range(120):

if 0<=i<30 or 60<=i<90:

a=a+0.08

left(3) #向左转3度

forward(a) #向前走a的步长

else:

a=a-0.08

left(3)

forward(a)

end_fill()#填充完成

penup()

setheading(90)

forward(25)

setheading(0)

forward(10)

pendown()

pencolor(255,155,192)#画笔颜色

setheading(10)

begin_fill()

circle(5)

color(160,82,45)#返回或设置pencolor和fillcolor

end_fill()

penup()

setheading(0)

forward(20)

pendown()

pencolor(255,155,192)

setheading(10)

begin_fill()

circle(5)

color(160,82,45)

end_fill()

def head(x,y):#头

color((255,155,192),"pink")

penup()

goto(x,y)

setheading(0)

pendown()

begin_fill()

setheading(180)

circle(300,-30)

circle(100,-60)

circle(80,-100)

circle(150,-20)

circle(60,-95)

setheading(161)

circle(-300,15)

penup()

goto(-100,100)

pendown()

setheading(-30)

a=0.4

for i in range(60):

if 0<=i<30 or 60<=i<90:

a=a+0.08

lt(3) #向左转3度

fd(a) #向前走a的步长

else:

a=a-0.08

lt(3)

fd(a)

end_fill()

def ears(x,y): #耳朵

color((255,155,192),"pink")

penup()

goto(x,y)

pendown()

begin_fill()

setheading(100)

circle(-50,50)

circle(-10,120)

circle(-50,54)

end_fill()

penup()

setheading(90)

forward(-12)

setheading(0)

forward(30)

pendown()

begin_fill()

setheading(100)

circle(-50,50)

circle(-10,120)

circle(-50,56)

end_fill()

def eyes(x,y):#眼睛

color((255,155,192),"white")

penup()

setheading(90)

forward(-20)

setheading(0)

forward(-95)

pendown()

begin_fill()

circle(15)

end_fill()

color("black")

penup()

setheading(90)

forward(12)

setheading(0)

forward(-3)

pendown()

begin_fill()

circle(3)

end_fill()

color((255,155,192),"white")

penup()

seth(90)

forward(-25)

seth(0)

forward(40)

pendown()

begin_fill()

circle(15)

end_fill()

color("black")

penup()

setheading(90)

forward(12)

setheading(0)

forward(-3)

pendown()

begin_fill()

circle(3)

end_fill()

def cheek(x,y):#腮

color((255,155,192))

penup()

goto(x,y)

pendown()

setheading(0)

begin_fill()

circle(30)

end_fill()

def mouth(x,y): #嘴

color(239,69,19)

penup()

goto(x,y)

pendown()

setheading(-80)

circle(30,40)

circle(40,80)

def body(x,y):#身体

color("red",(255,99,71))

penup()

goto(x,y)

pendown()

begin_fill()

setheading(-130)

circle(100,10)

circle(300,30)

setheading(0)

forward(230)

setheading(90)

circle(300,30)

circle(100,3)

color((255,155,192),(255,100,100))

setheading(-135)

circle(-80,63)

circle(-150,24)

end_fill()

def hands(x,y):#手

color((255,155,192))

penup()

goto(x,y)

pendown()

setheading(-160)

circle(300,15)

penup()

setheading(90)

forward(15)

setheading(0)

forward(0)

pendown()

setheading(-10)

circle(-20,90)

penup()

setheading(90)

forward(30)

setheading(0)

forward(237)

pendown()

setheading(-20)

circle(-300,15)

penup()

setheading(90)

forward(20)

setheading(0)

forward(0)

pendown()

setheading(-170)

circle(20,90)

def foot(x,y):#脚

pensize(10)

color((240,128,128))

penup()

goto(x,y)

pendown()

setheading(-90)

forward(40)

setheading(-180)

color("black")

pensize(15)

fd(20)

pensize(10)

color((240,128,128))

penup()

setheading(90)

forward(40)

setheading(0)

forward(90)

pendown()

setheading(-90)

forward(40)

setheading(-180)

color("black")

pensize(15)

fd(20)

def tail(x,y):#尾巴

pensize(4)

color((255,155,192))

penup()

goto(x,y)

pendown()

seth(0)

circle(70,20)

circle(10,330)

circle(70,30)

def setting(): #参数设置

pensize(4)

hideturtle() #使乌龟无形(隐藏)

colormode(255) #将其设置为1.0或255.随后 颜色三元组的r,g,b值必须在0 .. cmode范围内

color((255,155,192),"pink")

setup(840,500)

speed(10)

def main():

setting() #画布、画笔设置

nose(-100,100) #鼻子

head(-69,167) #头

ears(0,160) #耳朵

eyes(0,140) #眼睛

cheek(80,10) #腮

mouth(-20,30) #嘴

body(-32,-8) #身体

hands(-56,-45) #手

foot(2,-177) #脚

tail(148,-155) #尾巴

done()

if __name__ == '__main__':

main()

image.png

image.png

image.png

image.png

image.png

python画图小猪佩奇_用python画个小猪佩奇相关推荐

  1. python画图皮卡丘_用python画一只可爱的皮卡丘

    #!/usr/bin/env python # -*- coding:utf-8 -*- from turtle import * ''' 绘制皮卡丘头部 ''' def face(x,y): &qu ...

  2. python画图颜色随机_用python画随机颜色随机大小随机位置的正方形

    1 ''' 2 作者:唐梓文3 版本:1.04 日期:08/05/20205 功能:随机的在画布画多个正方形,并涂色6 7 ''' 8 9 importturtle10 importrandom11 ...

  3. python画图程序代码_少儿python编程(7)海龟画图(拓展1)

    我们继续用Python的海龟库来画图吧! 上图是画一朵花的程序,重点是6-12行,使用了函数来定义drawleaf:每一掰叶子由两条弧线组成,每一条弧线重复画15次,每次前进5步,右转6度. 看图形化 ...

  4. python画图的模块_用python和pygame游戏编程入门-画图模块

    在设计一个游戏时,有些时候你可以不加载任何图片,只是绘制一些图形来制作一个游戏. pygame.draw这个模块的作用是在屏幕上绘制各种图形. 函数 作用 rect 绘制矩形 polygon 绘制多边 ...

  5. python画图颜色填充_【Python】Matplotlib画图(十一)——箱线图

    数据描述 参数介绍 plt.boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, pa ...

  6. 用python画佩奇_使用python画个小猪佩奇的示例代码

    基本原理 选好画板大小,设置好画笔颜色.粗细,定位好位置,依次画鼻子.头.耳朵.眼睛.腮.嘴.身体.手脚.尾巴,完事儿. 都知道,Turtle 是 Python 内置的一个比较有趣味的模块,俗称&qu ...

  7. python画图怎么调色_数据可视化Seaborn从零开始学习教程(二) 颜色调控篇

    作者:xiaoyu 微信公众号:Python数据科学 知乎:python数据分析师 Seaborn学习大纲 seaborn的学习内容主要包含以下几个部分: 风格管理 绘图风格设置 颜色风格设置 绘图方 ...

  8. python大牛 关东升_《Python从小白到大牛》第4章 Python语法基础

    本章主要为大家介绍Python的一些语法,其中包括标识符.关键字.常量.变量.表达式.语句.注释.模块和包等内容. 标识符和关键字 任何一种计算机语言都离不开标识符和关键字,因此下面将详细介绍Pyth ...

  9. python之禅 中文_《Python之禅》中对于Python编程过程中的一些建议

    <Python之禅>中对于Python编程过程中的一些建议 来源:中文源码网    浏览: 次    日期:2018年9月2日 [下载文档:  <Python之禅>中对于Pyt ...

最新文章

  1. 单片机检测stc没反应_stc单片机无法烧录,一直正在检测目标单片机怎么办?
  2. 计算机专业特殊人才上大学,上海交通大学计算机科学与工程系(CSE)
  3. 利用ant构建 jsp-servlet-class-jar
  4. 信号与系统 chapter10 系统的初值问题与系数匹配法
  5. 摩托罗拉为什么要限制自家linux手机,摩托罗拉为何在安卓手机大放异彩的时候,突然开始衰败了呢?...
  6. 计算机网络十进制转二进制的应用题,【网络-理论】二进制与十进制的转换
  7. selenium python文档_selenium+python实现百度文库word文档抓取
  8. linux进行MySQL查询_linux下mysql Select查询命令
  9. vb FindwindowEx的用法实例
  10. ListView一些特殊属性
  11. MfC基础--绘图基础--win32
  12. NGINX简介及工作原理
  13. 自学c语言难,c语言难学吗?
  14. 靶机渗透练习81-Momentum:2
  15. 尚硅谷周阳学习微服务《二》
  16. 南大和中科大计算机哪个好,南京大学和中国科技大学哪个更好?
  17. 分享几个DJ网站音乐下载站
  18. 判断一个点是否在闭合曲线内
  19. 在 UltraEdit 或 UEStudio 中执行 DOS 或 Windows 命令
  20. 软件项目简明代码评审流程

热门文章

  1. Google pixel Android 8.0 模拟器
  2. BZOJ2648: SJY摆棋子2716: [Violet 3]天使玩偶
  3. 读书点亮生活-教育成本
  4. 精通特征工程 —— 2.简单得数字奇特技巧
  5. android 群英传笔记,Android 群英传读书笔记1
  6. 牛客网_java选择题
  7. Vim 8文本处理实战 第二章 高级编辑和文本浏览 阅读笔记2
  8. 考研数学 每日一题 第一题
  9. linux下修改ext3硬盘为nst,Linux系统备份与恢复
  10. 携号转网手机号归属地查询