前几天想着用py画一个校徽,找了好多方法,都说要用傅里叶,但是那个看着不简单,就没有去研究。就自己整了整,用了 点动成线这个原理画了一下,没想到还成了,只不过绕着半圆打圈的字没有往上整,那个有点内容。
#1.引入模块、定义函数
from turtle import *
#自定义向左拐的for循环函数
def forleft(x,y,z):
for i in range(x):
left(y)
fd(z)
#自定义向右拐的for循环函数
def forright(x,y,z):
for i in range(x):
right(y)
fd(z)
2.建立画布
setup(600,600,350,35)
#3.画左边的字“禾”
def he():
begin_fill()
color("red")
pendown()
pencolor("red")
#speed(10)
forleft(1,125,8)
forleft(4,10,5)
forleft(1,15,26)
forright(2,90,28)
forleft(5,10,5)
#第二个拐
forleft(1,40,54)
forleft(13,12,2)
#拐圆弯
forleft(1,24,53)
forright(2,90,31)
forleft(8,10,6)
forleft(1,10,33)
forleft(13,12,2)
forleft(1,24,28)
forright(10,9,3)
fd(24)
forright(1,90,28)
forright(10,9,1)
fd(12)
forleft(15,12,2)
fd(21)
forleft(9,10,2)
fd(40)
forright(2,90,31)
fd(10)
forleft(9,10,2)
fd(80)
for i in range(2):
forleft(15,12,2)
fd(68)
for i in range(2):
forright(8,11,2)
fd(11.5)
right(2)
fd(60)
fd(-5)
forleft(15,12,2)
fd(78)
end_fill()
penup()
#4.画右边的字“口”
def kou():
goto(45,75)
pendown()
begin_fill()
color("red")
fd(35)
forleft(13,12,2)
#拐圆弯
forleft(1,24,53)
fd(125)
forleft(3,30,15)
fd(45)
forleft(3,30,15)
fd(160)
forleft(13,12,2)
forleft(1,24,35)
forright(1,90,65)
end_fill()
penup()
goto(45,55)
pendown()
begin_fill()
color('white')
forleft(1,90,115)
forleft(3,30,10)
fd(30)
forleft(3,30,10)
fd(107)
forleft(1,90,70)
end_fill()
penup()
#里面那个圆
def innercircle():
goto(0,210)
pendown()
pensize(8)
pencolor('red')
circle(190)
penup()
# 外面那个圆
def excircle():
goto(0,260)
pendown()
pensize(4)
pencolor('red')
circle(235)
penup()
goto(0,273)
pendown()
pensize(15)
pencolor('red')
circle(249)
penup()
def main():
he()
kou()
innercircle()
excircle()
main()
done()
结果如下:
真正的校徽如下:
整体来看还是不错的!这个编辑器我不怎么会用,代码可能会错行,请谅解。