我女朋友喜欢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的绘制的更多相关文章

  1. Python数据挖掘课程

    [Python数据挖掘课程]一.安装Python及爬虫入门介绍[Python数据挖掘课程]二.Kmeans聚类数据分析及Anaconda介绍[Python数据挖掘课程]三.Kmeans聚类代码实现.作 ...

  2. Python学习课程零基础学Python

    python学习课程,零基础Python初学者应该怎么去学习Python语言编程?python学习路线这里了解一下吧.想python学习课程?学习路线网免费下载海量python教程,上班族也能在家自学 ...

  3. Python使用Plotly绘图工具,绘制直方图

    今天我们再来讲解一下Python使用Plotly绘图工具如何绘制直方图 使用plotly绘制直方图需要用到graph_objs包中的Histogram函数 我们将数据赋值给函数中的x变量,x = da ...

  4. Python使用Plotly绘图工具,绘制面积图

    今天我们来讲一下如何使用Python使用Plotly绘图工具,绘制面积图 绘制面积图与绘制散点图和折线图的画法类似,使用plotly graph_objs 中的Scatter函数,不同之处在于面积图对 ...

  5. Python使用Plotly绘图工具,绘制饼图

    今天我们来学习一下如何使用Python的Plotly绘图工具,绘制饼图 使用Plotly绘制饼图的方法,我们需要使用graph_objs中的Pie函数 函数中最常用的两个属性values,用于赋值给需 ...

  6. Python使用Plotly绘图工具,绘制甘特图

    今天来讲一下如何使用Python 的绘图工具Plotly来绘制甘特图的方法 甘特图大家应该了解熟悉,就是通过条形来显示项目的进度.时间安排等相关情况的. 我们今天来学习一下,如何使用ployly来绘制 ...

  7. Python使用Plotly绘图工具,绘制气泡图

    今天来讲讲如何使用Python 绘图工具,Plotly来绘制气泡图. 气泡图的实现方法类似散点图的实现.修改散点图中点的大小,就变成气泡图. 实现代码如下: import plotly as py i ...

  8. python完整课程

    python完整课程 python课程概述 python课程大纲 链接:http://www.cnblogs.com/lx63blog/articles/9054294.html 课程结构: 1.安装 ...

  9. python入门课程 第一章 课程介绍

    1-1 Python入门课程介绍特点:    优雅.明确.简单适合领域:    web网站和各种网络服务    系统工具和脚本    作为"胶水"语言把其他语言开发的模块包装起来方 ...

  10. php课程 8-28 php如何绘制生成显示图片

    php课程 8-28 php如何绘制生成显示图片 一.总结 一句话总结:gd库轻松解决 1.php图片操作生成的图的两种去向是什么? 一种在页面直接输出,一种存进本地磁盘 2.php操作图片的库有哪些 ...

随机推荐

  1. ls 和 du显示文件大小不一样

    查看当前文件系统的磁盘使用 df -k / Filesystem 1K-blocks Used Available Use% Mounted on /dev/nvme0n1p2 97844508 37 ...

  2. Go语言中指针详解

    指针在 Go 语言中是一个重要的特性,它允许你引用和操作变量的内存地址.下面是指针的主要作用和相关示例代码: 1. 引用传递 在 Go 中,所有的变量传递都是值传递,即复制变量的值.如果你想在一个函数 ...

  3. 【解惑】介绍.net中的DataTable的AcceptChanges方法

    DataTable.AcceptChanges方法是一个用于DataTable对象的方法,它将所有对DataTable进行的更改标记为已接受.这意味着所有新增.修改和删除的行都将被标记为DataRow ...

  4. [信息安全] 加密算法:md5摘要算法 / sha256算法

    1 MD5 1.1 算法定义 MD5的全称为 Message-Digest Algorithm,是一种被广泛使用的单向散列函数.属于Hash算法中一种比较重要算法--具有单项加密.加密结果唯一.安全性 ...

  5. 表格JS实现在线Excel的附件上传与下载

    摘要:本文由葡萄城技术团队于博客园原创并首发.转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 前言 在本地使用Excel时,经常会有需要在Excel中添加一 ...

  6. qBittorrent如何运行脚本 BT实现自动改名并方便Jellyfin的搜刮器

    qBittorrent如何运行脚本 BT实现自动改名并方便Jellyfin的搜刮器 很多影视网站下载的视频名字大概是为了规避监测,命名非常奇葩,比如:z灼f流,y骨y等等.如果你使用了Jellyfin ...

  7. O2OA(翱途)开发平台 V8.1正式发布

    尊敬的O2OA(翱途)平台合作伙伴.用户以及亲爱的开发小伙伴们,平台 V8.1版本已正式发布.正值8月的最后一周,我们以更安全.更高效.更好用的崭新面貌迎接9月的到来. O2OA开发平台v8.1版本更 ...

  8. Go开始:Go基本元素介绍

    本文深入探讨了Go编程语言中的核心概念,包括标识符.关键字.具名函数.具名值.定义类型.类型别名.包和模块管理,以及代码块和断行.这些元素是构成Go程序的基础,也是编写高质量代码的关键. 关注Tech ...

  9. QA|workon env后没有进入虚拟环境,但也没有报错,但cmd可以|Python虚拟环境

    问题:pycharm的terminal执行workon env后没有进入虚拟环境,但也没有报错 但cmd可以 原因:因为pycharm的terminal用的是powershell,更改为cmd,重新打 ...

  10. shell、python时间函数小结

    有时需要写一些定时任务脚本,简单总结一下,备忘. 1. 获取当前时间 python 在windows下精确到0.001秒,linux下时间精度为0.000001秒 >>> impor ...