我女朋友喜欢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. windows下安装及配置JDK(详解版)

    1.下载JDK 本文以JDK1.8为主 JDK1.8官方下载链接 https://www.oracle.com/java/technologies/javase/javase-jdk8-downloa ...

  2. 行行AI人才直播第12期:风平智能创始人林洪祥《AI数字人的技术实践和商业探讨》

    行行AI人才是博客园和顺顺智慧共同运营的AI行业人才全生命周期服务平台. 歌手孙燕姿凭借AI翻唱席卷各大视频平台.有视频博主用AI技术复活已故的奶奶,并且与之对话缅怀亲人填补遗憾.更有国外网红通过GP ...

  3. Java 调用gdal API(二)——栅格裁剪

    gdal可以说是GIS数据处理比较好的工具之一,虽然也提供了Java API,但是官方文档确实太过简单,用起来确实太难受,每次都需要去参考对应的C++api,然后在对应使用. 因此小编决定从这篇文章开 ...

  4. 打造原生 WebGL 2D 引擎:一场创意与技术的融合

    打造原生 WebGL 2D 引擎:一场创意与技术的融合 1.引言 在当今数字化时代,网页的功能越来越丰富,已经远远超越了传统的文本和图片呈现.我们生活在一个充满交互性和视觉魅力的网络世界.每天都会遇到 ...

  5. 深度系统安装mysql

    # 安装 Mysql 8.0.19下载 MySQL Community Server 8.0.19 [Compressed TAR Archive](mysql-8.0.19-linux-glibc2 ...

  6. 记一次使用pagehelper的坑(返回的total和size每页条数一致的问题)

    问题描述 众所周知,pagehelper使用时应该在dao查询语句的前一句加上PageHelper.startPage,所以标题的问题由此引出-- 原因 PageHelper.startPage使用后 ...

  7. 让nodejs开启服务更简单--koa篇

    在nodejs原始的http模块中,开启一个服务编码相对麻烦,需要对请求方式及上传的数据进行各种判断,而koa给我们提供了比较便捷的编码方式,同时它还有很多中间件可以直接拿来使用.   首先来看,如何 ...

  8. 几种常用到的 Hybrid App 技术框架

    移动操作系统在经历了诸神混战之后,BlackBerry OS.Symbian OS.Windows Phone 等早期的移动操作系统逐渐因失去竞争力而退出.目前,市场上主要只剩下安卓和 iOS 两大阵 ...

  9. 【日常踩坑】解决 pip 安装第三方包时因 SSL 报错

    目录 踩坑 什么是 SSL ? 为什么会报错 解决办法 1. 临时关闭代理.VPN 或者网络抓包等软件 2. 通过镜像的 HTTP 源来避免 SSL 认证问题 3. 切换至低版本 pip 参考资料 踩 ...

  10. 玩转 PI 系列-看起来像服务器的 ARM 开发板矩阵-Firefly Cluster Server

    前言 基于我个人的工作内容和兴趣,想要在家里搞一套服务器集群,用于容器/K8s 等方案的测试验证. 考虑过使用二手服务器,比如 Dell R730, 还搞了一套配置清单,如下: Dell R730 3 ...