# Python turtle艺术画赏析-演道网

import turtle
import random
turtle.tracer(0, 0)
mi = turtle.Screen()
mi.colormode(255)
turtle.bgcolor(“black”)
alex = turtle.Turtle()
alex.speed(10)
alex.goto(0,0)
alex.pensize(0)
alex.ht()
for i in range(500):
alex.color(random.randrange(256),random.randrange(256),random.randrange(256))
alex.goto(round(random.gauss(0,150),0),round(random.gauss(0,150),0))
x = alex.xcor()
y = alex.ycor()
for j in range(25):
z = round(random.gauss(0,5), 0)
a = round(random.gauss(0,5), 0)
alex.color(random.randrange(256),random.randrange(256),random.randrange(256))
alex.pensize(0)
alex.goto(x + z, y + a)
alex.goto(z,a)
turtle.update()
mi.exitonclick()

import random
import turtle
def colorGen(sat = 1, val = 1):
rand1 = round(random.randrange(256)*val)
rand2 = round(random.randrange(256)*val)
sat2 = round((1-sat)*255)
if rand1 >= rand2:
rand1 = round(255*val)
else:
rand2 = round(255*val)
color = [[sat2, rand1, rand2], [rand1, sat2, rand2], [sat2, rand2, rand1],
[rand1, rand2, sat2], [rand2, sat2, rand1], [rand2, rand1, sat2]]
return tuple(color[random.randrange(6)])
def timeTunnel(repeats = 1,linuxmi = 10, stepVar = 1):
for i in range(repeats):
alex.goto(0,0)
alex.seth(random.uniform(0,360)) # 设定标题
alex.color(colorGen(val=0))
for j in range(10):
alex.down()
alex.forward(abs(round(random.gauss(10, stepVar),0)))
alex.seth(h1 + random.gauss(0,linuxmi))
x = alex.xcor()
y = alex.ycor()
alex.color(colorGen(val = j/10))
for k in range(3):
alex.down()
alex.seth(f2 + random.gauss(0, linuxmi))
for u2 in range(10):
alex.color(colorGen(val = u2/10))
alex.seth(h3 + random.gauss(0,linuxmi))
alex.forward(abs(round(random.gauss(10, stepVar), 0)))
m = alex.xcor()
n = alex.ycor()
for l in range(2):
alex.color(colorGen())
alex.down()
alex.seth(abs(h4 + random.gauss(0,linuxmi)))
for l2 in range(10):
alex.color(colorGen(val = l2/10))
alex.seth(h5 + random.gauss(0,linuxmi))
alex.forward(abs(round(random.gauss(10,stepVar),0)))
alex.up()
alex.goto(x, y)
alex.up()
turtle.tracer(0, 0)
wn = turtle.Screen()
wn.colormode(255)
turtle.bgcolor(“black”)
alex = turtle.Turtle()
alex.speed(10)
alex.pensize(0)
alex.ht()
timeTunnel(300)
turtle.update()
wn.exitonclick()

from turtle import * # 导入模块turtle

speed(0) # 将绘图速度设置为0，这是最快的
pencolor(‘red’) # 设置钢笔/线条的颜色为红色
bgcolor(‘black’) # 设置背景/画布的颜色为黑色

x = 0 # 创建一个值为0的变量x
up() # 举起笔，这样就不会画线了

# d()表示向前移动，bk() 示向后移动
# rt()或lt()表示向右倾斜一定角度

rt(45)
fd(90)
rt(135)

down() # 放下笔，让乌龟画画
while x < 120: # 当x的值小于120时，
#连续这样做:
fd(200)
rt(61)
fd(200)
rt(61)
fd(200)
rt(61)
fd(200)
rt(61)
fd(200)
rt(61)
fd(200)
rt(61)

rt(11.1111)
x = x+1 # #在x的值上加1，
# 所以每次循环后它都接近120

exitonclick() # 当您单击时，turtle退出。

Python turtle艺术画赏析相关完整代码可从以下信息的得到下载：

——————————————分割线——————————————

FTP地址：ftp://ftp1.linuxidc.com

——————————————分割线——————————————