使用turtle库绘制图形
2024-08-28 08:09:04
1.使用turtle库绘制红色五角星图形
import turtle
n = eval(input("请输入五角星的长度"))
turtle.begin_fill() #开始填充颜色
i = 0
while i < 5:
turtle.forward(n)
turtle.right(180-36)
i += 1
turtle.color("red") # 退出填充颜色
turtle.end_fill()
turtle.done()
2.使用turtle库绘制六角形图形
from turtle import *
color("black","red") begin_fill()
pu()
fd(-200)
pd()
seth(30)
fd(300)
seth(-90)
fd(300)
seth(150)
fd(300)
end_fill() pu()
seth(90)
fd(150)
seth(0)
fd(87)
begin_fill() pd()
seth(-90)
fd(300)
seth(30)
fd(300)
seth(150)
fd(300)
end_fill()
done()
3.使用turtle库绘制叠加等边三角形图形
import turtle as t
t.setup(600, 600, None,None)
t.pu()
t.fd(-120)
t.pensize(5)
t.width(5)
t.pencolor("darkgreen")
t.pd()
t.fd(250)
t.seth(120)
t.pencolor("black")
t.fd(250)
t.seth(-120)
t.pencolor("blue")
t.fd(250)
t.pencolor("purple")
t.fd(250)
t.seth(0)
t.pencolor("green")
t.fd(250)
t.pencolor("gold")
t.fd(250)
t.seth(120)
t.pencolor("yellow")
t.fd(250)
t.seth(-120)
t.pencolor("grey")
t.fd(250)
t.seth(120)
t.pencolor("pink")
t.fd(250)
最新文章
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(43)-工作流设计-字段分类设计
- 文件夹右键添加“DOS”命令
- 【python】装饰器
- 转:AngularJS的Filter用法详解
- SQL入门经典(八) 之存储过程
- Python之with语句
- Recovery和Charger模式下屏幕旋转180度
- 解决微信OAuth2.0网页授权回调域名只能设置一个的问题
- php日期时间函数 整理
- 使用Maven创建一个Spring MVC Web 项目
- UVa 11021 (概率 递推) Tribles
- POJ 3264 Balanced Lineup(RMQ)
- MAC OS X 快捷键(自己总结)
- DIV+CSS初学随记
- JAVA写接口傻瓜(?)教程(一)
- LeetCode算法题-Implement Queue Using Stacks(Java实现)
- Mysql数据库表被锁定处理
- nobup 与 后台运行命令
- [java]转:String Date Calendar之间的转换
- [python] os.path模块常用方法汇总