1、python画迪斯科灯
import turtle
import math
import random
#color = ['green','red','blue','yellow','orange','pink']
pen = turtle.Turtle()
turtle.colormode(255)
rr = 3
theta = 0
pi = 3.1415926
pen.pensize(5)
pen.speed(0)
pen.left(90)
for j in range(60):
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
pen.penup()
pen.goto(0,0)
pen.down()
#pen.pencolor(color[j%6])
pen.pencolor((r,g,b))
pen.penup()
pen.goto(60*math.sin(2*pi/60*j),60*math.cos(2*pi/60*j))
pen.down()
#pen.reset()
#pen.left(6)
pen.forward(random.randint(20,80))
pen.setheading(90)
pen.right(6*j)
#theta = 6 * j
turtle.done()
2、Python画随机雨点
import turtle
import math
import random
pen = turtle.Turtle()
turtle.colormode(255)
rr = 20
#theta = 0
#pi = 3.1415926
pen.pensize(5)
pen.speed(0)
r = 100
g = 100
b = 150
dd0 = 20
dd = 30
for j in range(20):
rr = 20
r = 100
g = 100
b = 150
dd0 = 20
dd = 30
x = random.randint(-300,300)
y = random.randint(-300,300)
for i in range(10):
pen.color((r,g,b))
pen.penup()
#pen.goto(0,dd0+dd)
pen.goto(x,y+dd0-2*(11-i))
pen.down()
pen.dot(rr)
#dd = dd - 3
rr = rr -2
r = r + 6
b = b + 6
turtle.done()
3、Python画五彩螺旋
from turtle import *
colors = ['red', 'purple', 'blue', 'green', 'yellow', 'orange']
for x in range(360):
pencolor(colors[x % 6])
width(x / 100 + 1)
forward(x)
left(59)
speed(0)
done()
五彩螺旋2
import turtle
color = ['green','red','blue','yellow','orange','pink']
pen = turtle.Turtle()
rr = 3
pen.pensize(3)
pen.speed(0)
for j in range(20):
for i in range(5):
rr = rr + 2
pen.pencolor(color[i])
pen.forward(rr)
pen.left(36) # 61 84 6
pen.pencolor(color[5])
pen.forward(rr)
pen.left(36)
rr = rr + 2
turtle.done()
文章来源:https://www.toymoban.com/news/detail-505417.html
文章来源地址https://www.toymoban.com/news/detail-505417.html
到了这里,关于用python画一些有趣的图案(001)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!