aboutsummaryrefslogtreecommitdiff
path: root/src/avp/components/life.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/avp/components/life.py')
-rw-r--r--src/avp/components/life.py103
1 files changed, 37 insertions, 66 deletions
diff --git a/src/avp/components/life.py b/src/avp/components/life.py
index 9e5e202..a062617 100644
--- a/src/avp/components/life.py
+++ b/src/avp/components/life.py
@@ -8,8 +8,8 @@ import logging
from ..component import Component
-from ..toolkit.frame import BlankFrame, scale
-from .original import Component as Visualizer
+from ..toolkit.frame import BlankFrame, scale, addShadow
+from ..toolkit.visualizer import createSpectrumArray
log = logging.getLogger("AVP.Component.Life")
@@ -17,7 +17,7 @@ log = logging.getLogger("AVP.Component.Life")
class Component(Component):
name = "Conway's Game of Life"
- version = "2.0.0"
+ version = "2.0.1"
def widget(self, *args):
super().widget(*args)
@@ -27,26 +27,26 @@ class Component(Component):
# https://conwaylife.com/wiki/Queen_bee_shuttle
self.startingGrid = set(
[
- (3, 7),
- (3, 8),
- (4, 7),
- (4, 8),
- (8, 7),
- (9, 6),
- (9, 8),
- (10, 5),
+ (3, 11),
+ (3, 12),
+ (4, 11),
+ (4, 12),
+ (8, 11),
+ (9, 10),
+ (9, 12),
(10, 9),
- (11, 6),
- (11, 7),
- (11, 8),
- (12, 4),
- (12, 5),
+ (10, 13),
+ (11, 10),
+ (11, 11),
+ (11, 12),
+ (12, 8),
(12, 9),
- (12, 10),
- (23, 6),
- (23, 7),
- (24, 6),
- (24, 7),
+ (12, 13),
+ (12, 14),
+ (23, 10),
+ (23, 11),
+ (24, 10),
+ (24, 11),
]
)
@@ -163,41 +163,27 @@ class Component(Component):
def previewRender(self):
image = self.drawGrid(self.startingGrid, self.color)
image = self.addKaleidoscopeEffect(image)
- image = self.addShadow(image)
+ if self.shadow:
+ image = addShadow(image, 5.00, -2, 2)
image = self.addGridLines(image)
return image
def preFrameRender(self, *args, **kwargs):
super().preFrameRender(*args, **kwargs)
self.tickGrids = {0: self.startingGrid}
-
- smoothConstantDown = 0.08 + 0
- smoothConstantUp = 0.8 - 0
- self.lastSpectrum = None
- self.spectrumArray = {}
if self.sensitivity == 0:
return
- for i in range(0, len(self.completeAudioArray), self.sampleSize):
- if self.canceled:
- break
- self.lastSpectrum = Visualizer.transformData(
- i,
- self.completeAudioArray,
- self.sampleSize,
- smoothConstantDown,
- smoothConstantUp,
- self.lastSpectrum,
- self.sensitivity,
- )
- self.spectrumArray[i] = copy(self.lastSpectrum)
-
- progress = int(100 * (i / len(self.completeAudioArray)))
- if progress >= 100:
- progress = 100
- pStr = "Analyzing audio: " + str(progress) + "%"
- self.progressBarSetText.emit(pStr)
- self.progressBarUpdate.emit(int(progress))
+ self.spectrumArray = createSpectrumArray(
+ self,
+ self.completeAudioArray,
+ self.sampleSize,
+ 0.08,
+ 0.8,
+ 20,
+ self.progressBarUpdate,
+ self.progressBarSetText,
+ )
def properties(self):
if self.customImg and (not self.image or not os.path.exists(self.image)):
@@ -256,21 +242,11 @@ class Component(Component):
if not self.customImg:
image = Image.alpha_composite(previousGridImage, image)
image = self.addKaleidoscopeEffect(image)
- image = self.addShadow(image)
+ if self.shadow:
+ image = addShadow(image, 5.00, -2, 2)
image = self.addGridLines(image)
return image
- def addShadow(self, frame):
- if not self.shadow:
- return frame
-
- shadImg = ImageEnhance.Contrast(frame).enhance(0.0)
- shadImg = shadImg.filter(ImageFilter.GaussianBlur(5.00))
- shadImg = ImageChops.offset(shadImg, -2, 2)
- shadImg.paste(frame, box=(0, 0), mask=frame)
- frame = shadImg
- return frame
-
def addGridLines(self, frame):
if not self.showGrid:
return frame
@@ -299,11 +275,6 @@ class Component(Component):
flippedImage = frame.transpose(Image.Transpose.FLIP_LEFT_RIGHT)
frame.paste(flippedImage, (0, 0), mask=flippedImage)
- flippedImage = frame.transpose(Image.Transpose.ROTATE_90)
- frame.paste(flippedImage, (0, 0), mask=flippedImage)
-
- flippedImage = frame.transpose(Image.Transpose.ROTATE_270)
- frame.paste(flippedImage, (0, 0), mask=flippedImage)
return frame
def drawGrid(self, grid, color, spectrumData=None, didntChange=None):
@@ -506,10 +477,10 @@ class Component(Component):
for x, y in grid:
drawPtX = x * self.pxWidth
- if drawPtX > self.width:
+ if drawPtX > self.width or drawPtX + self.pxWidth < 0:
continue
drawPtY = y * self.pxHeight
- if drawPtY > self.height:
+ if drawPtY > self.height or drawPtY + self.pxHeight < 0:
continue
audioMorphWidth = (