sketch-a-day/sketch_180204b/sketch_180204b.pyde

39 wiersze
1.2 KiB
Plaintext
Czysty Zwykły widok Historia

2018-02-06 11:30:59 +00:00
"""
2018-02-06 11:32:47 +00:00
sketch 35 180204b - Alexandre B A Villares
2018-02-06 11:30:59 +00:00
https://abav.lugaralgum.com/sketch-a-day
"""
from __future__ import division
2018-02-05 01:08:20 +00:00
CONFETI = []
SIZE = 15
def setup():
2018-02-06 00:08:36 +00:00
size(500, 500)
2018-02-05 01:08:20 +00:00
noStroke()
for _ in range(1200):
2018-02-06 11:30:59 +00:00
CONFETI.append(([random(width), # [X,
random(height + 20)], # Y] -> x, y position list
2018-02-05 01:08:20 +00:00
random(TWO_PI), # screen plane rotation
random(TWO_PI), # "Z" rotation
2018-02-06 11:30:59 +00:00
color(random(256), random(256), random(256)) # color
2018-02-05 01:08:20 +00:00
))
def draw():
background(0)
2018-02-06 11:30:59 +00:00
for position, rot1, rot2, color_ in CONFETI:
with pushMatrix(): # contexto do sistema de coordenadas mudado
x, y = position # umpack da lista position
translate(x, y) # translada sistema de coordenadas
2018-02-05 01:08:20 +00:00
rotate(rot1 + float(frameCount / 7))
s = sin(rot2 + float(frameCount / 11))
fill(color_)
ellipse(0, 0, SIZE, SIZE * s)
2018-02-06 11:30:59 +00:00
position[1] += 1 + random(0, 2) * s # update y (position[1])
2018-02-05 01:08:20 +00:00
if y > height + 20:
2018-02-06 11:30:59 +00:00
position[1] = -20
2018-02-05 01:08:20 +00:00
2018-02-06 11:30:59 +00:00
# if frameCount<200 and frameCount % 2
# saveFrame("###.tga") # salva frames para o GIF