sketch-a-day/2018/s246/s246.pyde

61 wiersze
1.7 KiB
Plaintext
Czysty Zwykły widok Historia

2018-09-14 21:57:32 +00:00
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
SKETCH_NAME = "s246" # 20180901
OUTPUT = ".png"
2018-09-02 00:37:33 +00:00
curvas = []
2018-09-02 01:51:22 +00:00
n = 3
2018-09-02 00:37:33 +00:00
def setup():
size(1024, 300)
2018-09-02 01:51:22 +00:00
noStroke()
blendMode(MULTIPLY)
2018-09-02 00:37:33 +00:00
def keyPressed():
2018-09-02 01:51:22 +00:00
if key == "s":
saveFrame("###.png")
else:
curvas[:] = []
for i in range(n):
curvas.append((random(-height/6,height/6),
random(-height/6, height/6),
random(.33, 3),
random(.33, 3),
random(.33, 3),
2018-09-02 00:37:33 +00:00
))
def draw():
2018-09-02 01:51:22 +00:00
background(200)
2018-09-02 00:37:33 +00:00
translate(0, height/2)
2018-09-02 01:51:22 +00:00
for i, (h, a, f1, f2, f3) in enumerate(curvas):
if i % 3 == 0:
fill(0, 255, 0)
elif i % 3 == 1:
fill(255, 0, 0)
2018-09-02 00:37:33 +00:00
else:
2018-09-02 01:51:22 +00:00
fill(0, 0, 255)
2018-09-02 00:37:33 +00:00
beginShape()
for x in range(width):
2018-09-02 01:51:22 +00:00
ang = x/30.
2018-09-02 00:37:33 +00:00
s = sin(ang * f1) + sin(ang * f2) + sin(ang * f3)
vertex(x, h+ s * a)
2018-09-02 01:51:22 +00:00
for xx in range(width):
x = width-xx
ang = x/30.
s = sin(ang * f1)*1.1 + sin(ang * f2)*1.2 + sin(ang * f3)*1.3
vertex(x, 10 + h + s * a)
2018-09-02 00:37:33 +00:00
endShape(CLOSE)
2018-09-02 01:51:22 +00:00
2018-09-14 21:57:32 +00:00
# this part is for making it easy to add a markdown static "blog" entry
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)
)