一、畫星星01
import turtle
turtle.setup(500, 500)
wn = turtle.Screen()
t = turtle.Turtle()
wn.title("STAR 01")
t.backward(200)
t.speed(10)
t.pencolor("blue")
for x in range(48):
t.forward(400) #採用固定長度
t.right(172.5)
wn.mainloop()
wn = turtle.Screen()
t = turtle.Turtle()
wn.title("STAR 01")
t.backward(200)
t.speed(10)
t.pencolor("blue")
for x in range(48):
t.forward(400) #採用固定長度
t.right(172.5)
wn.mainloop()
import turtle
turtle.setup(800, 900)
wn = turtle.Screen()
t = turtle.Turtle()
wn.title("STAR 02")
t.speed(10)
t.pencolor("blue")
t.backward(300)
for x in range(90):
t.forward(600)
t.right(148)
t.dot(20,"red") #轉折處畫點
wn.mainloop()
三、畫星星-幸福摩天輪
import turtle
turtle.setup(600, 700)
wn = turtle.Screen()
t = turtle.Turtle()
t.speed(0) #全速
t.backward(250)
t.pencolor("pink")
# start point
t.dot(20,"red")
turtle.setup(600, 700)
wn = turtle.Screen()
t = turtle.Turtle()
t.speed(0) #全速
t.backward(250)
t.pencolor("pink")
# start point
t.dot(20,"red")
#每隔100像素畫一點
for x in range(100):
t.forward(100)
t.dot(15,"blue")
t.forward(100)
t.dot(5,"orange")
t.forward(100)
t.dot(5,"yellow")
t.forward(100)
t.dot(10,"skyblue")
t.forward(100)
t.dot(20,"red")
t.right(148)
wn.mainloop()
for x in range(100):
t.forward(100)
t.dot(15,"blue")
t.forward(100)
t.dot(5,"orange")
t.forward(100)
t.dot(5,"yellow")
t.forward(100)
t.dot(10,"skyblue")
t.forward(100)
t.dot(20,"red")
t.right(148)
wn.mainloop()
"""
subject: draw London's eye
32 seats (360 / 32 = 11.25 degrees)
64 nodes (5.625 degrees)
@author: wuhinco
"""
import turtle
turtle.setup(1000, 800)
wn = turtle.Screen()
wn.title("Love Ferris Wheel")
t = turtle.Turtle()
wn.bgcolor("royalblue")
t.speed(5)
# draw base
t.pencolor("lightgray")
t.pensize(20)
t.right(70)
t.forward(400)
t.backward(400)
t.right(40)
t.forward(400)
t.backward(400)
t.dot(10,"deeppink")
# draw inner star
t.penup()
t.pensize(1)
t.pencolor("limegreen")
t.home()
t.backward(25)
t.sety(5)
t.pendown()
for x in range(16):
t.forward(50)
t.pencolor("limegreen")
t.right(157.5)
# get nodes by circle
t.speed(8)
t.pensize(1)
t.setheading(0)
t.penup()
t.home()
t.sety(25)
t.pendown()
t.backward(250)
t.pencolor("pink")
# start point
t.dot(20,"white")
for x in range(32):
t.forward(100)
t.dot(10,"violet")
t.forward(100)
t.dot(5,"orange")
t.forward(100)
t.dot(5,"yellow")
t.forward(100)
t.dot(10,"skyblue")
t.forward(100)
t.dot(20,"white")
t.dot(15,"gray")
t.right(168.75)
wn.mainloop()
沒有留言:
張貼留言