kopia lustrzana https://github.com/villares/sketch-a-day
Update sketch_2020_12_26c_recursive_grid.pyde
rodzic
970fae6f3e
commit
26cbffdcda
|
|
@ -3,8 +3,6 @@ from villares import ubuntu_jogl_fix # you probably won't need this
|
|||
|
||||
from copy import deepcopy
|
||||
|
||||
ox, oy = 0, 0
|
||||
|
||||
def setup():
|
||||
global grid, other_grid
|
||||
size(640, 640, P3D)
|
||||
|
|
@ -105,29 +103,20 @@ def check_valid_cells(cells):
|
|||
return all(cell[-1] is None and cell[-2] == cw
|
||||
for cell in cells)
|
||||
|
||||
|
||||
def otranslate(x, y):
|
||||
global ox, oy
|
||||
ox += x
|
||||
oy += y
|
||||
|
||||
def rec_grid(x, y, n, tw, shallow=None):
|
||||
otranslate(x, y)
|
||||
cw = float(tw) / n
|
||||
margin = (cw - tw) / 2.0
|
||||
cells = []
|
||||
for i in range(n):
|
||||
nx = cw * i + margin
|
||||
nx = x + cw * i + margin
|
||||
for j in range(n):
|
||||
ny = cw * j + margin
|
||||
ny = y + cw * j + margin
|
||||
if cw > 8 and random(10) < 5 and not shallow:
|
||||
cs = rec_grid(nx, ny, 2, cw)
|
||||
cells.append(cs)
|
||||
else:
|
||||
cells.append((ox + nx,
|
||||
oy + ny,
|
||||
cells.append((nx, ny,
|
||||
cw - 2, None))
|
||||
otranslate(-x, -y)
|
||||
return cells
|
||||
|
||||
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue