summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrianna Rainey2023-02-17 16:02:13 -0500
committerBrianna Rainey2023-02-17 16:02:13 -0500
commit20090784f816e49a23e637f4c47f193c0210beca (patch)
tree7e97b7756577a66fa16f7b11afbfbe3d6431407e
parent622291e7aeecd0211b4fc91a6df8051d2650d664 (diff)
ignore cells that are 40+ coords out of frame
-rw-r--r--src/components/life.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/components/life.py b/src/components/life.py
index 3a5276f..a2a3a30 100644
--- a/src/components/life.py
+++ b/src/components/life.py
@@ -29,6 +29,10 @@ class Component(Component):
29 (23, 6), (23, 7), 29 (23, 6), (23, 7),
30 (24, 6), (24, 7) 30 (24, 6), (24, 7)
31 ]) 31 ])
32
33 # Amount of 'bleed' (off-canvas coordinates) on each side of the grid
34 self.bleedSize = 40
35
32 self.page.pushButton_pickImage.clicked.connect(self.pickImage) 36 self.page.pushButton_pickImage.clicked.connect(self.pickImage)
33 self.trackWidgets({ 37 self.trackWidgets({
34 'tickRate': self.page.spinBox_tickRate, 38 'tickRate': self.page.spinBox_tickRate,
@@ -370,7 +374,14 @@ class Component(Component):
370 374
371 newGrid = set() 375 newGrid = set()
372 # Copy cells from the previous grid if they have 2 or 3 neighbouring cells 376 # Copy cells from the previous grid if they have 2 or 3 neighbouring cells
377 # and if they are within the grid or its bleed area (off-canvas area)
373 for x, y in lastGrid: 378 for x, y in lastGrid:
379 if (
380 -self.bleedSize > x > self.gridWidth + self.bleedSize
381 or
382 -self.bleedSize > y > self.gridHeight + self.bleedSize
383 ):
384 continue
374 surrounding = len(neighbours(x, y)) 385 surrounding = len(neighbours(x, y))
375 if surrounding == 2 or surrounding == 3: 386 if surrounding == 2 or surrounding == 3:
376 newGrid.add((x, y)) 387 newGrid.add((x, y))