这下边都是我无聊画的,感兴趣可以拿去看看,研究研究琢磨琢磨,练习练习。
实例一
import turtle as t
import random as r
t.setup(500,500)
t.bgcolor("brown")
t.hideturtle()
t.speed(0)
for i in range(50):
t.speed(0)
t.pensize(5)
q = r.randrange(-250,250,18)
w = r.randrange(-250,250,18)
t.penup()
t.goto(q,w)
t.pendown()
colors = ['white','ivory','wheat','seashell']
t.color(colors[i%4])
t.begin_fill()
t.pencolor(colors[i%4])
for z in range(2):
for x in range(1):
for y in range(90):
t.forward(1)
t.right(1)
t.right(90)
t.end_fill()
t.penup()
t.goto(0,-50)
t.pendown()
t.pensize(1)
a = 1
c = 0
while c!=250:
t.color('seagreen')
t.speed(0)
t.forward(a)
t.left(a)
c = c + 1
a = a +0.7
实例二
import random
import turtle as t
t.speed(10)
t.bgcolor('black')
t.hideturtle()
t.pensize(5)
def draw(x,y):
colors=['cyan']
t.pencolor(random.choice(colors))
size=random.randint(10,50)
t.penup()
t.goto(x,y)
t.pendown()
for i in range(1):
t.forward(i)
t.circle(50,steps=3)
for i in range(1):
t.forward(i)
t.circle(50,steps=4)
for i in range(1):
t.forward(i)
t.circle(50,steps=5)
for n in range(50):
x = random.randrange(-380,380,50)
y = random.randrange(-380,380,50)
draw(x,y)
实例三
import turtle as t
t.speed(0)
t.setup(800,800)
t.penup()
t.goto(-400,400)
t.pendown()
t.colormode(255)
t.color((71,60,139))
t.begin_fill()
for i in range(4):
t.forward(800)
t.right(90)
t.end_fill()
#花瓣
t.penup()
t.goto(0,0)
t.pendown()
t.pensize(10)
colors=['seashell','magenta','pink','purple','cyan','tomato']
for i in range(6):
for x in range(2):
for y in range(90):
t.pencolor(colors[x%6])
t.forward(3)
t.right(1)
t.right(90)
t.right(60)
t.speed(0)
#花心
for i in range(6):
for x in range(2):
for y in range(90):
t.pencolor("yellow")
t.forward(1)
t.right(1)
t.right(90)
t.right(60)
t.penup()
t.goto(0,-30)
t.pendown()
t.color('yellow')
t.begin_fill()
t.circle(25)
t.end_fill()
t.pencolor('cyan')
t.penup()
t.goto(-350,350)
t.pendown()
t.write('May the Christmas candle \
bring you peace and \
happiness.', font = ('SimHei', 15, 'bold'))