1.代码
#coding=utf-8
import turtle
spiral=turtle.Turtle()
ninja=turtle.Turtle()
ninja.speed(10)
for i in range(100):
ninja.forward(100)
ninja.right(30)
ninja.forward(20)
ninja.left(60)
ninja.forward(50)
ninja.penup()
ninja.setposition(0,0)
ninja.pendown()
ninja.right(2)
turtle.done()
效果展示:
2.可漂亮的图形堆叠
代码:
#coding=utf-8
import turtle
#画五角星(动态)
spiral=turtle.Turtle()
for i in range(20):
spiral.forward(i*15) #
spiral.right(144) #其中的数字代表,画的角度, 120就画三角形,144就画五角星,
turtle.done()
效果图:
3 说不出名字:
#coding=utf-8
import turtle
painter= turtle.Turtle()
painter.pencolor("blue")
for i in range(30):
painter.forward(30) #数字好像是代表半径
painter.left(100)
painter.pencolor("red")
for i in range(50):
painter.forward(120)
painter.left(123)
turtle.done()
效果图: