Skip to content

Commit

Permalink
9
Browse files Browse the repository at this point in the history
  • Loading branch information
villares committed Jan 10, 2025
1 parent 2287b57 commit 78e8b82
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 31 deletions.
Binary file added 2025/sketch_2025_01_09/sketch_2025_01_09.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 29 additions & 31 deletions 2025/sketch_2025_01_09/sketch_2025_01_09.py
Original file line number Diff line number Diff line change
@@ -1,58 +1,56 @@
import numpy as np

cols = 100
filas = 100
matrix = np.zeros((100, 100), dtype=int) #[[0] * cols for _ in range(filas)]
# to implement and idea stolen from Carlos @vamoss
c_matrix = np.zeros((100, 100), dtype=int)

geracao = 0
regras_legais = [ # Algumas regras de que gostamos
[1, 0, 1, 1, 1, 1, 1, 0], # Regra 125
[1, 0, 0, 1, 0, 1, 0, 1], # Regra 169
[0, 1, 1, 1, 1, 0, 0, 0], # Regra 30
[0, 1, 1, 1, 0, 1, 1, 0], # Regra 110
rows = 100
matrix = np.zeros((100, 100), dtype=int)
c_matrix = np.zeros((100, 100), dtype=int) # to implement and idea stolen from Carlos @vamoss
gen = 0
nice_rules = [ # Some rules we like
[1, 0, 1, 1, 1, 1, 1, 0], # rule 125
[1, 0, 0, 1, 0, 1, 0, 1], # rule 169
[0, 1, 1, 1, 1, 0, 0, 0], # rule 30
[0, 1, 1, 1, 0, 1, 1, 0], # rule 110
]
ruleset = regras_legais[3]

ruleset = nice_rules[2]

def setup():
size(800, 800)
no_smooth()
no_stroke()

matrix[cols // 2][0] = 1 # Começa com "1" no meio da 1ª linha
matrix[cols // 2, 0] = 1 # Começa com "1" no meio da 1ª linha
frame_rate(10)



def draw():
background(200)
scale(8)
offset = geracao % filas
offset = gen % rows
for i in range(cols):
for j in range(filas):
for j in range(rows):
y = j - offset
if y <= 0:
y = filas + y
if matrix[i][j] == 1: # Se a célula i, está viva/ativa/1
stroke(c_matrix[i][j])# stroke(c_matrix[i][j])
y = rows + y
if matrix[i, j] == 1: # Se a célula i, está viva/ativa/1
stroke(c_matrix[i, j])# stroke(c_matrix[i, j])
else:
stroke(200)
point(i, y - 1)

nova_geracao()
new_gen()

def nova_geracao():
global geracao
def new_gen():
global gen
for i in range(cols):
esq = matrix[(i + cols - 1) % cols][geracao % filas]
centro = matrix[i][geracao % filas]
dir = matrix[(i + 1) % cols][geracao % filas]
result = ruleset[esq * 4 + centro * 2 + dir * 1]
cor = color(55 + esq * 100, 55 + centro * 100, 55 + dir * 100)
matrix[i][(geracao + 1) % filas] = result
c_matrix[i][(geracao + 1) % filas] = cor
geracao += 1
left = matrix[(i + cols - 1) % cols, gen % rows]
centre = matrix[i, gen % rows]
right = matrix[(i + 1) % cols, gen % rows]
result = ruleset[left * 4 + centre * 2 + right * 1]
cor = color(55 + left * 100, 55 + centre * 100, 55 + right * 100)
matrix[i, (gen + 1) % rows] = result
c_matrix[i, (gen + 1) % rows] = cor
gen += 1


def key_pressed():
save_frame('####.png')
10 changes: 10 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ If you appreciate what I have been doing, you may also support my artistic work,
2025 \| [<b>2024</b>](2024.md) \| [<b>2023</b>](2023.md) \| [<b>2022</b>](2022.md) \| [<b>2021</b>](2021.md) \| [<b>2020</b>](2020.md) \| [<b>2019</b>](2019.md) \| [<b>2018</b>](2018.md)


---

### sketch_2025_01_09

![sketch_2025_01_09](https://raw.githubusercontent.com/villares/sketch-a-day/main/2025/sketch_2025_01_09/sketch_2025_01_09.png)

[sketch_2025_01_09](https://github.com/villares/sketch-a-day/tree/main/2025/sketch_2025_01_09) [[py5](https://py5coding.org/)]

I'd love to see Wolfram's "rule 30" on my bus seats! #genuary9 #genuary2025

---

### sketch_2025_01_08
Expand Down

0 comments on commit 78e8b82

Please sign in to comment.