如何用Python画一些简单形状你知道吗
作者:我帅的是不是无可救药 时间:2021-06-23 06:56:13
进入主题
1.
import turtle as t
import math
t.pensize(3)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,5):
t.penup()
t.goto(start_x,y)
t.pendown()
for x in range(-200,200,1):
if ((y-50*(math.cos(0.05*x)) <= 80) and
(y-50*(math.cos(0.05*x)) >= 60)):
t.pencolor('yellow')
elif ((y-50*(math.cos(0.05*x)) <= 40) and
(y-50*(math.cos(0.05*x)) >= -20)):
t.pencolor('blue')
elif ((y-50*(math.cos(0.05*x)) <= -20) and
(y-50*(math.cos(0.05*x)) >= -80)):
t.pencolor('red')
elif ((y-50*(math.cos(0.05*x)) <= -60) and
(y-50*(math.cos(0.05)) <= -80)):
t.pencolor('green')
else:
t.pencolor('black')
t.setx(x)
t.update()
t.done()
import turtle as t
t.speed(0)
t.tracer(20)
t.hideturtle()
t.colormode(255)
angle = 90
for x in range(255,0,-5):
for n in range(360//angle):
t.pencolor((x,255,255))
t.fillcolor((25,x,255))
t.begin_fill()
for i in range(2):
t.forward(x)
t.right(angle)
t.forward(x)
t.right(180-angle)
t.end_fill()
t.right(angle)
t.update()
t.done()
import turtle as t
t.speed(0)
t.tracer(20)
t.colormode(255)
angle = 60
angle2 = 3
for x in range(255,0,-5):
for n in range(360//angle):
t.pencolor((x,255,255))
t.fillcolor((255,x,255))
t.begin_fill()
for i in range(2):
t.forward(x)
t.right(angle)
t.forward(x)
t.right(180-angle)
t.end_fill()
t.right(angle)
t.right(angle2)
t.update()
t.done()
from turtle import *
colormode(255)
tracer(5)
a1=39
a2=1
for x in range(255,0,-5):
pencolor(x,255,255)
fillcolor(255,x,255)
for y in range(360//a1):
begin_fill()
for z in range(2):
fd(x)
rt(a1)
fd(x)
rt(180-a1)
end_fill()
rt(a1)
rt(a2)
update()
ht()
done()
import turtle as t
t.speed(0)
t.hideturtle()
t.penup()
t.setx(-200)
t.pendown()
r = 20
i = 6
for x in range(10):
if x % 2 == 0:
t.fillcolor("skyblue")
t.begin_fill()
t.circle(r)
t.end_fill()
add = 0
else:
t.fillcolor("green")
t.begin_fill()
for n in range(4):
t.forward(r*2)
t.left(90)
t.end_fill()
add = r*2
t.penup()
t.forward(r+i+add)
t.pendown()
t.done()
import turtle as t
t.pensize(5)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,20):
t.penup()
t.goto(start_x,y)
t.pendown()
for x in range(-200,200,1):
if ((x < 100 and x > 0) and
(y < 80 and y > 0)):
t.pencolor('yellow')
elif ((x < 100 and x > 0) and
(y < 0 and y > -80)):
t.pencolor('blue')
elif ((x < 0 and x > -100) and
(y < 80 and y > 0)):
t.pencolor('red')
elif ((x < 0 and x > -100) and
(y < 0 and y > -80)):
t.pencolor('orange')
else:
t.pencolor('green')
t.setx(x)
t.update()
t.done()
import turtle as t
t.pensize(5)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,20):
t.penup()
t.goto(start_x,y)
t.pendown()
for x in range(-200,200,1):
if ((y-x <= 40) and
(y-x >= -40)):
t.pencolor('yellow')
elif ((y+x <= 40) and
(y+x >= -40)):
t.pencolor('blue')
else:
t.pencolor('green')
t.setx(x)
t.update()
t.done()
import turtle as t
t.speed(0)
t.tracer(20)
t.hideturtle()
t.colormode(255)
angle = 60
for x in range(255,0,-5):
for n in range(360//angle):
t.pencolor((x,255,255))
t.fillcolor((255,x,255))
t.begin_fill()
for i in range(2):
t.forward(x)
t.right(angle)
t.forward(x)
t.right(180-angle)
t.end_fill()
t.right(angle)
t.update()
t.done()
来源:https://blog.csdn.net/m0_60636930/article/details/119729343
标签:Python,画
0
投稿
猜你喜欢
perl 文件操作总结
2023-07-07 07:17:38
ASP中Utf-8与Gb2312编码转换乱码问题的解决方法 页面编码声明
2012-11-30 20:45:55
python paramiko连接ssh实现命令
2022-03-29 02:29:22
Vue如何实现多页面配置以及打包方式
2024-05-02 17:09:11
用Python实现爬取百度热搜信息
2023-12-28 22:22:20
python中networkx函数的具体使用
2023-01-05 12:29:16
PHP实现通过正则表达式替换回调的内容标签
2024-05-13 09:25:39
Mysql数据库按时间点恢复实战记录
2024-01-16 22:37:56
python PyAUtoGUI库实现自动化控制鼠标键盘
2022-07-07 16:47:41
使用python解析json字段的3种方式实例
2021-12-24 04:16:27
python 实现数组list 添加、修改、删除的方法
2021-10-21 16:27:34
python中关于py文件之间相互import的问题及解决方法
2021-08-29 00:29:33
Python自定义线程池实现方法分析
2021-12-17 09:13:10
MySQL数据库之union,limit和子查询详解
2024-01-16 08:15:29
用ASP实现在线压缩与解压缩
2007-09-29 12:13:00
python分析网页上所有超链接的方法
2021-03-15 05:28:08
Python线程threading模块用法详解
2023-01-30 03:55:01
python生成遍历暴力破解密码的方法
2021-07-02 21:28:54
用pywin32实现windows模拟鼠标及键盘动作
2023-07-04 21:26:30
详解Python中的路径问题
2021-06-05 08:48:45