sketch-a-day/s338/s338.pyde

47 wiersze
1.1 KiB
Plaintext
Czysty Zwykły widok Historia

2018-12-02 18:37:03 +00:00
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
SKETCH_NAME = "s338" # 20181202
OUTPUT = ".png"
2018-12-02 19:46:18 +00:00
mode = 0
2018-12-02 18:37:03 +00:00
2018-12-02 18:32:25 +00:00
from cell import Cell
from random import choice
CELL_SIZE = 25
Cell.grid = dict()
def setup():
size(500, 500)
rectMode(CENTER)
init_grid(width//CELL_SIZE, height//CELL_SIZE)
def init_grid(w, h):
for i in range(w):
for j in range(h):
Cell.grid[(i, j)] = Cell((i,j), CELL_SIZE, choice((True, False)))
2018-12-02 19:46:18 +00:00
def draw():
background(220)
2018-12-02 18:32:25 +00:00
for c in Cell.grid.values():
2018-12-02 19:46:18 +00:00
c.play(mode)
2018-12-02 18:32:25 +00:00
def keyPressed():
2018-12-02 19:46:18 +00:00
global mode
2018-12-02 18:37:03 +00:00
if key == "s":
saveFrame("###.png")
2018-12-02 19:46:18 +00:00
if key == "2":
mode = 2
if key == "1":
mode = 1
if key == "0":
mode = 0
2018-12-02 18:37:03 +00:00
# print text to add to the project's README.md
def settings():
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(SKETCH_NAME, SKETCH_NAME[1:], OUTPUT)
)