利用Python的turtle库绘制玫瑰教程


Posted in Python onNovember 23, 2019

turtle的文档:https://docs.python.org/3/library/turtle.html

用Python的turtle库绘图是很简单的,闲来无事就画了一个玫瑰花,下面奉上源码....

源码:

'''
Created on Nov 18, 2017
@author: QiZhao
'''
import turtle
 
# 设置初始位置
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
 
# 花蕊
turtle.fillcolor("red")
turtle.begin_fill()
turtle.circle(10,180)
turtle.circle(25,110)
turtle.left(50)
turtle.circle(60,45)
turtle.circle(20,170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30,110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90,70)
turtle.circle(30,150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80,90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150,80)
turtle.left(50)
turtle.circle(150,90)
turtle.end_fill()
 
# 花瓣1
turtle.left(150)
turtle.circle(-90,70)
turtle.left(20)
turtle.circle(75,105)
turtle.setheading(60)
turtle.circle(80,98)
turtle.circle(-90,40)
 
# 花瓣2
turtle.left(180)
turtle.circle(90,40)
turtle.circle(-80,98)
turtle.setheading(-83)
 
# 叶子1
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(-80,90)
turtle.right(90)
turtle.circle(-80,90)
turtle.end_fill()
 
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
 
# 叶子2
turtle.right(90)
turtle.right(45)
turtle.fillcolor("green")
turtle.begin_fill()
turtle.circle(80,90)
turtle.left(90)
turtle.circle(80,90)
turtle.end_fill()
 
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200,60)

效果图:

利用Python的turtle库绘制玫瑰教程

以上这篇利用Python的turtle库绘制玫瑰教程就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python实现更改图片尺寸大小的方法(基于Pillow包)
Sep 19 Python
python中的内置函数max()和min()及mas()函数的高级用法
Mar 29 Python
python定时关机小脚本
Jun 20 Python
python 处理string到hex脚本的方法
Oct 26 Python
利用Python对文件夹下图片数据进行批量改名的代码实例
Feb 21 Python
Python可变和不可变、类的私有属性实例分析
May 31 Python
Python 获取项目根路径的代码
Sep 27 Python
Python简易计算器制作方法代码详解
Oct 31 Python
python中数字是否为可变类型
Jul 08 Python
django rest framework 自定义返回方式
Jul 12 Python
python 5个实用的技巧
Sep 27 Python
Python利用Pillow(PIL)库实现验证码图片的全过程
Oct 04 Python
Python input函数使用实例解析
Nov 22 #Python
python循环输出三角形图案的例子
Nov 22 #Python
Python-Flask:动态创建表的示例详解
Nov 22 #Python
python flask中动态URL规则详解
Nov 22 #Python
Python之——生成动态路由轨迹图的实例
Nov 22 #Python
python:动态路由的Flask程序代码
Nov 22 #Python
python判断无向图环是否存在的示例
Nov 22 #Python
You might like
PHP5在Apache下的两种模式的安装
2006/09/05 PHP
给初学PHP的5个入手程序
2006/11/23 PHP
在PHP中使用与Perl兼容的正则表达式
2006/11/26 PHP
php 获取select下拉列表框的值
2010/05/08 PHP
Js中sort()方法的用法
2006/11/04 Javascript
jQuery 注意事项 与原因分析
2009/04/24 Javascript
JS小功能(setInterval实现图片效果显示时间)实例代码
2013/11/28 Javascript
JS+JSP checkBox 全选具体实现
2014/01/02 Javascript
Node.js开发之访问Redis数据库教程
2015/01/14 Javascript
jQuery实现Email邮箱地址自动补全功能代码
2015/11/03 Javascript
JavaScript实战之菜单特效
2016/08/16 Javascript
AngularJS $injector 依赖注入详解
2016/09/14 Javascript
jquery popupDialog 使用 加载jsp页面的方法
2016/10/25 Javascript
JavaScript实现256色转灰度图
2017/02/22 Javascript
解决node-sass偶尔安装失败的方法小结
2018/12/05 Javascript
vue自动路由-单页面项目(非build时构建)
2019/04/30 Javascript
[46:21]Liquid vs LGD 2018国际邀请赛淘汰赛BO3 第一场 8.23
2018/08/24 DOTA
[38:31]完美世界DOTA2联赛PWL S3 Magma vs GXR 第一场 12.13
2020/12/17 DOTA
python网络编程学习笔记(六):Web客户端访问
2014/06/09 Python
python实现在目录中查找指定文件的方法
2014/11/11 Python
python 连接sqlite及简单操作
2017/06/30 Python
python实现机器人行走效果
2018/01/29 Python
python 获取文件下所有文件或目录os.walk()的实例
2018/04/23 Python
Python 3.x基于Xml数据的Http请求方法
2018/12/28 Python
python 将字符串完成特定的向右移动方法
2019/06/11 Python
Pytorch高阶OP操作where,gather原理
2020/04/30 Python
Html5实现文件异步上传功能
2017/05/19 HTML / CSS
Ray-Ban雷朋太阳眼镜英国官网:Ray-Ban UK
2019/11/23 全球购物
校园十大歌手策划书
2014/02/01 职场文书
写求职信有哪些注意事项
2014/05/08 职场文书
党员个人剖析材料(四风问题)
2014/10/07 职场文书
小学生差生评语
2014/12/29 职场文书
2015年高三年级组工作总结
2015/07/21 职场文书
使用Djongo模块在Django中使用MongoDB数据库
2021/06/20 Python
OpenCV图像变换之傅里叶变换的一些应用
2021/07/26 Python
Redis分布式锁的7种实现
2022/04/01 Redis