Python绘图Turtle库详解&情人节玫瑰花

https://blog.csdn.net/zengxiantao1994/article/details/76588580

(https://mp.weixin.qq.com/s/80bGWMuzg5VwDls87FCrJQ)

from turtle import * # 导入海龟模块
import time   

setup(600,800,0,0)  # 画布(宽,高,矩形窗口左上角顶点的位置,为空则表示窗口位于屏幕中心)
speed(0) # 设置画笔移动速度,画笔绘制的速度范围[0,10]整数,数字越大越快
penup()  # 提起笔移动,不绘制图形,用于另起一个地方绘制
seth(90) # 设置当前朝向为angle角度
fd(340) # forward(distance) 向当前画笔方向移动distance像素长度
seth(0)
pendown() # 移动时绘制图形,缺省时也为绘制

speed(5)
begin_fill() # 准本填充图形
fillcolor('red') # 绘制图形的填充颜色
circle(50,30)  # 画圆,半径为正(负),表示圆心在画笔的左边(右边)画圆

for i in range(10):
 fd(1)
 left(10)  # left(degree)逆时针移动degree

circle(40,40)

for i in range(6):
 fd(1)
 left(3)

circle(80,40)

for i in range(20):
 fd(0.5)
 left(5)

circle(80,45)

for i in range(10):
 fd(2)
 left(1)

circle(80,25)

for i in range(20):
 fd(1)
 left(4)

circle(50,50)

time.sleep(0.1) # 沉睡0.1秒

circle(120,55)

speed(0)

seth(-90)
fd(70)

right(150)
fd(20)

left(140)
circle(140,90)

left(30)
circle(160,100)

left(130)
fd(25)

penup()
right(150)
circle(40,80)
pendown()

left(115)
fd(60)

penup()
left(180)
fd(60)
pendown()

end_fill()

right(120)
circle(-50,50)
circle(-20,90)

speed(1)
fd(75)

speed(0)
circle(90,110)

penup()
left(162)
fd(185)
left(170)
pendown()
circle(200,10)
circle(100,40)
circle(-52,115)
left(20)
circle(100,20)
circle(300,20)
speed(1)
fd(250)

penup()
speed(0)
left(180)
fd(250)
circle(-300,7)
right(80)
circle(200,5)
pendown()

left(60)
begin_fill()
fillcolor('green')
circle(-80,100)
right(90)
fd(10)
left(20)
circle(-63,127)
end_fill()

penup()
left(50)
fd(20)
left(180)

pendown()
circle(200,25)

penup()
right(150)

fd(180)

right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100,80)
right(150)
fd(10)
left(60)
circle(-80,98)
end_fill()

penup()
left(60)
fd(13)
left(180)

pendown()
speed(1)
circle(-200,23)



exitonclick()

Python绘图Turtle库详解&情人节玫瑰花_第1张图片

from turtle import *
import time

setup(600,800,0,0)
speed(0)
penup()
seth(90)
fd(340)
seth(0)
pendown()

speed(5)
begin_fill()
fillcolor('red')
circle(50,30)

for i in range(10):
 fd(1)
 left(10)

circle(40,40)

for i in range(6):
 fd(1)
 left(3)

circle(80,40)

for i in range(20):
 fd(0.5)
 left(5)

circle(80,45)

for i in range(10):
 fd(2)
 left(1)

circle(80,25)

for i in range(20):
 fd(1)
 left(4)

circle(50,50)

time.sleep(0.1)

circle(120,55)

speed(0)

seth(-90)
fd(70)

right(150)
fd(20)

left(140)
circle(140,90)

left(30)
circle(160,100)

left(130)
fd(25)

penup()
right(150)
circle(40,80)
pendown()

left(115)
fd(60)

penup()
left(180)
fd(60)
pendown()

end_fill()

right(120)
circle(-50,50)
circle(-20,90)

speed(1)
fd(75)

speed(0)
circle(90,110)

penup()
left(162)
fd(185)
left(170)
pendown()
circle(200,10)
circle(100,40)
circle(-52,115)
left(20)
circle(100,20)
circle(300,20)
speed(1)
fd(250)

penup()
speed(0)
left(180)
fd(250)
circle(-300,7)
right(80)
circle(200,5)
pendown()

left(60)
begin_fill()
fillcolor('green')
circle(-80,100)
right(90)
fd(10)
left(20)
circle(-63,127)
end_fill()

penup()
left(50)
fd(20)
left(180)

pendown()
circle(200,25)

penup()
right(150)

fd(180)

right(40)
pendown()
begin_fill()
fillcolor('green')
circle(-100,80)
right(150)
fd(10)
left(60)
circle(-80,98)
end_fill()

penup()
left(60)
fd(13)
left(180)

pendown()
speed(1)
circle(-200,23)



exitonclick()

Python绘图Turtle库详解&情人节玫瑰花_第2张图片

你可能感兴趣的:(Python绘图Turtle库详解&情人节玫瑰花)