[Python急救站课程]Hello Kitty的绘制
我女朋友喜欢Hello Kitty,当她知道我会用Python画图,让我给画一个,怎么说呢,当然要安排上啦!请看程序
import math
import turtle as t
# 计算长度、角度 t1:画笔对象 r:半径 angle:扇形(圆形)的角度
def myarc(t1, r, angle):
arc_length = 2 * math.pi * r * angle / 360 # angle角度的扇形的弧长
n = int(arc_length / 3) + 1 # 线段条数
step_length = arc_length / n # 每条线段的长度
step_angle = angle / n # 每条线段的角度
polyline(t1, n, step_length, step_angle)
# 画弧线 t1:画笔对象 n:线段条数 length:每条线段长度 angle:每条线段的角度
def polyline(t1, n, length, angle):
for index in range(n):
t1.fd(length)
t1.lt(angle)
# 小花
def flower(n):
for X in range(n):
t.forward(0.5)
if X < 80:
t.left(1)
elif X < 120:
t.left(2.3)
else:
t.left(1)
# 画布
t.screensize(500, 500, "white")
t.pensize(8)
t.pencolor("black")
t.speed(10)
# 头
t.penup()
t.goto(-130, 170)
t.pendown()
t.setheading(220)
for x in range(580):
t.forward(1)
if x < 250:
t.left(0.5)
elif x < 350:
t.left(0.1)
else:
t.left(0.5)
# 耳朵
t.setheading(70)
for y in range(150):
t.forward(1)
if y < 80:
t.left(0.2)
elif y < 90:
t.left(10)
else:
t.left(0.2)
t.setheading(160)
for y1 in range(140):
t.forward(1)
t.left(0.15)
t.setheading(140)
for y2 in range(157):
t.forward(1)
if y2 < 65:
t.left(0.2)
elif y2 < 75:
t.left(8)
else:
t.left(0.5)
t.pensize(5)
# 左眼睛
t.penup()
t.goto(-100, 60)
t.setheading(350)
t.pendown()
t.fillcolor("#000")
t.begin_fill()
step = 0.3
for i in range(2):
for j in range(60):
if j < 30:
step += 0.02
else:
step -= 0.02
t.forward(step)
t.left(3)
t.end_fill()
# 右眼睛
t.penup()
t.goto(50, 40)
t.setheading(350)
t.pendown()
t.fillcolor("#000")
t.begin_fill()
step = 0.3
for i in range(2):
for j in range(60):
if j < 30:
step += 0.02
else:
step -= 0.02
t.forward(step)
t.left(3)
t.end_fill()
# 鼻子
t.penup()
t.goto(-40, 30)
t.setheading(260)
t.pendown()
t.fillcolor("#ebc80e")
t.begin_fill()
step = 0.3
for i in range(2):
for j in range(60):
if j < 30:
step += 0.02
else:
step -= 0.02
t.forward(step)
t.left(3)
t.end_fill()
# 小花
t.penup()
t.goto(20, 180)
t.pendown()
t.fillcolor("#dd4a76")
t.begin_fill()
t.setheading(175)
flower(200)
t.setheading(250)
flower(200)
t.setheading(325)
flower(200)
t.setheading(40)
flower(200)
t.setheading(115)
flower(170)
t.end_fill()
t.penup()
t.goto(30, 180)
t.setheading(270)
t.pendown()
t.fillcolor("#e7be04")
t.begin_fill()
t.circle(10)
t.end_fill()
# 胡子
t.penup()
t.goto(-150, 65)
t.pendown()
t.setheading(170)
t.pensize(6)
for y in range(40):
t.forward(1)
t.left(0.3)
t.penup()
t.goto(-150, 85)
t.pendown()
t.setheading(160)
for y in range(50):
t.forward(1)
t.left(0.3)
t.penup()
t.goto(-150, 45)
t.pendown()
t.setheading(180)
for y in range(55):
t.forward(1)
t.left(0.3)
t.penup()
t.goto(110, 10)
t.setheading(340)
t.pendown()
for y in range(40):
t.forward(1)
t.right(0.3)
t.penup()
t.goto(120, 30)
t.setheading(350)
t.pendown()
for y in range(30):
t.forward(1)
t.right(0.3)
t.penup()
t.goto(115, 50)
t.setheading(360)
t.pendown()
for y in range(50):
t.forward(1)
t.right(0.3)
# 身子
t.pensize(8)
t.penup()
t.goto(-100, -30)
t.setheading(230)
t.pendown()
t.fillcolor("#efa9c1")
t.begin_fill()
for z in range(140):
t.forward(1)
t.left(0.2)
t.setheading(340)
for z in range(200):
t.forward(1)
t.left(0.1)
t.setheading(85)
for z in range(140):
t.forward(1)
t.left(0.1)
t.end_fill()
t.penup()
t.goto(-73, -33)
t.pendown()
t.setheading(250)
t.fillcolor("#da4b76")
t.begin_fill()
myarc(t, 40, 205)
t.setheading(170)
t.pensize(6)
t.forward(75)
t.end_fill()
# 左胳膊
t.pensize(8)
t.penup()
t.goto(-120, -17)
t.setheading(230)
t.pendown()
t.fillcolor("#d64b75")
t.begin_fill()
t.forward(50)
t.setheading(320)
for k in range(27):
t.forward(1)
t.left(1)
t.setheading(55)
for k in range(50):
t.forward(1)
t.right(0.1)
t.end_fill()
# 左手
t.penup()
t.goto(-125, -15)
t.setheading(140)
t.pendown()
t.fillcolor("#fff")
t.begin_fill()
t.forward(8)
t.setheading(50)
myarc(t, 10, 190)
t.setheading(150)
for j in range(80):
t.forward(1)
t.left(2.2)
t.forward(24)
t.end_fill()
# 右胳膊
t.penup()
t.goto(27, -45)
t.pendown()
t.fillcolor("#db4e79")
t.setheading(350)
t.begin_fill()
for x in range(50):
t.forward(1)
t.right(1)
t.setheading(220)
t.forward(40)
t.setheading(100)
for x in range(50):
t.forward(1)
t.left(0.2)
t.end_fill()
# 右手
t.penup()
t.goto(70, -75)
t.pendown()
t.setheading(300)
t.forward(8)
t.setheading(30)
for x in range(40):
t.forward(1)
t.right(5)
t.setheading(280)
for x in range(70):
t.forward(1)
t.right(2)
# 右脚
t.penup()
t.goto(-70, -180)
t.pendown()
t.setheading(250)
for x in range(30):
t.forward(1)
t.left(0.3)
for x in range(160):
t.forward(1)
if x < 30:
t.left(3)
elif x < 65:
t.left(0.1)
else:
t.left(1)
# 左脚
t.penup()
t.goto(-150, -210)
t.setheading(340)
t.pendown()
t.fillcolor("#fff")
t.begin_fill()
step = 1.5
for i in range(2):
for j in range(60):
if j < 30:
step += 0.1
else:
step -= 0.1
t.forward(step)
t.left(3)
t.end_fill()
t.hideturtle()
t.mainloop()
运行结果如下:

