sketch-a-day/s244/s244.pyde

51 wiersze
1.3 KiB
Plaintext
Czysty Zwykły widok Historia

2018-09-14 21:41:55 +00:00
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
SKETCH_NAME = "s244" # 20180830
OUTPUT = ".png"
2018-08-31 02:30:44 +00:00
curvas = []
n = 6
def setup():
size(1024, 300)
blendMode(ADD)
background(0)
def keyPressed():
curvas[:] = []
for i in range(n):
2018-08-31 02:37:33 +00:00
curvas.append((random(-height/4,height/4),
random(-height/4, height/4),
2018-09-14 21:52:33 +00:00
random(.2, 5)
2018-08-31 02:37:33 +00:00
))
2018-09-14 21:41:55 +00:00
saveFrame(SKETCH_NAME+OUTPUT)
2018-08-31 02:30:44 +00:00
def draw():
background(0)
translate(0, height/2)
for x in range(width):
2018-09-14 21:52:33 +00:00
for h, a, f in curvas:
2018-08-31 02:30:44 +00:00
ang = x / 30.
2018-09-14 21:52:33 +00:00
if int(f) % 3 == 0:
2018-08-31 02:30:44 +00:00
stroke(255, 0, 0)
2018-09-14 21:52:33 +00:00
elif int(f) % 3 == 1:
2018-08-31 02:30:44 +00:00
stroke(0, 255, 0)
else:
stroke(0, 0, 255)
2018-09-14 21:52:33 +00:00
s = sin(ang * f) * a
line(x, 0, x, h + s)
2018-09-14 21:41:55 +00:00
def settings():
print_text_for_readme(SKETCH_NAME, OUTPUT)
def print_text_for_readme(name, output):
""" prints text in the console to add to project README.md """
println("""
![{0}]({0}/{0}{2})
{1}: [code](https://github.com/villares/sketch-a-day/tree/master/{0}) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
""".format(name, name[1:], output)
)