day 50
|
@ -8,6 +8,14 @@ If you enjoy this, make a small donation [here](https://www.paypal.com/cgi-bin/w
|
|||
|
||||
----
|
||||
|
||||

|
||||
|
||||
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...
|
||||
|
||||
----
|
||||
|
||||

|
||||
|
||||
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)]
|
||||
|
|
Po Szerokość: | Wysokość: | Rozmiar: 46 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 49 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 52 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 50 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 47 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 54 KiB |
Po Szerokość: | Wysokość: | Rozmiar: 197 KiB |
|
@ -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()
|
||||
|
|