diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/__base__.py | 11 | ||||
| -rw-r--r-- | components/color.py | 18 | ||||
| -rw-r--r-- | components/video.py | 12 |
3 files changed, 24 insertions, 17 deletions
diff --git a/components/__base__.py b/components/__base__.py index bef7f0e..a29d775 100644 --- a/components/__base__.py +++ b/components/__base__.py @@ -39,7 +39,7 @@ class Component(QtCore.QObject): then update self.page widgets using the preset dict. ''' self.currentPreset = presetName \ - if presetName != None else presetDict['preset'] + if presetName is not None else presetDict['preset'] def preFrameRender(self, **kwargs): '''Triggered only before a video is exported (video_thread.py) @@ -66,8 +66,9 @@ class Component(QtCore.QObject): print('Couldn\'t locate preset "%s"' % preset) quit(1) else: - print('Opening "%s" preset on layer %s' % \ - (preset, self.compPos)) + print('Opening "%s" preset on layer %s' % ( + preset, self.compPos) + ) self.core.openPreset(path, self.compPos, preset) else: print( @@ -142,10 +143,10 @@ class Component(QtCore.QObject): return image ''' + class BadComponentInit(Exception): def __init__(self, arg, name): - string = \ -'''################################ + string = '''################################ Mandatory argument "%s" not specified in %s instance initialization ###################################''' diff --git a/components/color.py b/components/color.py index 5ffcdea..3b73458 100644 --- a/components/color.py +++ b/components/color.py @@ -53,7 +53,7 @@ class Component(__base__.Component): page.spinBox_height.valueChanged.connect(self.update) page.checkBox_trans.stateChanged.connect(self.update) - self.fillLabels = [ \ + self.fillLabels = [ 'Solid', 'Linear Gradient', 'Radial Gradient', @@ -126,8 +126,8 @@ class Component(__base__.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 Image.new("RGBA", (width, height), (r, g, b, 255)) frame = self.blankFrame(width, height) @@ -143,9 +143,11 @@ class Component(__base__.Component): image = ImageQt(frame) painter = QtGui.QPainter(image) if self.stretch: - w = width; h = height + w = width + h = height else: - w = self.sizeWidth; h = self.sizeWidth + w = self.sizeWidth + h = self.sizeWidth if self.fillType == 1: # Linear Gradient brush = QtGui.QLinearGradient( @@ -170,8 +172,10 @@ class Component(__base__.Component): else: brush.setColorAt(1.0, QColor(*self.color2)) painter.setBrush(brush) - painter.drawRect(self.x, self.y, - self.sizeWidth, self.sizeHeight) + painter.drawRect( + self.x, self.y, + self.sizeWidth, self.sizeHeight + ) painter.end() imBytes = image.bits().asstring(image.numBytes()) return Image.frombytes('RGBA', (width, height), imBytes) diff --git a/components/video.py b/components/video.py index 1d250bd..4fced4e 100644 --- a/components/video.py +++ b/components/video.py @@ -41,8 +41,8 @@ class Video: '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % - scale(self.scale, self.width, self.height, str), + '-filter:v', 'scale=%s:%s' % scale( + self.scale, self.width, self.height, str), '-vcodec', 'rawvideo', '-', ] @@ -199,8 +199,8 @@ class Component(__base__.Component): '-i', self.videoPath, '-f', 'image2pipe', '-pix_fmt', 'rgba', - '-filter:v', 'scale=%s:%s' % - scale(self.scale, width, height, str), + '-filter:v', 'scale=%s:%s' % scale( + self.scale, width, height, str), '-vcodec', 'rawvideo', '-', '-ss', '90', '-vframes', '1', @@ -238,6 +238,7 @@ class Component(__base__.Component): def commandHelp(self): print('Load a video:\n path=/filepath/to/video.mp4') + def scale(scale, width, height, returntype=None): width = (float(width) / 100.0) * float(scale) height = (float(height) / 100.0) * float(scale) @@ -248,6 +249,7 @@ def scale(scale, width, height, returntype=None): else: return (width, height) + def finalizeFrame(self, imageData, width, height): if self.distort: try: @@ -265,7 +267,7 @@ def finalizeFrame(self, imageData, width, height): imageData) if self.scale != 100 \ - or self.xPosition != 0 or self.yPosition != 0: + or self.xPosition != 0 or self.yPosition != 0: frame = self.blankFrame(width, height) frame.paste(image, box=(self.xPosition, self.yPosition)) else: |
