kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
bba4185fa4
commit
d4177566ca
|
|
@ -1,15 +1,15 @@
|
|||
# Alexandre B A Villares - https://abav.lugaralgum.com/sketch-a-day
|
||||
SKETCH_NAME, OUTPUT = "s147", ".gif" # 180527
|
||||
SKETCH_NAME, OUTPUT = "s148", ".gif" # 180528
|
||||
|
||||
add_library('gifAnimation')
|
||||
from gif_export_wrapper import *
|
||||
|
||||
GRID_SIZE = 32
|
||||
GRID_SIZE = 25
|
||||
|
||||
def setup():
|
||||
size(500, 500)
|
||||
print_text_for_readme(SKETCH_NAME, OUTPUT)
|
||||
border = 20
|
||||
border = 12.5
|
||||
spacing = (width - border * 2) / GRID_SIZE
|
||||
Ponto.spacing = spacing
|
||||
for j in range(GRID_SIZE):
|
||||
|
|
@ -28,7 +28,7 @@ def draw():
|
|||
p.update()
|
||||
|
||||
if frameCount > 100 and not frameCount % 2:
|
||||
gif_export(GifMaker, frames=200, filename=SKETCH_NAME)
|
||||
pass #gif_export(GifMaker, frames=200, filename=SKETCH_NAME)
|
||||
|
||||
class Ponto():
|
||||
PONTOS = []
|
||||
|
|
@ -38,7 +38,7 @@ class Ponto():
|
|||
self.y = y
|
||||
self.px = x
|
||||
self.py = y
|
||||
self.link_count = 4
|
||||
self.link_count = 0
|
||||
|
||||
def set_neighbours(self):
|
||||
self.ort_ngb = [] # orthogonal neighbours
|
||||
|
|
@ -54,36 +54,28 @@ class Ponto():
|
|||
def update(self):
|
||||
rx = random(-0.5, 0.5)
|
||||
ry = random(-0.5, 0.5)
|
||||
if abs(self.px + rx - self.x) < Ponto.spacing * .5:
|
||||
if abs(self.px + rx - self.x) < Ponto.spacing * .25:
|
||||
self.px += rx
|
||||
if abs(self.py + ry - self.y) < Ponto.spacing * .5:
|
||||
self.py += ry
|
||||
if self.link_count > 8:
|
||||
self.link_count = 8
|
||||
if self.link_count < 0:
|
||||
self.link_count = 0
|
||||
|
||||
if abs(self.py + ry - self.y) < Ponto.spacing * .25:
|
||||
self.py += ry
|
||||
self.plot()
|
||||
|
||||
def plot(self):
|
||||
self.link_count = 0
|
||||
for p in self.ngb:
|
||||
d = dist(p.px, p.py, self.px, self.py)
|
||||
if Ponto.spacing * .9 < d <= Ponto.spacing * 1.2:
|
||||
self.link_count += 1
|
||||
elif d < Ponto.spacing * 0.9:
|
||||
self.link_count += 1
|
||||
else:
|
||||
self.link_count -= 1
|
||||
for p in self.ngb:
|
||||
if p.link_count + self.link_count > 3:
|
||||
if p in self.dia_ngb:
|
||||
stroke(0, 0, 255)
|
||||
else:
|
||||
if p in self.ort_ngb and d > Ponto.spacing * 1:
|
||||
stroke(0, 150, 0)
|
||||
line(p.px, p.py, self.px, self.py)
|
||||
line(p.px, p.py, self.px, self.py)
|
||||
self.link_count += 1
|
||||
elif p in self.dia_ngb and d > Ponto.spacing * 1.45:
|
||||
stroke(0, 0, 255)
|
||||
line(p.px, p.py, self.px, self.py)
|
||||
self.link_count += 1
|
||||
|
||||
if dist(mouseX, mouseY, self.x, self.y) < Ponto.spacing * 2:
|
||||
fill(255)
|
||||
textSize(6)
|
||||
textSize(8)
|
||||
text(str(self.link_count), self.x, self.y)
|
||||
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue