diff options
| author | tassaron | 2026-01-11 14:29:58 -0500 |
|---|---|---|
| committer | tassaron | 2026-01-11 14:29:58 -0500 |
| commit | 669756b391d26661cf2e2a97a304e73343ef6655 (patch) | |
| tree | 9cf2d4858c209bdab9f44d5c7f95c2a30b37f7a6 /src/components/color.py | |
| parent | 9d45f7f1a986aaa5d3c084c7ae747442b94a61b1 (diff) | |
update to Qt 6 and Pillow 12
and yeah, I accidentally ran black on the codebase. I don't want to spend more free time fixing that. All of these changes are simple renames or removals, nothing too major.
Diffstat (limited to 'src/components/color.py')
| -rw-r--r-- | src/components/color.py | 136 |
1 files changed, 76 insertions, 60 deletions
diff --git a/src/components/color.py b/src/components/color.py index 8d0edd2..1f32c23 100644 --- a/src/components/color.py +++ b/src/components/color.py @@ -1,16 +1,16 @@ -from PyQt5 import QtGui +from PyQt6 import QtGui import logging from ..component import Component from ..toolkit.frame import BlankFrame, FloodFrame, FramePainter, PaintColor -log = logging.getLogger('AVP.Components.Color') +log = logging.getLogger("AVP.Components.Color") class Component(Component): - name = 'Color' - version = '1.0.0' + name = "Color" + version = "1.0.0" def widget(self, *args): self.x = 0 @@ -20,48 +20,56 @@ class Component(Component): # disable color #2 until non-default 'fill' option gets changed self.page.lineEdit_color2.setDisabled(True) self.page.pushButton_color2.setDisabled(True) - self.page.spinBox_width.setValue( - int(self.settings.value("outputWidth"))) - self.page.spinBox_height.setValue( - int(self.settings.value("outputHeight"))) + self.page.spinBox_width.setValue(int(self.settings.value("outputWidth"))) + self.page.spinBox_height.setValue(int(self.settings.value("outputHeight"))) self.fillLabels = [ - 'Solid', - 'Linear Gradient', - 'Radial Gradient', + "Solid", + "Linear Gradient", + "Radial Gradient", ] for label in self.fillLabels: self.page.comboBox_fill.addItem(label) self.page.comboBox_fill.setCurrentIndex(0) - self.trackWidgets({ - 'x': self.page.spinBox_x, - 'y': self.page.spinBox_y, - 'sizeWidth': self.page.spinBox_width, - 'sizeHeight': self.page.spinBox_height, - 'trans': self.page.checkBox_trans, - 'spread': self.page.comboBox_spread, - 'stretch': self.page.checkBox_stretch, - 'RG_start': self.page.spinBox_radialGradient_start, - 'LG_start': self.page.spinBox_linearGradient_start, - 'RG_end': self.page.spinBox_radialGradient_end, - 'LG_end': self.page.spinBox_linearGradient_end, - 'RG_centre': self.page.spinBox_radialGradient_spread, - 'fillType': self.page.comboBox_fill, - 'color1': self.page.lineEdit_color1, - 'color2': self.page.lineEdit_color2, - }, presetNames={ - 'sizeWidth': 'width', - 'sizeHeight': 'height', - }, colorWidgets={ - 'color1': self.page.pushButton_color1, - 'color2': self.page.pushButton_color2, - }, relativeWidgets=[ - 'x', 'y', - 'sizeWidth', 'sizeHeight', - 'LG_start', 'LG_end', - 'RG_start', 'RG_end', 'RG_centre', - ]) + self.trackWidgets( + { + "x": self.page.spinBox_x, + "y": self.page.spinBox_y, + "sizeWidth": self.page.spinBox_width, + "sizeHeight": self.page.spinBox_height, + "trans": self.page.checkBox_trans, + "spread": self.page.comboBox_spread, + "stretch": self.page.checkBox_stretch, + "RG_start": self.page.spinBox_radialGradient_start, + "LG_start": self.page.spinBox_linearGradient_start, + "RG_end": self.page.spinBox_radialGradient_end, + "LG_end": self.page.spinBox_linearGradient_end, + "RG_centre": self.page.spinBox_radialGradient_spread, + "fillType": self.page.comboBox_fill, + "color1": self.page.lineEdit_color1, + "color2": self.page.lineEdit_color2, + }, + presetNames={ + "sizeWidth": "width", + "sizeHeight": "height", + }, + colorWidgets={ + "color1": self.page.pushButton_color1, + "color2": self.page.pushButton_color2, + }, + relativeWidgets=[ + "x", + "y", + "sizeWidth", + "sizeHeight", + "LG_start", + "LG_end", + "RG_start", + "RG_end", + "RG_centre", + ], + ) def update(self): fillType = self.page.comboBox_fill.currentIndex() @@ -86,7 +94,7 @@ class Component(Component): return self.drawFrame(self.width, self.height) def properties(self): - return ['static'] + return ["static"] def frameRender(self, frameNo): log.debug("Color component is drawing frame #%s", frameNo) @@ -96,8 +104,12 @@ class Component(Component): r, g, b = self.color1 shapeSize = (self.sizeWidth, self.sizeHeight) # in default state, skip all this logic and return a plain fill - if self.fillType == 0 and shapeSize == (width, height) \ - and self.x == 0 and self.y == 0: + if ( + self.fillType == 0 + and shapeSize == (width, height) + and self.x == 0 + and self.y == 0 + ): return FloodFrame(width, height, (r, g, b, 255)) # Return a solid image at x, y @@ -120,19 +132,26 @@ class Component(Component): if self.fillType == 1: # Linear Gradient brush = QtGui.QLinearGradient( - self.LG_start, - self.LG_start, - self.LG_end+width/3, - self.LG_end) + float(self.LG_start), + float(self.LG_start), + float(self.LG_end + width / 3), + float(self.LG_end), + ) elif self.fillType == 2: # Radial Gradient brush = QtGui.QRadialGradient( - self.RG_start, - self.RG_end, - w, h, - self.RG_centre) - - brush.setSpread(self.spread) + float(self.RG_start), + float(self.RG_end), + float(w), + float(h), + float(self.RG_centre), + ) + spread = QtGui.QGradient.Spread.PadSpread + if self.spread == 1: + spread = QtGui.QGradient.Spread.ReflectSpread + elif self.spread == 2: + spread = QtGui.QGradient.Spread.RepeatSpread + brush.setSpread(spread) brush.setColorAt(0.0, PaintColor(*self.color1)) if self.trans: brush.setColorAt(1.0, PaintColor(0, 0, 0, 0)) @@ -141,20 +160,17 @@ class Component(Component): else: brush.setColorAt(1.0, PaintColor(*self.color2)) image.setBrush(brush) - image.drawRect( - self.x, self.y, - self.sizeWidth, self.sizeHeight - ) + image.drawRect(self.x, self.y, self.sizeWidth, self.sizeHeight) return image.finalize() def commandHelp(self): - print('Specify a color:\n color=255,255,255') + print("Specify a color:\n color=255,255,255") def command(self, arg): - if '=' in arg: - key, arg = arg.split('=', 1) - if key == 'color': + if "=" in arg: + key, arg = arg.split("=", 1) + if key == "color": self.page.lineEdit_color1.setText(arg) return super().command(arg) |
