|
|
|
@ -0,0 +1,135 @@
|
|
|
|
|
import turtle as t
|
|
|
|
|
import time, random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#六芒星
|
|
|
|
|
def LMX(x,y,d):
|
|
|
|
|
t.penup() #起笔
|
|
|
|
|
t.goto(x, y) #定位坐标
|
|
|
|
|
t.pendown() #落笔
|
|
|
|
|
t.seth(60) #只改变海龟的行进方向(角度按逆时针),但不行进
|
|
|
|
|
for i in range(3): #做三次循环,画一个三角形
|
|
|
|
|
t.fd(d) #将前进的距离设为d
|
|
|
|
|
t.left(120) #逆时针旋转120
|
|
|
|
|
t.penup()
|
|
|
|
|
t.goto(x, -y)
|
|
|
|
|
t.pendown()
|
|
|
|
|
t.seth(-60) # turtle.seth(angle):只改变海龟的行进方向(角度按逆时针),但不行进,angle为绝对度数
|
|
|
|
|
for i in range(3):
|
|
|
|
|
t.fd(d)
|
|
|
|
|
t.right(120)
|
|
|
|
|
t.hideturtle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 圆
|
|
|
|
|
def yuan(r):
|
|
|
|
|
t.penup()
|
|
|
|
|
t.goto(-r * pow(3, 0.5) / 2, -r / 2)
|
|
|
|
|
t.pendown()
|
|
|
|
|
t.circle(r)
|
|
|
|
|
t.hideturtle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 六个小圆环
|
|
|
|
|
def sixy(x, y, r):
|
|
|
|
|
def txyuan(x, y, r):
|
|
|
|
|
t.seth(0)
|
|
|
|
|
y = y - r
|
|
|
|
|
t.penup()
|
|
|
|
|
t.goto(x, y)
|
|
|
|
|
t.pendown()
|
|
|
|
|
t.pensize(2)
|
|
|
|
|
t.circle(r)
|
|
|
|
|
t.penup()
|
|
|
|
|
t.goto(x, y + 3)
|
|
|
|
|
t.pendown()
|
|
|
|
|
r = r - 3
|
|
|
|
|
y = y - r
|
|
|
|
|
t.circle(r)
|
|
|
|
|
|
|
|
|
|
t.color("#5daed9")
|
|
|
|
|
txyuan(x, y, r)
|
|
|
|
|
txyuan(-x, y, r)
|
|
|
|
|
txyuan(-x, -y, r)
|
|
|
|
|
txyuan(x, -y, r)
|
|
|
|
|
txyuan(175, 0, r)
|
|
|
|
|
txyuan(-175, 0, r)
|
|
|
|
|
t.hideturtle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 六边形
|
|
|
|
|
|
|
|
|
|
def lbx(x, y):
|
|
|
|
|
t.penup()
|
|
|
|
|
t.goto(x, y)
|
|
|
|
|
t.pendown()
|
|
|
|
|
for i in range(6):
|
|
|
|
|
t.fd(180)
|
|
|
|
|
t.left(60)
|
|
|
|
|
t.hideturtle()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 初始化
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.setup(1.0, 1.0, 0, 0) #设置主窗体的大小和位置
|
|
|
|
|
t.bgcolor("black")
|
|
|
|
|
t.pencolor("#7ecff1")
|
|
|
|
|
t.hideturtle()
|
|
|
|
|
|
|
|
|
|
# 六芒星和叠加
|
|
|
|
|
mt = ["#0489D4", "#d9f1f1"] # 蓝色,,浅蓝
|
|
|
|
|
mv = ["#6cd1ef", "#d9f1f1"]
|
|
|
|
|
for i in range(2):
|
|
|
|
|
t.speed(3) #画笔的速度
|
|
|
|
|
t.delay(0) #延迟函数,此方法用于返回或设置绘制延迟(以毫秒为单位)。它只需要一个可选的参数作为延迟一个正整数
|
|
|
|
|
t.pensize(2 - i * 1.2) #设置笔的大小
|
|
|
|
|
t.color(mt[i]) #遍历列表的数值
|
|
|
|
|
LMX(0, -70, 122.5) #调用六芒星的函数
|
|
|
|
|
LMX(0, -100, 175)
|
|
|
|
|
t.pensize(3 - i * 1.6)
|
|
|
|
|
t.color(mv[i])
|
|
|
|
|
LMX(0, -200, 350)
|
|
|
|
|
LMX(0, -220, 385)
|
|
|
|
|
|
|
|
|
|
# 圆叠加
|
|
|
|
|
nc = ["#94d5f0", "#acdefa"]
|
|
|
|
|
for i in range(2):
|
|
|
|
|
t.speed(13) #速度,画笔的速度
|
|
|
|
|
t.pensize(3 - i * 1.5)
|
|
|
|
|
t.pencolor(nc[i])
|
|
|
|
|
yuan(220 + i)
|
|
|
|
|
yuan(250 + i)
|
|
|
|
|
yuan(258 + i)
|
|
|
|
|
t.pensize(1)
|
|
|
|
|
t.pencolor("#389bc8")
|
|
|
|
|
t.speed(6)
|
|
|
|
|
yuan(100 + i)
|
|
|
|
|
yuan(110 + i)
|
|
|
|
|
yuan(35 + i)
|
|
|
|
|
yuan(30 + i)
|
|
|
|
|
|
|
|
|
|
# 六个小圆环
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
t.speed(5)
|
|
|
|
|
sixy(86, 155, 40)
|
|
|
|
|
|
|
|
|
|
# 六边形和叠加效果
|
|
|
|
|
BT = ["#54B6D8", "#f0efeb"]
|
|
|
|
|
t.speed(10)
|
|
|
|
|
for i in range(2):
|
|
|
|
|
t.speed(5)
|
|
|
|
|
t.delay(0)
|
|
|
|
|
t.color(BT[i]) #遍历颜色
|
|
|
|
|
t.pensize(3 - i * 1.6)
|
|
|
|
|
t.seth(-12)
|
|
|
|
|
lbx(-123,-135.88) #调用六边形函数且赋予坐标
|
|
|
|
|
t.seth(0) #角度为0度
|
|
|
|
|
lbx(-90,-155.88)
|
|
|
|
|
t.seth(12)
|
|
|
|
|
lbx(-57,-175.88)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
t.done()
|