from turtle import *
import math
setup(718, 816, 0, 0)
pendown()
pensize(2)
pencolor("purple")
angle_1 = [50,80,235,180,125,-80,-50,'*',
70,180,-70,'*',
50,15,80,195,80,15,80,195,80,15,55,-104,238,
122,104,-55,-15,-80,-195,-80,-15,-80,-195,-80,-15,-50,'*','*',
116,161,-48,-28,'*',
64,19,-132,-152,'*','*','*',
122,-82,-26,'*',
58,-98,-154,
'*','*','*'
]
length_1 = [66,158,80,48,80,158,66,'*',
22//math.sin(math.pi/9),44,22//math.sin(math.pi/9),'*',
70,90,25,77,25,77,25,77,35,90,90,210,310,
310,210,90,90,35,77,25,77,25,77,25,90,70,'*','*',
60,80,70,64,'*',
60,80,70,64,'*','*','*',
2*math.sqrt(76*76+58*58-2*76*58*math.cos(math.pi/45*31)),152,116,'*',
2*math.sqrt(76*76+58*58-2*76*58*math.cos(math.pi/45*31)),152,116,
'*','*','*'
]
angle_2 = [90,-90,-90,180,0,180,-90,180,0,180,90,-90]
length_2 = [55,80,27,28,56,28,156,35,70,35,262,79]
j = 0
for i in range(len(length_1)):
if angle_1[i] == '*':
penup()
seth(angle_2[j])
fd(length_2[j])
j += 1
pendown()
else:
seth(angle_1[i])
fd(length_1[i])
给logo填充颜色
from turtle import *
import math
setup(718, 816, 0, 0)
pendown()
pensize(2)
pencolor('#262525')
begin_fill()
# 黑色部分
angle_1 = [50,80,235,180,125,-80,-50,'*',
'#','#','#','*',
50,15,80,195,80,15,80,195,80,15,55,-104,238,
122,104,-55,-15,-80,-195,-80,-15,-80,-195,-80,-15,-50,'*','*',
'#','#','#','#','*',
'#','#','#','#','*','*','*',
122,-82,-26,'*',
58,-98,-154,
'*','*'
]
length_1 = [66,158,80,48,80,158,66,'*',
'#','#','#','*',
70,90,25,77,25,77,25,77,35,90,90,210,310,
310,210,90,90,35,77,25,77,25,77,25,90,70,'*','*',
'#','#','#','#','*',
'#','#','#','#','*','*','*',
2*math.sqrt(76*76+58*58-2*76*58*math.cos(math.pi/45*31)),152,116,'*',
2*math.sqrt(76*76+58*58-2*76*58*math.cos(math.pi/45*31)),152,116,
'*','*'
]
# '*'代表起笔不画线
angle_2 = [90,-90,-90,180,0,180,-90,180,0,180,90]
length_2 = [55,80,27,28,56,28,156,35,70,35,185]
# '#'代表白色部分
angle_3 = [70,180,-70,
116,161,-48,-28,
64,19,-132,-152]
length_3 = [22//math.sin(math.pi/9),44,22//math.sin(math.pi/9),
60,80,70,64,
60,80,70,64,]
j = 0
k = 0
for i in range(len(length_1)):
if angle_1[i] == '*':
penup()
end_fill()
seth(angle_2[j])
fd(length_2[j])
j += 1
pendown()
begin_fill()
elif angle_1[i] == '#':
fillcolor('white')
seth(angle_3[k])
fd(length_3[k])
k += 1
else:
fillcolor('#262525')
seth(angle_1[i])
fd(length_1[i])
初识Python,还望指正