Alexandre B A Villares 2018-10-10 20:36:13 -03:00
rodzic fb19df83d3
commit 048d155c7e
3 zmienionych plików z 96 dodań i 0 usunięć

24
s285/node.py 100644
Wyświetl plik

@ -0,0 +1,24 @@
from random import choice
class Node():
nodes = []
def __init__(self, x, y):
self.x = Node.border + Node.spacing / 2 + x * Node.spacing - width / 2
self.y = Node.border + Node.spacing / 2 + y * Node.spacing - height / 2
self.size_ = 1
self.cor = color(0, 0, 200)
self.rot = choice((0, HALF_PI, PI, PI + HALF_PI))
def plot(self, ang):
""" draws node """
with pushMatrix():
translate(self.x, self.y)
rotate(self.rot + ang)
noFill() #stroke(0)
stroke(self.cor)
siz = Node.spacing * self.size_
rect(0, 0, siz, siz)
line(-siz/2, -siz/2, siz/2, siz/2)

BIN
s285/s285.gif 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 2.8 MiB

72
s285/s285.pyde 100644
Wyświetl plik

@ -0,0 +1,72 @@
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
SKETCH_NAME = "s284" # 2018109
OUTPUT = ".gif"
GRID_SIZE = 10
from random import seed
from random import choice
from random import randint
from node import Node
def setup():
global ang
ang = 0
size(500, 500, P2D)
strokeWeight(2)
rectMode(CENTER)
random_seed(101)
init_grid(GRID_SIZE)
def draw():
translate(width/2, height/2)
background(200)
ang = frameCount/31.
for node in Node.nodes:
node.plot(ang)
if not frameCount % 12:
init_grid(GRID_SIZE)
if ang <= PI:
saveFrame("###.png")
else:
noLoop()
def init_grid(grid_size):
Node.border = 50
Node.spacing = (width - Node.border * 2) / grid_size
Node.nodes = []
for x in range(grid_size):
for y in range(grid_size):
new_node = Node(x, y)
Node.nodes.append(new_node)
def keyPressed():
if key == "n":
init_grid(GRID_SIZE)
if key == "s": saveFrame("###.png")
def random_seed(s=None):
global rnd_seed
if s:
rnd_seed = s
seed(rnd_seed)
randomSeed(rnd_seed)
else:
seed(rnd_seed)
randomSeed(rnd_seed)
# 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)
)