如何用Python绘制曲线——Turtle花之舞的几何之美

水陆草木之花,可爱者甚蕃。 

在研究Turtle绘制某图的时候,偶得下面两幅小图,似花非花、静小柔美。附上代码,记录下夏日花见。

 

其一《小花的舞》

点击在线欣赏《小花的舞》绘制过程

如何用Python绘制曲线——Turtle花之舞的几何之美_第1张图片

from turtle import *
pensize(5)
speed(0)

##【背景圆】
color('#99BBFF')#浅紫
pu()
goto(0,-200)
pd()
begin_fill()
circle(200)
end_fill()


##定义画弧函数
def arc(initial_degree,range_num,step,rotate_degree):
    seth(initial_degree)
    for n in range(range_num):   
        fd(step)
        rt(rotate_degree)#    

#花盘
initial_degree = 0
for i in range(18):
    pu()
    home()
    pd()
    pencolor("#FFDEAD")
    arc(initial_degree+20*i,100,2,2)

hideturtle()

其二《花团》

点击在线欣赏《花团》绘制过程

如何用Python绘制曲线——Turtle花之舞的几何之美_第2张图片

from turtle import *
pensize(4)
speed(0)

##【背景圆】
color('white')
pu()
goto(0,-200)
pd()
begin_fill()
circle(200)
end_fill()


##定义画弧函数
def arc(initial_degree,range_num,step,rotate_degree):
    seth(initial_degree)
    for n in range(range_num):   
        fd(step)
        rt(rotate_degree)#    

#花盘
initial_degree = 0
for i in range(9):
    pu()
    home()
    pd()
    pencolor("#FFDEAD")
    arc(initial_degree+40*i,100,3,3)

hideturtle()

 

你可能感兴趣的:(python_turtle)