[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操作图片的库有哪些 ...
随机推荐
- Blazor前后端框架Known-V1.2.7
V1.2.7 Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行. Gitee: https://gitee.com/known/Known Gith ...
- sudo:pam_open_session Permission denied 与 Too many open files
sudo:pam_open_session Permission denied 一,验证 sudo 权限失败: /etc/sudoers 文件未给相关用户配置权限. 打开 /etc/sudoers 文 ...
- Blazor前后端框架Known-V1.2.8
V1.2.8 Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行. Gitee: https://gitee.com/known/Known Gith ...
- .Net Web API 005 Controller上传小文件
1.附属文件对象定义 一般情况下,系统里面的文件都会附属一个对象存在,例如用户的头像文件,会附属用户对象存在.邮件中的文件会附属邮件存在.所以在系统里面,我们会创建一个附属文件对象,命名为Attach ...
- 二代水务系统架构设计分享——DDD+个性化
系统要求 C/S架构的单体桌面应用,可以满足客户个性化需求,易于升级和维护.相比于一代Winform,界面要求美观,控件丰富可定制. 解决方案 依托.Net6开发平台,采用模块化思想设计(即分而治之的 ...
- vivo 场景下的 H5无障碍适配实践
作者:vivo 互联网前端团队- Zhang Li.Dai Wenkuan 随着信息无障碍的建设越来越受重视,开发人员在无障碍适配中也遇到了越来越多的挑战.本文是笔者在vivo开发H5项目做无障碍适配 ...
- 0×03 Vulnhub 靶机渗透总结之 KIOPTRIX: LEVEL 1.2 (#3) SQL注入+sudo提权
0×03 Vulnhub 靶机渗透总结之 KIOPTRIX: LEVEL 1.2 (#3) 系列专栏:Vulnhub靶机渗透系列 欢迎大佬:点赞️收藏关注 首发时间: 2023年8月22日 如有错误 ...
- 为何每个开发者都在谈论Go?
本文深入探讨了Go语言的多个关键方面,从其简洁的语法.强大的并发支持到出色的性能优势,进一步解析了Go在云原生领域的显著应用和广泛的跨平台支持.文章结构严谨,逐一分析了Go语言在现代软件开发中所占据的 ...
- QA|如何给我们的自动化测试代码增加日志记录?|Loguru
这里我们用的是loguru,logging虽然是自带的,但确实使用起来比较繁琐,loguru在Logging基础上增加了很多个性化功能,使用起来也比较简单,所以就使用loguru 代码如下: 1 # ...
- Hutool,一个超好用的 Java 工具类库
一.简介 Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以"甜甜的". ...