diff options
| author | Brianna Rainey | 2023-02-17 16:02:13 -0500 |
|---|---|---|
| committer | Brianna Rainey | 2023-02-17 16:02:13 -0500 |
| commit | 20090784f816e49a23e637f4c47f193c0210beca (patch) | |
| tree | 7e97b7756577a66fa16f7b11afbfbe3d6431407e /src | |
| parent | 622291e7aeecd0211b4fc91a6df8051d2650d664 (diff) | |
ignore cells that are 40+ coords out of frame
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/life.py | 11 |
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): (23, 6), (23, 7), (24, 6), (24, 7) ]) + + # Amount of 'bleed' (off-canvas coordinates) on each side of the grid + self.bleedSize = 40 + self.page.pushButton_pickImage.clicked.connect(self.pickImage) self.trackWidgets({ 'tickRate': self.page.spinBox_tickRate, @@ -370,7 +374,14 @@ class Component(Component): newGrid = set() # Copy cells from the previous grid if they have 2 or 3 neighbouring cells + # and if they are within the grid or its bleed area (off-canvas area) for x, y in lastGrid: + if ( + -self.bleedSize > x > self.gridWidth + self.bleedSize + or + -self.bleedSize > y > self.gridHeight + self.bleedSize + ): + continue surrounding = len(neighbours(x, y)) if surrounding == 2 or surrounding == 3: newGrid.add((x, y)) |
