使用python turtle画出一个钻戒
2018-04-05 12:23
489 查看
看了很多教程,画出的不同的图案,今天我在这里与大家分享一个使用python turtle画出一个钻戒。
源代码如下:#引入小海龟模块
import turtle
#设置画板的背景色
turtle.bgcolor("gray")
#设置画板的背景图片
#turtle.bgpic(".../timg.gif")
#设置小海龟画笔速度
turtle.speed(0)
turtle.pensize(1)
#画出钻戒的钻石
for i in range(1,5):
#顺时针移动画笔的角度
turtle.right(0)
turtle.speed(0)
#设置画笔的颜色
turtle.pencolor('white')
#画圆,参数steps可以设置形状
turtle.circle(23,steps= 3)
turtle.circle(20,steps= 7)
turtle.circle(15, steps = 6)
turtle.circle(13, steps = 5)
turtle.circle(10,steps = 4)
turtle.circle(10,steps = 3)
#像当前画笔方向前进对应的距离
turtle.forward(4)
turtle.forward(6)
turtle.speed(0)
#像画笔相反的方向移动相应的距离
turtle.backward(48)
turtle.forward(24)
turtle.right(180)
turtle.speed(0)
turtle.circle(36)
#提起画笔
turtle.penup()
#移动画笔的坐标(x,y)
turtle.goto(16,12)
#落下画笔
turtle.pendown()
turtle.circle(42)
turtle.penup()
turtle.goto(50,-100)
turtle.pendown()
#turtle.pencolor('white')
#写入文本
turtle.write('Python的第一个作品:Lee',font = ('华文隶书' ,15 ,'normal'))
turtle.penup()
turtle.goto(50,-115)
turtle.pendown()
turtle.write('2018 年 04 月 05 日' ,font = ('华文隶书',12,'normal'))
turtle.pendown()
#隐藏画笔箭头
turtle.hideturtle()
#关闭turtle
turtle.done()最后的效果:
本文为作者原创,给大家学习参考。
源代码如下:#引入小海龟模块
import turtle
#设置画板的背景色
turtle.bgcolor("gray")
#设置画板的背景图片
#turtle.bgpic(".../timg.gif")
#设置小海龟画笔速度
turtle.speed(0)
turtle.pensize(1)
#画出钻戒的钻石
for i in range(1,5):
#顺时针移动画笔的角度
turtle.right(0)
turtle.speed(0)
#设置画笔的颜色
turtle.pencolor('white')
#画圆,参数steps可以设置形状
turtle.circle(23,steps= 3)
turtle.circle(20,steps= 7)
turtle.circle(15, steps = 6)
turtle.circle(13, steps = 5)
turtle.circle(10,steps = 4)
turtle.circle(10,steps = 3)
#像当前画笔方向前进对应的距离
turtle.forward(4)
turtle.forward(6)
turtle.speed(0)
#像画笔相反的方向移动相应的距离
turtle.backward(48)
turtle.forward(24)
turtle.right(180)
turtle.speed(0)
turtle.circle(36)
#提起画笔
turtle.penup()
#移动画笔的坐标(x,y)
turtle.goto(16,12)
#落下画笔
turtle.pendown()
turtle.circle(42)
turtle.penup()
turtle.goto(50,-100)
turtle.pendown()
#turtle.pencolor('white')
#写入文本
turtle.write('Python的第一个作品:Lee',font = ('华文隶书' ,15 ,'normal'))
turtle.penup()
turtle.goto(50,-115)
turtle.pendown()
turtle.write('2018 年 04 月 05 日' ,font = ('华文隶书',12,'normal'))
turtle.pendown()
#隐藏画笔箭头
turtle.hideturtle()
#关闭turtle
turtle.done()最后的效果:
本文为作者原创,给大家学习参考。
相关文章推荐
- python中使用turtle库画一个蟒蛇
- 使用Python的turtle库画一个简单的五角星
- python cgi ajax - 使用CGIHTTPServer实现一个ajax程序
- 今天犯了一个很蠢的错误,有关python的模块包的使用的
- [python]关于import的一个使用tip
- 用Python 实现刷钻网上抢任务,并实现一个简单的限制使用时间的功能
- IronPython for ASP.NET:使用IronPython创建一个简单的Web页面
- 经常使用的一个python logging封装,支持同时向console和文件输出
- 如何使用Python为Hadoop编写一个简单的MapReduce程序
- Python:通过自定义系统级快捷键来控制程序开始或停止记录日志(使用小技巧解决一个貌似无解的问题)
- 使用Python实现一个小型的航空订票系统(3)
- 留一个神python代码——混合使用wxpython和pyglet(cocos2d编辑器)
- 一个Python HTMLParser的使用例子
- 使用python的flask新建一个简单的站点前做的注意事项
- 今天犯了一个很蠢的错误,有关python的模块包的使用的
- 一个简单的使用代理访问百度页面内容的python脚本
- 使用python为Java项目开发一个预编译脚本
- 使用delphi 为python创建一个新的类型。
- 从使用Python开发一个Socket示例说到开发者的思维和习惯问题 推荐
- Getting Started Spidering a Site使用Chilkat(python)练习的一个爬虫(from :http://www.example-code.com)