嘿嘿,让女朋友开心一下哈哈。
画笔速度有点慢,可以自己调哦!
[Python急救站课程]Hello Kitty的绘制的更多相关文章
- Python数据挖掘课程
[Python数据挖掘课程]一.安装Python及爬虫入门介绍[Python数据挖掘课程]二.Kmeans聚类数据分析及Anaconda介绍[Python数据挖掘课程]三.Kmeans聚类代码实现.作 ...
- Python学习课程零基础学Python
python学习课程,零基础Python初学者应该怎么去学习Python语言编程?python学习路线这里了解一下吧.想python学习课程?学习路线网免费下载海量python教程,上班族也能在家自学 ...
- Python使用Plotly绘图工具,绘制直方图
今天我们再来讲解一下Python使用Plotly绘图工具如何绘制直方图 使用plotly绘制直方图需要用到graph_objs包中的Histogram函数 我们将数据赋值给函数中的x变量,x = da ...
- Python使用Plotly绘图工具,绘制面积图
今天我们来讲一下如何使用Python使用Plotly绘图工具,绘制面积图 绘制面积图与绘制散点图和折线图的画法类似,使用plotly graph_objs 中的Scatter函数,不同之处在于面积图对 ...
- Python使用Plotly绘图工具,绘制饼图
今天我们来学习一下如何使用Python的Plotly绘图工具,绘制饼图 使用Plotly绘制饼图的方法,我们需要使用graph_objs中的Pie函数 函数中最常用的两个属性values,用于赋值给需 ...
- Python使用Plotly绘图工具,绘制甘特图
今天来讲一下如何使用Python 的绘图工具Plotly来绘制甘特图的方法 甘特图大家应该了解熟悉,就是通过条形来显示项目的进度.时间安排等相关情况的. 我们今天来学习一下,如何使用ployly来绘制 ...
- Python使用Plotly绘图工具,绘制气泡图
今天来讲讲如何使用Python 绘图工具,Plotly来绘制气泡图. 气泡图的实现方法类似散点图的实现.修改散点图中点的大小,就变成气泡图. 实现代码如下: import plotly as py i ...
- python完整课程
python完整课程 python课程概述 python课程大纲 链接:http://www.cnblogs.com/lx63blog/articles/9054294.html 课程结构: 1.安装 ...
- python入门课程 第一章 课程介绍
1-1 Python入门课程介绍特点: 优雅.明确.简单适合领域: web网站和各种网络服务 系统工具和脚本 作为"胶水"语言把其他语言开发的模块包装起来方 ...
- php课程 8-28 php如何绘制生成显示图片
php课程 8-28 php如何绘制生成显示图片 一.总结 一句话总结:gd库轻松解决 1.php图片操作生成的图的两种去向是什么? 一种在页面直接输出,一种存进本地磁盘 2.php操作图片的库有哪些 ...
随机推荐
- 正确处理 CSV 文件的引号和逗号
CSV(Comma-Separated Values,逗号分割值),就是用纯文本的形式存储表格数据,最大的特点就是方便. 作为开发,我们经常面临导数据的问题,特别是后台系统,产品或者运营的同事常常会提 ...
- SkipList原理与实现
机制 链表中查询的效率的复杂度是O(n), 有没有办法提升这个查询复杂度呢? 最简单的想法就是在原始的链表上构建多层索引. 在level 1(最底层为0), 每2位插入一个索引, 查询复杂度便是 O( ...
- javascript高级程序设计第三版FileApi 学习与实践1
文件操纵 File API File API 在表单中的文件输入字段的基础上,又添加了一些直接访问文件信息的接口. H5 在 DOM 元素中为文件输入元素添加了一个 files 集合. 在通过文件输入 ...
- 基于Aidlux平台的人脸关键点检测以及换脸算法
第一步:安装APP 手机应用市场下载AidLux 手机和电脑连接同一个Wifi 第二步:配置APP 赋予AidLux各种系统权限,包括:媒体和文件.相机.麦克风.后台弹窗 手机-设置-关于手机-点击操 ...
- Windows 环境下载、安装、使用(.Net 5.0) Redis 数据库及常见问题的解决
〇.前言 Redis (Remote Dictionary Server 远程字典服务)是一个使用 ANSI C 编写的开源.包含多种数据结构,支持网络.基于内存.可选持久性的键值对存储数据库,是现在 ...
- Crawpy - 一款python写的网站目录扫描工具
国外网站看到的. 简贴一下谷歌翻译的介绍 是什么让这个工具与其他工具不同: 它被写入异步工作,允许达到最大限制.所以它非常快. 校准模式,自行应用过滤器 有一堆标志可以帮助你详细地模糊 给定状态代码和 ...
- 基于Go编写一个可视化Navicat本地密码解析器
前提 开发小组在测试环境基于docker构建和迁移一个MySQL8.x实例,过程中大意没有记录对应的用户密码,然后发现某开发同事本地Navicat记录了根用户,于是搜索是否能够反解析Navicat中的 ...
- [loki]轻量级日志聚合系统loki快速入门
前言 简述:loki是由grafana开源的日志聚合系统,相较于ELK.EFK更轻量. loki特性: 不对日志进行全文索引.通过存储压缩非结构化日志和仅索引元数据,Loki 操作起来会更简单,更省成 ...
- 后缀数组C++详解
后缀定义 "后缀i"代表以第i个字符开头的后缀,存储是用i代表字符串s的后缀s[i...n] 后缀数组是什么? 后缀数组(Suffix Array)主要关系到两个数组:sa 和 r ...
- Ceph-部署
Ceph规划 主机名 IP地址 角色 配置 ceph_controler 192.168.87.202 控制节点.MGR Centos7系统500G硬盘 ceph_node1 192.168.87.2 ...