python turtle工具绘制四叶草的实例分享
更新时间:2020年02月14日 10:59:13 作者:unlock1835
在本篇文章里小编给各位整理的是关于python turtle工具绘制四叶草的实例分享,有兴趣的朋友们可以跟着学习下。
本篇文章介绍了python使用turtle库绘制四叶草的方法,代码很简单,希望对学习python的朋友有帮助。
import turtle import time turtle.setup(650.,350,200,200) turtle.pendown() turtle.pensize(10) turtle.pencolor('green') #四叶草 def draw_clover(radius,rotate): #参数radius控制叶子的大小,rotate控制叶子的旋转 for i in range(4): direction = i*90 turtle.seth(60+direction+rotate) #控制叶子根部的角度为60度 # turtle.fd(2*radius*pow(2,1/2)) #控制叶子根部的角度为90度 turtle.fd(4*radius) for j in range(2): turtle.seth(90+direction+rotate) turtle.circle(radius,180) turtle.seth(-60+direction+rotate) turtle.fd(4*radius) turtle.seth(-90) turtle.fd(6*radius) draw_clover(30,45) time.sleep(5)
内容扩展
import turtle def draw_shapes(): window = turtle.Screen() window.bgcolor("red") flower = turtle.Turtle() flower.speed(10) flower.shape("arrow") flower.right(45) for i in range(1,37): for j in range(1,5): draw_circle(flower,i,"green") flower.left(90) flower.right(45) flower.color("green") flower.forward(500) window.exitonclick() def draw_circle(circle,radius,color): circle.color(color) circle.circle(radius) draw_shapes()
以上就是python绘图四叶草的详细内容,感谢大家的学习和对脚本之家的支持。
您可能感兴趣的文章:
- Python使用turtle模块绘制爱心图案
- Python绘图之turtle库的基础语法使用
- Python turtle实现贪吃蛇游戏
- python基于turtle绘制几何图形
- Python趣味挑战之turtle库绘画飘落的银杏树
- 教你利用Python+Turtle绘制简易版爱心表白
- 关于Python turtle库使用时坐标的确定方法
- 使用python图形模块turtle库绘制樱花、玫瑰、圣诞树代码实例
- 使用python的turtle函数绘制一个滑稽表情
- Python如何使用turtle库绘制图形
- python使用turtle库绘制奥运五环
- 解决Python3.8用pip安装turtle-0.0.2出现错误问题
- python使用Turtle库画画写名字
相关文章
python实现word文档批量转成自定义格式的excel文档的思路及实例代码
这篇文章主要介绍了python实现word文档批量转成自定义格式的excel文档的解决思路及实例代码,代码简单易懂,非常不错,具有一定的参考借鉴价值,需要的朋友可以参考下2020-02-02Python使用concurrent.futures模块实现多进程多线程编程
Python的concurrent.futures模块可以很方便的实现多进程、多线程运行,减少了多进程带来的的同步和共享数据问题,下面就跟随小编一起了解一下concurrent.futures模块的具体使用吧2023-12-12
最新评论