main
Alexandre B A Villares 2018-02-19 18:26:46 -03:00
rodzic 5514f50e3c
commit 71f366212b
1 zmienionych plików z 18 dodań i 13 usunięć

Wyświetl plik

@ -1,4 +1,7 @@
add_library('pdf') """
sketch 50 180219 - Alexandre B A Villares
https://abav.lugaralgum.com/sketch-a-day
"""
import random as rnd import random as rnd
LISTA = [] LISTA = []
@ -16,16 +19,15 @@ def nova_lista():
LISTA.append(( LISTA.append((
random(MARGIN, width - MARGIN), # x random(MARGIN, width - MARGIN), # x
random(MARGIN, height - MARGIN), # y random(MARGIN, height - MARGIN), # y
rnd.choice([10, 20, 30]), # size rnd.choice([10, 20, 30]), # circle size
rnd.choice([2, 4, 6]), # strokeWeight rnd.choice([2, 4, 6]), # strokeWeight
rnd.choice([True, False]), # arrow rnd.choice([True, False]), # is arrow
list() # other nodes list() # sub_list of nodes
)) ))
for node in LISTA: for node in LISTA:
random_node = rnd.choice(LISTA) random_node = rnd.choice(LISTA)
if random_node != node: if random_node != node:
node[-1].append(random_node) node[-1].append(random_node) # adds random node to the sub_list
def seta(x1, y1, x2, y2, shorter=12, head=12): def seta(x1, y1, x2, y2, shorter=12, head=12):
""" draws an arrow """ """ draws an arrow """
@ -41,17 +43,20 @@ def seta(x1, y1, x2, y2, shorter=12, head=12):
def draw(): def draw():
background(200) background(200)
for x, y, s, w, arrow, sub_lista in LISTA: # x, y, s: circle size, w: strokeWeightm, arrow T/F, points to...
strokeWeight(w) for x1, y1, d1, sw, arrow, points_to in LISTA:
for n in sub_lista: strokeWeight(sw)
for other in points_to:
x2, y2 = other[0], other[1]
if arrow: if arrow:
stroke(0) stroke(0)
seta(x, y, n[0], n[1], s, w * 5) # x1, y1, x2, y2, circle offset, arrow head size
seta(x1, y1, x2, y2, d1, sw * 5)
else: else:
stroke(255) stroke(255)
line(x, y, n[0], n[1]) line(x1, y1, x2, y2)
ellipse(x, y, s, s) ellipse(x1, y1, d1, d1)
def keyPressed(): def keyPressed():
if key == 's': if key == 's':
saveFrame("####.png") saveFrame("####.png")