diff options
| author | Brianna Rainey | 2026-01-28 17:49:58 -0500 |
|---|---|---|
| committer | GitHub | 2026-01-28 17:49:58 -0500 |
| commit | f66eb99465c61232a7f649e66bee59504bb0e52c (patch) | |
| tree | 40d4f2e4e7cea033e4a68da025c7d91295e71cfb /src/avp/components/life.py | |
| parent | 864898419e810055b51e3a32fccb00a62aab9a6b (diff) | |
v2.2.1 - fix #74, fix #92, add optional 64th bar to Classic Visualizer, improve Conway default (#93)
* update gitignore
ignore profiling and coverage data
* F1 opens help window, create appName variable, move undostack class
* fix kaleidoscope effect, increase default Y values by +4
the increased y values allow the cells to continue animating for more than 60 minutes instead of 30 (at default 60f/t)
* update version number
* add minimumWidth to undo history window
* Classic Visualizer: option to include 64th bar
* Waveform component: fix #74 - new animation speed option
* move shared visualizer code into toolkit
* Waveform component: compress audio by default
* Waveform component: fix 100% animation speed
* new components receive random color
* update to Qt 6
* fix pushbutton stylesheet
* fix #92: replace ok/cancel with save/discard/cancel
* remove obsolete PaintColor subclass
* mv common shadow code into addShadow func
* add 3rd option of ok/cancel back to showMessage
the 3 options are:
- ok
- ok/cancel
- save/discard/cancel
* Image component: add shadow option
* small test of rgbFromString
* fix color tuple string
* test another way to get comp names from CLI
* rename component tests, add some more
* Image component: scale shadow based on resolution
* catch AttributeError if previewRender returns None
* Text component: fix blur radius only able to increase
the relativeWidgets system causes QDoubleSpinbox to only allow increases, because it really only works with integeres, so I changed the blur radius into a normal QSpinBox. I noted where the problem exists within component.py for future reference. This commit also removes an unneeded VerticalLayout from the ui file
* remove unnecessary QVBoxLayout
* paste shadow at x,y instead of using offset method
* fix tests due to shadow change
* don't print warning in connectWidget due to QFontComboBox
Diffstat (limited to 'src/avp/components/life.py')
| -rw-r--r-- | src/avp/components/life.py | 103 |
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 = ( |
