From b77bcdc4a1dd50ce4f688bd88f166370d1b30823 Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares Date: Fri, 22 Jun 2018 10:34:04 -0300 Subject: [PATCH] shape -> dim MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NumPy usa a o termo shape para as dimensões de matrizes, isso confunde com o PShape do Processing --- s172/s172.pyde | 18 +++++++++--------- s173/s173.pyde | 22 +++++++++++----------- s174/s174.pyde | 22 +++++++++++----------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/s172/s172.pyde b/s172/s172.pyde index 52f19e22..ce4d5290 100644 --- a/s172/s172.pyde +++ b/s172/s172.pyde @@ -18,24 +18,24 @@ def draw(): rect(w/2 + w * x, h/2 + h * y, w, h) def maze(mh, mw, complexity=.01, density=10): - # Only odd shapes - shape = ((mh // 2) * 2 + 1, (mw // 2) * 2 + 1) + # Only odd dims + dim = ((mh // 2) * 2 + 1, (mw // 2) * 2 + 1) # Adjust complexity and density relative to maze size - complexity = int(complexity * (5 * (shape[0] + shape[1]))) # number of components - density = int(density * ((shape[0] // 2) * (shape[1] // 2))) # size of components + complexity = int(complexity * (5 * (dim[0] + dim[1]))) # number of components + density = int(density * ((dim[0] // 2) * (dim[1] // 2))) # size of components # Build actual maze - Z = [[0] * shape[1] for _ in range(shape[0])] + Z = [[0] * dim[1] for _ in range(dim[0])] # Make aisles for i in range(density): - x = randint(0, shape[1] // 2) * 2 - y = randint(0, shape[0] // 2) * 2 # pick a random position + x = randint(0, dim[1] // 2) * 2 + y = randint(0, dim[0] // 2) * 2 # pick a random position Z[y][x] = 1 for j in range(complexity): neighbours = [] if x > 1: neighbours.append((y, x - 2)) - if x < shape[1] - 2: neighbours.append((y, x + 2)) + if x < dim[1] - 2: neighbours.append((y, x + 2)) if y > 1: neighbours.append((y - 2, x)) - if y < shape[0] - 2: neighbours.append((y + 2, x)) + if y < dim[0] - 2: neighbours.append((y + 2, x)) if len(neighbours): y_,x_ = neighbours[randint(0, len(neighbours) - 1)] if Z[y_][x_] == 0: diff --git a/s173/s173.pyde b/s173/s173.pyde index 25e691ce..4458dec9 100644 --- a/s173/s173.pyde +++ b/s173/s173.pyde @@ -3,16 +3,16 @@ from random import randint def setup(): - global m, shape, Z, C + global m, dim, Z, C size(400, 400) rectMode(CENTER) colorMode(HSB) noLoop() noStroke() - # Only odd shapes - shape = ((101 // 2) * 2 + 1, (101 // 2) * 2 + 1) - Z = [[0] * shape[1] for _ in range(shape[0])] - C = [[0] * shape[1] for _ in range(shape[0])] + # Only odd dims + dim = ((101 // 2) * 2 + 1, (101 // 2) * 2 + 1) + Z = [[0] * dim[1] for _ in range(dim[0])] + C = [[0] * dim[1] for _ in range(dim[0])] m = maze(101,101) w, h = 4, 4 for x in range(len(m)): @@ -23,21 +23,21 @@ def setup(): def maze(mh, mw, complexity=.51, density=2): # Adjust complexity and density relative to maze size - complexity = int(complexity * (5 * (shape[0] + shape[1]))) # number of components - density = int(density * ((shape[0] // 2) * (shape[1] // 2))) # size of components + complexity = int(complexity * (5 * (dim[0] + dim[1]))) # number of components + density = int(density * ((dim[0] // 2) * (dim[1] // 2))) # size of components # Build actual maze # Make aisles for i in range(density): - x = randint(0, shape[1] // 2) * 2 - y = randint(0, shape[0] // 2) * 2 # pick a random position + x = randint(0, dim[1] // 2) * 2 + y = randint(0, dim[0] // 2) * 2 # pick a random position Z[y][x] = 1 for j in range(complexity): neighbours = [] if x > 1: neighbours.append((y, x - 2)) - if x < shape[1] - 2: neighbours.append((y, x + 2)) + if x < dim[1] - 2: neighbours.append((y, x + 2)) if y > 1: neighbours.append((y - 2, x)) - if y < shape[0] - 2: neighbours.append((y + 2, x)) + if y < dim[0] - 2: neighbours.append((y + 2, x)) if len(neighbours): y_,x_ = neighbours[randint(0, len(neighbours) - 1)] if Z[y_][x_] == 0: diff --git a/s174/s174.pyde b/s174/s174.pyde index 6fde2358..a5be472e 100644 --- a/s174/s174.pyde +++ b/s174/s174.pyde @@ -3,16 +3,16 @@ from random import randint def setup(): - global m, shape, Z, C + global m, dim, Z, C size(800, 800) rectMode(CENTER) colorMode(HSB) noLoop() noStroke() - # Only odd shapes - shape = ((101 // 2) * 2 + 1, (101 // 2) * 2 + 1) - Z = [[0] * shape[1] for _ in range(shape[0])] - C = [[0] * shape[1] for _ in range(shape[0])] + # Only odd dims + dim = ((101 // 2) * 2 + 1, (101 // 2) * 2 + 1) + Z = [[0] * dim[1] for _ in range(dim[0])] + C = [[0] * dim[1] for _ in range(dim[0])] m = maze(101,101) w, h = 8, 8 for x in range(len(m)): @@ -24,21 +24,21 @@ def setup(): def maze(mh, mw, complexity=.51, density=2): # Adjust complexity and density relative to maze size - complexity = int(complexity * (5 * (shape[0] + shape[1]))) # number of components - density = int(density * ((shape[0] // 2) * (shape[1] // 2))) # size of components + complexity = int(complexity * (5 * (dim[0] + dim[1]))) # number of components + density = int(density * ((dim[0] // 2) * (dim[1] // 2))) # size of components # Build actual maze # Make aisles for i in range(density): - x = randint(0, shape[1] // 2) * 2 - y = randint(0, shape[0] // 2) * 2 # pick a random position + x = randint(0, dim[1] // 2) * 2 + y = randint(0, dim[0] // 2) * 2 # pick a random position Z[y][x] = 1 for j in range(complexity): neighbours = [] if x > 1: neighbours.append((y, x - 2)) - if x < shape[1] - 2: neighbours.append((y, x + 2)) + if x < dim[1] - 2: neighbours.append((y, x + 2)) if y > 1: neighbours.append((y - 2, x)) - if y < shape[0] - 2: neighbours.append((y + 2, x)) + if y < dim[0] - 2: neighbours.append((y + 2, x)) if len(neighbours): y_,x_ = neighbours[randint(0, len(neighbours) - 1)] if Z[y_][x_] == 0: