Alexandre B A Villares 2018-02-19 17:43:58 -03:00
rodzic c80fa09990
commit 5514f50e3c
9 zmienionych plików z 40 dodań i 25 usunięć

Wyświetl plik

@ -8,6 +8,14 @@ If you enjoy this, make a small donation [here](https://www.paypal.com/cgi-bin/w
----
![s050](s050/s050.gif)
050: [code](https://github.com/villares/sketch-a-day/tree/master/s050) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]
Arrows now...
----
![s049](s049/s049.gif)
049: [code](https://github.com/villares/sketch-a-day/tree/master/s049) [[Py.Processing](https://villares.github.io/como-instalar-o-processing-modo-python/index-EN)]

BIN
s050/0781.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 46 KiB

BIN
s050/1966.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 49 KiB

BIN
s050/2150.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 52 KiB

BIN
s050/2383.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 50 KiB

BIN
s050/2749.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 47 KiB

BIN
s050/4281.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 54 KiB

BIN
s050/s050.gif 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 197 KiB

Wyświetl plik

@ -1,36 +1,23 @@
add_library('pdf')
import random as rnd
LISTA = []
MARGIN = 25
MARGIN = 100
def setup():
size(500, 500)
background(200)
size(712, 712)
noFill()
smooth(12)
nova_lista()
println("'s' to save, and 'n' for a new drawing")
def draw():
for x, y, s, w, arrow, sub_list in LISTA:
strokeWeight(w)
for n in sub_list:
if arrow:
stroke(0)
seta(x, y, n[0], n[1], s, w*5)
else:
stroke(255)
line(x, y, n[0], n[1])
ellipse(x, y, s, s)
def keyPressed():
background(200)
def nova_lista():
LISTA[:] = []
for _ in range(20):
for _ in range(30):
LISTA.append((
random(MARGIN, width - MARGIN), # x
random(MARGIN, height - MARGIN), # y
rnd.choice([10, 20, 30]), # size
rnd.choice([2, 3, 5]), # strokeW
rnd.choice([2, 4, 6]), # strokeWeight
rnd.choice([True, False]), # arrow
list() # other nodes
))
@ -40,13 +27,33 @@ def keyPressed():
node[-1].append(random_node)
def seta(x1, y1, x2, y2, encurta=12, head=12):
d = dist(x1, y1, x2, y2)
def seta(x1, y1, x2, y2, shorter=12, head=12):
""" draws an arrow """
L = dist(x1, y1, x2, y2)
with pushMatrix():
translate(x2, y2)
angle = atan2(x1 - x2, y2 - y1)
rotate(angle)
offset = -encurta * .6
line(0, offset, 0, -d - offset)
offset = -shorter * .6
line(0, offset, 0, -L - offset)
line(0, offset, -head / 3, -head + offset)
line(0, offset, head / 3, -head + offset)
def draw():
background(200)
for x, y, s, w, arrow, sub_lista in LISTA:
strokeWeight(w)
for n in sub_lista:
if arrow:
stroke(0)
seta(x, y, n[0], n[1], s, w * 5)
else:
stroke(255)
line(x, y, n[0], n[1])
ellipse(x, y, s, s)
def keyPressed():
if key == 's':
saveFrame("####.png")
if key == 'n':
nova_lista()