kopia lustrzana https://github.com/villares/sketch-a-day
main
rodzic
573541e9d7
commit
197a8b4090
|
@ -5,8 +5,6 @@ NODE_SIZE = 5
|
||||||
nodes, edges = [], set()
|
nodes, edges = [], set()
|
||||||
|
|
||||||
# NGBS = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
|
# NGBS = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)]
|
||||||
# ONGBS = [(-1, 0), (0, 1), (0, -1), (1, 0), (-1, -1)]
|
|
||||||
|
|
||||||
ONGBS = [(0, 1), (1, 0), (0, -1), (-1, 0), (-1, -1)]
|
ONGBS = [(0, 1), (1, 0), (0, -1), (-1, 0), (-1, -1)]
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,16 +16,9 @@ def setup():
|
||||||
imagem = draw_text('PCD', 250, 240, text_size=180)
|
imagem = draw_text('PCD', 250, 240, text_size=180)
|
||||||
grid = make_grid(imagem, width, height, 10, margin=20)
|
grid = make_grid(imagem, width, height, 10, margin=20)
|
||||||
|
|
||||||
for _ in range(len(grid)):
|
|
||||||
add_connected(ONGBS)
|
|
||||||
|
|
||||||
def draw():
|
def draw():
|
||||||
background(170, 170, 200)
|
background(170, 170, 200)
|
||||||
|
|
||||||
for i, j in nodes:
|
|
||||||
x, y, c = grid[(i, j)]
|
|
||||||
fill(c)
|
|
||||||
# circle(x, y, NODE_SIZE)
|
|
||||||
for a, b in edges:
|
for a, b in edges:
|
||||||
noFill()
|
noFill()
|
||||||
x0, y0, c1 = grid[a]
|
x0, y0, c1 = grid[a]
|
||||||
|
@ -46,8 +37,7 @@ def keyPressed():
|
||||||
add_random_node()
|
add_random_node()
|
||||||
if key == 's':
|
if key == 's':
|
||||||
saveFrame("s####.png")
|
saveFrame("s####.png")
|
||||||
# if key == 'm':
|
|
||||||
# add_connected(NGBS)
|
|
||||||
|
|
||||||
def add_connected(nbs):
|
def add_connected(nbs):
|
||||||
if nodes:
|
if nodes:
|
||||||
|
@ -65,7 +55,6 @@ def add_connected(nbs):
|
||||||
nodes[:] = [nodes[-1]] + nodes[:-1]
|
nodes[:] = [nodes[-1]] + nodes[:-1]
|
||||||
println("ops!")
|
println("ops!")
|
||||||
|
|
||||||
|
|
||||||
def add_random_node():
|
def add_random_node():
|
||||||
if len(nodes) < len(grid):
|
if len(nodes) < len(grid):
|
||||||
k = choice(grid.keys())
|
k = choice(grid.keys())
|
||||||
|
@ -73,7 +62,6 @@ def add_random_node():
|
||||||
k = choice(grid.keys())
|
k = choice(grid.keys())
|
||||||
nodes.append(k)
|
nodes.append(k)
|
||||||
|
|
||||||
|
|
||||||
def draw_text(txt, x, y, text_size=120):
|
def draw_text(txt, x, y, text_size=120):
|
||||||
img = createGraphics(width, height)
|
img = createGraphics(width, height)
|
||||||
img.beginDraw()
|
img.beginDraw()
|
||||||
|
@ -95,8 +83,6 @@ def make_grid(p_graphics, w, h, s, margin=None):
|
||||||
for j in range(rows):
|
for j in range(rows):
|
||||||
y = off + j * s + margin
|
y = off + j * s + margin
|
||||||
bc = p_graphics.get(x, y)
|
bc = p_graphics.get(x, y)
|
||||||
# if bc != 0:
|
|
||||||
points[(i, j)] = (x, y, bc)
|
points[(i, j)] = (x, y, bc)
|
||||||
# else:
|
|
||||||
# points[(i, j)] = (x, y, 255)
|
|
||||||
return points
|
return points
|
||||||
|
|
Ładowanie…
Reference in New Issue