[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操作图片的库有哪些 ...
随机推荐
- Unity UGUI的LayoutElement(布局元素)组件的介绍及使用
Unity UGUI的LayoutElement(布局元素)组件的介绍及使用 1. 什么是LayoutElement组件? LayoutElement是Unity UGUI中的一个布局元素组件,用于控 ...
- pgrep:根据名称或其他属性查找进程(查找系统中running状态的进程)
用法示例 # 根据名称过滤 dewan Work ~/code/shell% pgrep qemu 3570191 dewan Work ~/code/shell% pgrep qemu -l 357 ...
- C#数据去重的这几种方式,你知道几种?
前言 今天我们一起来讨论一下关于C#数据去重的常见的几种方式,每种方法都有其特点和适用场景,我们根据具体需求选择最合适的方式.当然欢迎你在评论区留下你觉得更好的数据去重的方式. 使用HashSet去重 ...
- 2021-11-29 Wpf的ViewModel和xaml绑定
ViewModel代码 public class MainViewModel { MainWindow _mainWindow; public MainViewModel(MainWindow mai ...
- 2021-7-12 VUE的增删改查功能简单运用
Vue增删改查简易实例 <!DOCTYPE html> <html> <head> <title> </title> <style t ...
- 磁盘问题和解决: fsck,gdisk,fdisk等
错误: Resize inode not valid 对于gpt分区的硬盘一般fsck只能检查分区, 不能用于检查整个硬盘, 但是如果对硬盘设备运行时遇到这样的错误 $ sudo fsck -n /d ...
- MYSQL中JSON类型介绍
1 json对象的介绍 在mysql未支持json数据类型时,我们通常使用varchar.blob或text的数据类型存储json字符串,对mysql来说,用户插入的数据只是序列化后的一个普通的字符串 ...
- IOS Safari、微信小程序 img或者其他标签元素出现黑边、黑线阴影
这个问题最开始出现在小程序上,然后在社区找到一个一样得案例 案例:https://developers.weixin.qq.com/community/develop/doc/000608420706 ...
- 高效构建 vivo 企业级网络流量分析系统
作者:vivo 互联网服务器团队- Ming Yujia 随着网络规模的快速发展,网络状况的良好与否已经直接关系到了企业的日常收益,故障中的每一秒都会导致大量的用户流失与经济亏损.因此,如何快速发现网 ...
- 部署安装maven和mvnd
前言 maven是常见的java构建工具,优点是稳定可靠,缺点是构建太慢,maven-mvnd是maven的强化版,致力于提高构建速度,默认情况下,mvnd 使用多核CPU并行构建. 常见的java构 ...