#五彩星星
import turtle
def drawstar(x,y,c):
turtle.color(c)
turtle.up()
turtle.goto(x,y)
turtle.down()
turtle.begin_fill()
for i in range(5):
turtle.forward(100)
turtle.right(144)
turtle.end_fill()
turtle.bgcolor('black')
drawstar(-100,100,"yellow")
drawstar(100,100,"green")
drawstar(0,0,"orange")
drawstar(-100,-100,"red")
drawstar(100,-100,"purple")
turtle.done()
#五星红旗
import turtle
turtle.setup(600,400,0,0)
turtle.bgcolor('red')
turtle.fillcolor("yellow")
turtle.color("yellow")
turtle.speed(10)
def mygoto(x,y):
turtle.up()
turtle.goto(x,y)
def draw(z):
turtle.begin_fill()
for i in range(5):
turtle.forward(z)
turtle.right(144)
turtle.end_fill()
mygoto(-280,100) #位置
turtle.down() #落笔
draw(150) #绘制
mygoto(-100,180)
turtle.setheading(305) #朝向
turtle.down()
draw(50)
mygoto(-80,100)
turtle.setheading(30)
turtle.down()
draw(50)
mygoto(-70,50)
turtle.setheading(5)
turtle.down()
draw(50)
mygoto(-90,20)
turtle.setheading(300)
turtle.down()
draw(50)
turtle.hideturtle()
turtle.done()
#888
import turtle
turtle.setup(500,500,200,200)
turtle.pensize(2)
turtle.pencolor('red')
turtle.right(90)
turtle.penup() #笔尖朝上
turtle.fd(-20) #后退20
turtle.pendown() #笔尖朝下
turtle.seth(0) #前进方向归零
turtle.circle(40)
turtle.circle(60)
turtle.circle(-60)
turtle.color('green')
turtle.circle(-40)
turtle.circle(80)
turtle.circle(-80)
turtle.done()
#radius半径
#extent弧度
#steps边数
#彩色图形
import turtle
turtle.bgcolor('black')
t=turtle.Turtle() #绘图模块
colors=['red','yellow','blue','green']
for x in range(100):
t.pencolor(colors[x%4])
t.circle(x)
t.left(90)
#条状物
import turtle
turtle.setup(650,350,300,300)
turtle.penup()
turtle.fd(-250) #forward
turtle.pendown()
turtle.pensize(55)
turtle.pencolor('brown')
turtle.seth(-40) #改变进行角度
for i in range(4):
turtle.circle(40,80)
turtle.circle(-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,180) #调头
turtle.fd(40*2/3)
turtle.done()