From 11cc2879e02e14e7e2db81de32ff8b25cac3a321 Mon Sep 17 00:00:00 2001 From: "Alexander G. Morano" Date: Sun, 23 Jun 2024 09:48:59 -0700 Subject: [PATCH] formatting pass --- core/calc.py | 28 ++++++------ core/compose.py | 20 ++++----- core/create.py | 12 ++--- core/device_stream.py | 6 +-- core/utility.py | 2 +- sup/anim.py | 28 ++++++------ sup/audio.py | 2 +- sup/image.py | 102 +++++++++++++++++++++--------------------- sup/midi.py | 2 +- sup/text.py | 8 ++-- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/core/calc.py b/core/calc.py index 95777d3..7eb0b6f 100644 --- a/core/calc.py +++ b/core/calc.py @@ -570,8 +570,8 @@ def INPUT_TYPES(cls) -> dict: Lexicon.IN_A: (WILDCARD, {"tooltip": "Custom Start Point"}), Lexicon.IN_B: (WILDCARD, {"tooltip": "Custom End Point"}), Lexicon.FLOAT: ("FLOAT", {"default": 0., "min": 0., "max": 1.0, - "step": 0.001, "precision": 4, "round": 0.00001, - "tooltip": "Blend Amount. 0 = full A, 1 = full B"}), + "step": 0.001, "precision": 4, "round": 0.00001, + "tooltip": "Blend Amount. 0 = full A, 1 = full B"}), Lexicon.EASE: (["NONE"] + EnumEase._member_names_, {"default": "NONE"}), Lexicon.TYPE: (names_convert, {"default": names_convert[2], "tooltip":"Output type desired from resultant operation"}), @@ -796,17 +796,17 @@ def INPUT_TYPES(cls) -> dict: Lexicon.IN_A: (WILDCARD, {"default": None, "tooltip":"Passes a raw value directly, or supplies defaults for any value inputs without connections"}), Lexicon.TYPE: (typ, {"default": EnumConvertType.BOOLEAN.name}), Lexicon.X: (WILDCARD, {"default": 0, "min": -sys.maxsize, - "max": sys.maxsize, "step": 0.01, "precision": 6, - "forceInput": True}), + "max": sys.maxsize, "step": 0.01, "precision": 6, + "forceInput": True}), Lexicon.Y: (WILDCARD, {"default": 0, "min": -sys.maxsize, - "max": sys.maxsize, "step": 0.01, "precision": 6, - "forceInput": True}), + "max": sys.maxsize, "step": 0.01, "precision": 6, + "forceInput": True}), Lexicon.Z: (WILDCARD, {"default": 0, "min": -sys.maxsize, - "max": sys.maxsize, "step": 0.01, "precision": 6, - "forceInput": True}), + "max": sys.maxsize, "step": 0.01, "precision": 6, + "forceInput": True}), Lexicon.W: (WILDCARD, {"default": 0, "min": -sys.maxsize, - "max": sys.maxsize, "step": 0.01, "precision": 6, - "forceInput": True}), + "max": sys.maxsize, "step": 0.01, "precision": 6, + "forceInput": True}), Lexicon.IN_A+Lexicon.IN_A: ("VEC4", {"default": (0, 0, 0, 0), #"min": -sys.maxsize, "max": sys.maxsize, "label": [Lexicon.X, Lexicon.Y], @@ -840,8 +840,8 @@ def run(self, **kw) -> Tuple[bool]: default = [x_str] default2 = None if typ not in [EnumConvertType.STRING, EnumConvertType.LIST, \ - EnumConvertType.DICT,\ - EnumConvertType.IMAGE, EnumConvertType.LATENT, EnumConvertType.ANY, EnumConvertType.MASK]: + EnumConvertType.DICT,\ + EnumConvertType.IMAGE, EnumConvertType.LATENT, EnumConvertType.ANY, EnumConvertType.MASK]: a, b, c, d = xyzw a2, b2, c2, d2 = yyzw default = (a if r_x is None else r_x, @@ -853,8 +853,8 @@ def run(self, **kw) -> Tuple[bool]: val = parse_value(raw, typ, default) val2 = parse_value(default2, typ, default2) typ = EnumConvertType.VEC4 if typ in [EnumConvertType.VEC4, EnumConvertType.VEC3, \ - EnumConvertType.VEC2, EnumConvertType.FLOAT] \ - else EnumConvertType.VEC4INT + EnumConvertType.VEC2, EnumConvertType.FLOAT] \ + else EnumConvertType.VEC4INT # check if set to randomize.... if seed != 0: diff --git a/core/compose.py b/core/compose.py index 1e56c82..60a1e4a 100644 --- a/core/compose.py +++ b/core/compose.py @@ -71,7 +71,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.PIXEL: (WILDCARD, {}), Lexicon.MASK: (WILDCARD, {}), Lexicon.FUNC: (EnumAdjustOP._member_names_, {"default": EnumAdjustOP.BLUR.name, - "tooltip":"Type of adjustment (e.g., blur, sharpen, invert)"}), + "tooltip":"Type of adjustment (e.g., blur, sharpen, invert)"}), Lexicon.RADIUS: ("INT", {"default": 3, "min": 3, "step": 1}), Lexicon.VALUE: ("FLOAT", {"default": 1, "min": 0, "step": 0.1}), Lexicon.LOHI: ("VEC2", {"default": (0, 1), "step": 0.01, "precision": 4, @@ -79,7 +79,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.LMH: ("VEC3", {"default": (0, 0.5, 1), "step": 0.01, "precision": 4, "min": 0, "max": 1, "round": 0.00001, "label": [Lexicon.LO, Lexicon.MID, Lexicon.HI]}), Lexicon.HSV: ("VEC3",{"default": (0, 1, 1), "step": 0.01, "precision": 4, - "min": 0, "max": 1, "round": 0.00001, "label": [Lexicon.H, Lexicon.S, Lexicon.V]}), + "min": 0, "max": 1, "round": 0.00001, "label": [Lexicon.H, Lexicon.S, Lexicon.V]}), Lexicon.CONTRAST: ("FLOAT", {"default": 0, "min": 0, "max": 1, "step": 0.01, "precision": 4, "round": 0.00001}), Lexicon.GAMMA: ("FLOAT", {"default": 1, "min": 0.00001, "max": 1, "step": 0.01, @@ -105,7 +105,7 @@ def run(self, **kw) -> Tuple[torch.Tensor, ...]: matte = parse_param(kw, Lexicon.MATTE, EnumConvertType.VEC4INT, (0, 0, 0, 255), 0, 255) invert = parse_param(kw, Lexicon.INVERT, EnumConvertType.BOOLEAN, False) params = list(zip_longest_fill(pA, mask, op, radius, amt, lohi, - lmh, hsv, contrast, gamma, matte, invert)) + lmh, hsv, contrast, gamma, matte, invert)) images = [] pbar = ProgressBar(len(params)) for idx, (pA, mask, op, radius, amt, lohi, lmh, hsv, contrast, gamma, matte, invert) in enumerate(params): @@ -228,7 +228,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.INVERT: ("BOOLEAN", {"default": False, "tooltip": "Invert the mask input"}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -545,7 +545,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.END: ("VEC3", {"default": (128, 128, 128), "min":0, "max":255, "step": 1, "rgb": True}), Lexicon.FLOAT: ("VEC3", {"default": (0.5,0.5,0.5), "min":0, "max":1, "step": 0.01, "precision": 4, "tooltip": "the fuzziness use to extend the start and end range(s)"}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, - "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}), + "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}), } }) return Lexicon._parse(d, cls) @@ -587,7 +587,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -645,7 +645,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.A: (WILDCARD, {}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -812,10 +812,10 @@ def INPUT_TYPES(cls) -> dict: Lexicon.AXIS: (EnumOrientation._member_names_, {"default": EnumOrientation.GRID.name, "tooltip":"Choose the direction in which to stack the images. Options include horizontal, vertical, or a grid layout"}), Lexicon.STEP: ("INT", {"min": 1, "step": 1, "default": 1, - "tooltip":"Specify the spacing between each stacked image. This determines how far apart the images are from each other"}), + "tooltip":"Specify the spacing between each stacked image. This determines how far apart the images are from each other"}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -917,7 +917,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.STRENGTH: ("FLOAT", {"default": 1, "min": 0, "precision": 4, "step": 0.005}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } diff --git a/core/create.py b/core/create.py index 3010836..b664299 100644 --- a/core/create.py +++ b/core/create.py @@ -312,7 +312,7 @@ def INPUT_TYPES(cls) -> dict: "round": 0.00001, "label": [Lexicon.X, Lexicon.Y], "tooltip":"Offset the position"}), Lexicon.ANGLE: ("FLOAT", {"default": 0, "min": -180, "max": 180, - "step": 0.01, "precision": 4, "round": 0.00001}), + "step": 0.01, "precision": 4, "round": 0.00001}), Lexicon.EDGE: (EnumEdge._member_names_, {"default": EnumEdge.CLIP.name}), Lexicon.INVERT: ("BOOLEAN", {"default": False, "tooltip": "Invert the mask input"}) } @@ -339,13 +339,13 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]: invert = parse_param(kw, Lexicon.INVERT, EnumConvertType.BOOLEAN, False) images = [] params = list(zip_longest_fill(full_text, font_idx, autosize, letter, color, - matte, columns, font_size, align, justify, margin, - line_spacing, wihi, pos, angle, edge, invert)) + matte, columns, font_size, align, justify, margin, + line_spacing, wihi, pos, angle, edge, invert)) pbar = ProgressBar(len(params)) for idx, (full_text, font_idx, autosize, letter, color, matte, columns, - font_size, align, justify, margin, line_spacing, wihi, pos, - angle, edge, invert) in enumerate(params): + font_size, align, justify, margin, line_spacing, wihi, pos, + angle, edge, invert) in enumerate(params): width, height = wihi font_name = self.FONTS[font_idx] @@ -402,7 +402,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.VALUE: ("INT", {"default": 100, "min": 32, "max": 8192, "step": 1, "tooltip": "Number of Vertical bars to try to fit within the specified Width x Height"}), Lexicon.THICK: ("FLOAT", {"default": 0.72, "min": 0, "max": 1, "step": 0.01, - "tooltip": "The percentage of fullness for each bar; currently scaled from the left only"}), + "tooltip": "The percentage of fullness for each bar; currently scaled from the left only"}), Lexicon.WH: ("VEC2", {"default": (256, 256), "step": 1, "min":MIN_IMAGE_SIZE, "label": [Lexicon.W, Lexicon.H], "tooltip": "Final output size of the wave bar graph"}), diff --git a/core/device_stream.py b/core/device_stream.py index 4d0ca21..7345fae 100644 --- a/core/device_stream.py +++ b/core/device_stream.py @@ -101,7 +101,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.ZOOM: ("FLOAT", {"min": 0, "max": 1, "step": 0.005, "default": 0}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -277,7 +277,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.ROUTE: ("STRING", {"default": "/stream"}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 0), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } @@ -350,7 +350,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.FPS: ("INT", {"min": 0, "max": 60, "default": 30, "tooltip": "@@@ NOT USED @@@"}), Lexicon.MODE: (EnumScaleMode._member_names_, {"default": EnumScaleMode.NONE.name}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}), + "step": 1, "label": [Lexicon.W, Lexicon.H]}), Lexicon.SAMPLE: (EnumInterpolation._member_names_, {"default": EnumInterpolation.LANCZOS4.name}), Lexicon.MATTE: ("VEC4", {"default": (0, 0, 0, 255), "step": 1, "label": [Lexicon.R, Lexicon.G, Lexicon.B, Lexicon.A], "rgb": True}) } diff --git a/core/utility.py b/core/utility.py index ce58e27..f45e80f 100644 --- a/core/utility.py +++ b/core/utility.py @@ -378,7 +378,7 @@ def INPUT_TYPES(cls) -> dict: Lexicon.RESET: ("BOOLEAN", {"default": False}), Lexicon.VALUE: ("INT", {"default": 60, "min": 0, "tooltip":"Number of values to graph and display"}), Lexicon.WH: ("VEC2", {"default": (512, 512), "min":MIN_IMAGE_SIZE, - "step": 1, "label": [Lexicon.W, Lexicon.H]}) + "step": 1, "label": [Lexicon.W, Lexicon.H]}) } }) return Lexicon._parse(d, cls) diff --git a/sup/anim.py b/sup/anim.py index eb07c58..d915751 100644 --- a/sup/anim.py +++ b/sup/anim.py @@ -249,47 +249,47 @@ class EnumWave(Enum): @jit(cache=True) def wave_sin(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.sin(frequency * np.pi * 2 * timestep + phase) + offset @jit(cache=True) def wave_cos(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.cos(frequency * np.pi * 2 * timestep + phase) + offset @jit(cache=True) def wave_tan(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.tan(frequency * np.pi * 2 * timestep + phase) + offset @jit(cache=True) def wave_sawtooth(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * (2 * (frequency * timestep + phase) % 1 - 0.5) + offset @jit(cache=True) def wave_triangle(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * (4 * np.abs((frequency * timestep + phase) % 1 - 0.5) - 1) + offset @jit(cache=True) def wave_ramp(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * (frequency * timestep + phase % 1) + offset @jit(cache=True) def wave_step(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.heaviside(frequency * timestep + phase, 1) + offset @jit(cache=True) def wave_haversine(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * (1 - np.cos(frequency * np.pi * 2 * (timestep + phase))) + offset @jit(cache=True) def wave_noise(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.random.uniform(-1, 1) + offset # ============================================================================= @@ -303,29 +303,29 @@ def wave_square(phase: float, frequency: float, amplitude: float, offset: float, @jit(cache=True) def wave_exponential(phase: float, frequency: float, amplitude: float, - offset: float, timestep: float) -> float: + offset: float, timestep: float) -> float: return amplitude * np.exp(-frequency * (timestep + phase)) + offset @jit(cache=True) def wave_rectangular_pulse(phase: float, frequency: float, amplitude: float, - offset: float, timestep: float) -> float: + offset: float, timestep: float) -> float: return amplitude * np.heaviside(timestep + phase, 1) * np.heaviside(-(timestep + phase) + frequency, 1) + offset @jit(cache=True) def wave_logarithmic(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.log10(timestep + phase) / np.max(1, np.log10(frequency)) + offset @jit(cache=True) def wave_chirp(phase: float, frequency: float, amplitude: float, offset: float, - timestep: float) -> float: + timestep: float) -> float: return amplitude * np.sin(np.pi * 2 * frequency * (timestep + phase)**2) + offset #### @jit(cache=True) def wave_gaussian(phase: float, mean: float, amplitude: float, offset: float, - timestep: float, std_dev: float = 1) -> float: + timestep: float, std_dev: float = 1) -> float: return amplitude * np.exp(-0.5 * ((timestep + phase - mean) / std_dev)**2) + offset def wave_op(op: EnumEase, phase: float, frequency: float, amplitude: float, diff --git a/sup/audio.py b/sup/audio.py index b72664f..718af10 100644 --- a/sup/audio.py +++ b/sup/audio.py @@ -44,6 +44,6 @@ def graph_sausage(data: np.ndarray, bar_count:int, width:int, height:int, current_x = int((i + offset) * line_width) current_y = int((height - item_height) / 2) draw.line((current_x, current_y, current_x, current_y + item_height), - fill=color_back, width=int(thickness * line_width)) + fill=color_back, width=int(thickness * line_width)) image = pil2cv(image) return image_scalefit(image, width, height, EnumScaleMode.FIT) diff --git a/sup/image.py b/sup/image.py index a7ae06c..9eff2f8 100644 --- a/sup/image.py +++ b/sup/image.py @@ -84,37 +84,37 @@ class EnumAdjustOP(Enum): CLOSE = 74 class EnumBlendType(Enum): - """Rename the blend type names.""" - NORMAL = BlendType.NORMAL - ADDITIVE = BlendType.ADDITIVE - NEGATION = BlendType.NEGATION - DIFFERENCE = BlendType.DIFFERENCE - MULTIPLY = BlendType.MULTIPLY - DIVIDE = BlendType.DIVIDE - LIGHTEN = BlendType.LIGHTEN - DARKEN = BlendType.DARKEN - SCREEN = BlendType.SCREEN - BURN = BlendType.COLOURBURN - DODGE = BlendType.COLOURDODGE - OVERLAY = BlendType.OVERLAY - HUE = BlendType.HUE - SATURATION = BlendType.SATURATION - LUMINOSITY = BlendType.LUMINOSITY - COLOR = BlendType.COLOUR - SOFT = BlendType.SOFTLIGHT - HARD = BlendType.HARDLIGHT - PIN = BlendType.PINLIGHT - VIVID = BlendType.VIVIDLIGHT - EXCLUSION = BlendType.EXCLUSION - REFLECT = BlendType.REFLECT - GLOW = BlendType.GLOW - XOR = BlendType.XOR - EXTRACT = BlendType.GRAINEXTRACT - MERGE = BlendType.GRAINMERGE - DESTIN = BlendType.DESTIN - DESTOUT = BlendType.DESTOUT - SRCATOP = BlendType.SRCATOP - DESTATOP = BlendType.DESTATOP + """Rename the blend type names.""" + NORMAL = BlendType.NORMAL + ADDITIVE = BlendType.ADDITIVE + NEGATION = BlendType.NEGATION + DIFFERENCE = BlendType.DIFFERENCE + MULTIPLY = BlendType.MULTIPLY + DIVIDE = BlendType.DIVIDE + LIGHTEN = BlendType.LIGHTEN + DARKEN = BlendType.DARKEN + SCREEN = BlendType.SCREEN + BURN = BlendType.COLOURBURN + DODGE = BlendType.COLOURDODGE + OVERLAY = BlendType.OVERLAY + HUE = BlendType.HUE + SATURATION = BlendType.SATURATION + LUMINOSITY = BlendType.LUMINOSITY + COLOR = BlendType.COLOUR + SOFT = BlendType.SOFTLIGHT + HARD = BlendType.HARDLIGHT + PIN = BlendType.PINLIGHT + VIVID = BlendType.VIVIDLIGHT + EXCLUSION = BlendType.EXCLUSION + REFLECT = BlendType.REFLECT + GLOW = BlendType.GLOW + XOR = BlendType.XOR + EXTRACT = BlendType.GRAINEXTRACT + MERGE = BlendType.GRAINMERGE + DESTIN = BlendType.DESTIN + DESTOUT = BlendType.DESTOUT + SRCATOP = BlendType.SRCATOP + DESTATOP = BlendType.DESTATOP class EnumColorMap(Enum): AUTUMN = cv2.COLORMAP_AUTUMN @@ -542,7 +542,7 @@ def channel_add(image:TYPE_IMAGE, color:TYPE_PIXEL=255) -> TYPE_IMAGE: return np.concatenate([image, new], axis=-1) def channel_solid(width:int=MIN_IMAGE_SIZE, height:int=MIN_IMAGE_SIZE, color:TYPE_PIXEL=(0, 0, 0, 255), - chan:EnumImageType=EnumImageType.BGR) -> TYPE_IMAGE: + chan:EnumImageType=EnumImageType.BGR) -> TYPE_IMAGE: if chan == EnumImageType.GRAYSCALE: color = pixel_eval(color, EnumImageType.GRAYSCALE) @@ -584,7 +584,7 @@ def channel_merge(channel:List[TYPE_IMAGE]) -> TYPE_IMAGE: return img def channel_swap(imageA:TYPE_IMAGE, swap_ot:EnumPixelSwizzle, - imageB:TYPE_IMAGE, swap_in:EnumPixelSwizzle) -> TYPE_IMAGE: + imageB:TYPE_IMAGE, swap_in:EnumPixelSwizzle) -> TYPE_IMAGE: index_out = int(swap_ot.value / 10) cc_out = imageA.shape[2] if imageA.ndim == 3 else 1 # swap channel is out of range of image size @@ -668,8 +668,8 @@ def image_blend(imageA: TYPE_IMAGE, imageB: TYPE_IMAGE, mask:Optional[TYPE_IMAGE return image_crop_center(image, w, h) def image_color_blind(image: TYPE_IMAGE, deficiency:EnumCBDeficiency, - simulator:EnumCBSimulator=EnumCBSimulator.AUTOSELECT, - severity:float=1.0) -> TYPE_IMAGE: + simulator:EnumCBSimulator=EnumCBSimulator.AUTOSELECT, + severity:float=1.0) -> TYPE_IMAGE: cc = image.shape[2] if image.ndim == 3 else 1 if cc == 4: @@ -1019,9 +1019,9 @@ def image_invert(image: TYPE_IMAGE, value: float) -> TYPE_IMAGE: return bgr2image(image, alpha, cc == 1) def image_lerp(imageA:TYPE_IMAGE, - imageB:TYPE_IMAGE, - mask:TYPE_IMAGE=None, - alpha:float=1.) -> TYPE_IMAGE: + imageB:TYPE_IMAGE, + mask:TYPE_IMAGE=None, + alpha:float=1.) -> TYPE_IMAGE: imageA = imageA.astype(np.float32) imageB = imageB.astype(np.float32) @@ -1301,9 +1301,9 @@ def scale_func(img: TYPE_IMAGE) -> TYPE_IMAGE: return image_affine_edge(image, scale_func, edge) def image_scalefit(image: TYPE_IMAGE, width: int, height:int, - mode:EnumScaleMode=EnumScaleMode.NONE, - sample:EnumInterpolation=EnumInterpolation.LANCZOS4, - matte:TYPE_PIXEL=(0,0,0,0)) -> TYPE_IMAGE: + mode:EnumScaleMode=EnumScaleMode.NONE, + sample:EnumInterpolation=EnumInterpolation.LANCZOS4, + matte:TYPE_PIXEL=(0,0,0,0)) -> TYPE_IMAGE: match mode: case EnumScaleMode.MATTE: @@ -1330,7 +1330,7 @@ def image_scalefit(image: TYPE_IMAGE, width: int, height:int, return image def image_sharpen(image:TYPE_IMAGE, kernel_size=None, sigma:float=1.0, - amount:float=1.0, threshold:float=0) -> TYPE_IMAGE: + amount:float=1.0, threshold:float=0) -> TYPE_IMAGE: """Return a sharpened version of the image, using an unsharp mask.""" kernel_size = (kernel_size, kernel_size) if kernel_size else (5, 5) @@ -1456,9 +1456,9 @@ def image_stereo_shift(image: TYPE_IMAGE, depth: TYPE_IMAGE, shift:float=10) -> return pil2cv(shifted_image) def image_threshold(image:TYPE_IMAGE, threshold:float=0.5, - mode:EnumThreshold=EnumThreshold.BINARY, - adapt:EnumThresholdAdapt=EnumThresholdAdapt.ADAPT_NONE, - block:int=3, const:float=0.) -> TYPE_IMAGE: + mode:EnumThreshold=EnumThreshold.BINARY, + adapt:EnumThresholdAdapt=EnumThresholdAdapt.ADAPT_NONE, + block:int=3, const:float=0.) -> TYPE_IMAGE: const = max(-100, min(100, const)) block = max(3, block if block % 2 == 1 else block + 1) @@ -1505,9 +1505,9 @@ def image_transform(image: TYPE_IMAGE, offset:TYPE_COORD=(0.0, 0.0), angle:float # MORPHOLOGY def morph_edge_detect(image: TYPE_IMAGE, - ksize: int=3, - low: float=0.27, - high:float=0.6) -> TYPE_IMAGE: + ksize: int=3, + low: float=0.27, + high:float=0.6) -> TYPE_IMAGE: image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) ksize = max(3, ksize) @@ -1563,8 +1563,8 @@ def kernel(stride: int) -> TYPE_IMAGE: Example: >>> KERNEL(3) array([[ 0, 1, 1], - [-1, 0, 1], - [-1, -1, 0]], dtype=int8) + [-1, 0, 1], + [-1, -1, 0]], dtype=int8) """ # Create an initial matrix of zeros kernel = np.zeros((stride, stride), dtype=np.int8) @@ -1624,7 +1624,7 @@ def color_match_reinhard(image: TYPE_IMAGE, target: TYPE_IMAGE) -> TYPE_IMAGE: return cv2.cvtColor(lab_tar, cv2.COLOR_Lab2BGR) def color_match_lut(image: TYPE_IMAGE, colormap:int=cv2.COLORMAP_JET, - usermap:TYPE_IMAGE=None, num_colors:int=255) -> TYPE_IMAGE: + usermap:TYPE_IMAGE=None, num_colors:int=255) -> TYPE_IMAGE: """Colorize one input based on built in cv2 color maps or a user defined image.""" cc = image.shape[2] if image.ndim == 3 else 1 if cc == 4: diff --git a/sup/midi.py b/sup/midi.py index 95fe1b9..2be13f3 100644 --- a/sup/midi.py +++ b/sup/midi.py @@ -39,7 +39,7 @@ def midi_load(fn) -> None: mid = MidiFile(fn, clip=True) logger.debug(mid) for msg in mid.tracks[0]: - logger.debug(msg) + logger.debug(msg) def midi_device_names() -> List[str]: try: diff --git a/sup/text.py b/sup/text.py index 9d3d9a7..940115c 100644 --- a/sup/text.py +++ b/sup/text.py @@ -159,10 +159,10 @@ def text_autosize(text:str, font:str, width:int, height:int, columns:int=0) -> T return text, *size def text_draw(full_text: str, font: ImageFont, width: int, height: int, - align: EnumAlignment=EnumAlignment.CENTER, - justify: EnumJustify=EnumJustify.CENTER, - margin: int=0, line_spacing: int=0, - color: TYPE_PIXEL=(255,255,255,255)) -> TYPE_IMAGE: + align: EnumAlignment=EnumAlignment.CENTER, + justify: EnumJustify=EnumJustify.CENTER, + margin: int=0, line_spacing: int=0, + color: TYPE_PIXEL=(255,255,255,255)) -> TYPE_IMAGE: img = Image.new("RGBA", (width, height)) draw = ImageDraw.Draw(img)