python画一只佩奇
用python画一只佩奇
- 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()
python画一只佩奇的更多相关文章
- 使用python画一只佩奇
打开界面: 打开python shell界面. 建立脚本: 单击"file"——"new file"来建立脚本. 编写代码: 具体的代码如下. import t ...
- python 画个小猪佩奇
不知道大家小时候有没有学习过logo语言,就是操纵一只小王八,来画各种图案.博主小学微机课就学习了这个,最近发现python的turtle包就是logo语言,所以画个小猪佩奇和大家分享. 代码来自知乎 ...
- python 画小猪佩奇
转自:python画个小猪佩奇 # -*- coding: utf-8 -*- """ Created on Mon May 20 11:36:03 2019 @auth ...
- 沉淀再出发:用python画各种图表
沉淀再出发:用python画各种图表 一.前言 最近需要用python来做一些统计和画图,因此做一些笔记. 二.python画各种图表 2.1.使用turtle来画图 import turtle as ...
- 为什么学Python语言,只需四步全面了解Python语言
为什么学Python语言,只需四步全面了解Python语言每个时代都会悄悄犒赏会选择的人,Python现在风口的语言Python--第三大主流编程语言Python , 是一种面向对象的解释型计算机程序 ...
- python画樱花
用python画简单的樱花 代码如下: import turtle as T import random import time # 画樱花的躯干(60,t) def Tree(branch, t): ...
- 利用Python制作一个只属于和她的聊天器,再也不用担心隐私泄露啦!
------------恢复内容开始------------ 是否担心微信的数据流会被监视?是否担心你和ta聊天的小秘密会被保存到某个数据库里?没关系,现在我们可以用Python做一个只属于你和ta的 ...
- div+css画一个小猪佩奇
用DIV+CSS画一个小猪佩奇,挺可爱的,嘻嘻. HTML部分(全是DIV) <!-- 小猪佩奇整体容器 --> <div class="pig_container&quo ...
- 用python画 pareto front
用python画 pareto front 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2D pf import os import matplotlib.pyplot as plt im ...
随机推荐
- [转]网络协议-redis协议
Redis 通信协议(protocol) 本文档翻译自: http://redis.io/topics/protocol . Redis 协议在以下三个目标之间进行折中: 易于实现 可以高效地被计算机 ...
- 重大消息:华为笔记本电脑开始用LINUX系统
对华为而言,此举不失为一个明智的抉择.在手机操作系统领域,目前已被苹果的IOS系统和谷歌的安卓系统垄断.而IOS系统是封闭式,只为苹果手机使用:安卓是开放性,当谷歌与华为停止合作后.华为手机将无法使用 ...
- Linux CentOS7 VMware正则介绍、grep工具、egrep表达式
一.正则介绍 正则是学习shell脚本的必学的内容,正则学的好坏直接影响到shell编程能力. 正则表达式:使用单个字符串来描述或匹配一系列符合某个句法规则的字符串.通常用来检索和替换那些符合某个模式 ...
- js网页拉起支付宝支付
js网页唤起支付宝进行支付 在做uni-app项目中,打包成 ios App的时候,为了绕过苹果支付的审核,所以用的 webview 加载支付宝的网页支付,进行付款 具体实现流程: 前端通过 url ...
- Java中Compareable和Comparator两种比较器的区别
Java中Compareable和Comparator两种比较器的区别 参考原文链接:https://www.cnblogs.com/ldy-blogs/p/8488138.html 1.引言 在ja ...
- Logback的AsyncAppender与RollingFileAppender流程解析
近期工作中涉及到文件记录.文件翻转等操作,思考有没有成熟的代码以便参考. 因此,第一时间就联想到Logback的AsyncAppender以及RollingFileAppender. AsyncApp ...
- IOS 常用View属性设置
设置按钮属性 1.设置按钮背景颜色 backgroundColor @property (weak, nonatomic) IBOutlet UIButton *deleteButton; self. ...
- NPM概述及使用简介
什么是 NPM npm之于Node,就像pip之于Python,gem之于Ruby,composer之于PHP. npm是Node官方提供的包管理工具,他已经成了Node包的标准发布平台,用于Node ...
- NO26 Linux的文件权限--chmod--Linux删除文件说明--suid--sgid
chmod命令改权限: suid: sgid:
- 2.12 学习总结 之 表单校验插件validate
一.说在前面 昨天 学习了ajax的相关知识 今天 学习表单校验插件validate, 并使用ajax 自定义校验规则 二.validate 插件 1.网络上有许多成熟的插件共使用者参考,插件就是将j ...