From 5c7bfe05a16ebb7f07f9b9fd33da84afddd7e5a5 Mon Sep 17 00:00:00 2001 From: Jacob Segal Date: Sat, 8 Jul 2023 19:33:10 -0700 Subject: [PATCH] Add an Incrementer node --- MaskNodes.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 6 ++++++ __init__.py | 4 ++-- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/MaskNodes.py b/MaskNodes.py index fd3c109..9e5a1b0 100644 --- a/MaskNodes.py +++ b/MaskNodes.py @@ -1268,6 +1268,27 @@ class ConvertColorSpace: assert out_space == "HSL" return (hsv2hsl(hsv),) +class MaqueradeIncrementerNode: + def __init__(self): + pass + + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "seed": ("INT", {"default": 0, "min": -1, "max": 0xffffffffffffffff, "step": 1}), + "max_value": ("INT", {"default": 1, "min": 1, "max": 0xffffffffffffffff, "step": 1}), + } + } + + RETURN_TYPES = ("INT",) + FUNCTION = "increment" + + CATEGORY = "Masquerade Nodes" + + def increment(self, seed, max_value): + return (seed % max_value,) + NODE_CLASS_MAPPINGS = { "Mask By Text": ClipSegNode, @@ -1291,4 +1312,28 @@ NODE_CLASS_MAPPINGS = { "Make Image Batch": MakeImageBatch, "Create QR Code": CreateQRCodeNode, "Convert Color Space": ConvertColorSpace, + "MasqueradeIncrementer": MaqueradeIncrementerNode, +NODE_DISPLAY_NAME_MAPPINGS = { + "Mask By Text": "Mask By Text", + "Mask Morphology": "Mask Morphology", + "Combine Masks": "Combine Masks", + "Unary Mask Op": "Unary Mask Op", + "Unary Image Op": "Unary Image Op", + "Blur": "Blur", + "Image To Mask": "Image To Mask", + "Mix Images By Mask": "Mix Images By Mask", + "Mix Color By Mask": "Mix Color By Mask", + "Mask To Region": "Mask To Region", + "Cut By Mask": "Cut By Mask", + "Paste By Mask": "Paste By Mask", + "Get Image Size": "Get Image Size", + "Change Channel Count": "Change Channel Count", + "Constant Mask": "Constant Mask", + "Prune By Mask": "Prune By Mask", + "Separate Mask Components": "Separate Mask Components", + "Create Rect Mask": "Create Rect Mask", + "Make Image Batch": "Make Image Batch", + "Create QR Code": "Create QR Code", + "Convert Color Space": "Convert Color Space", + "MasqueradeIncrementer": "Incrementer", } diff --git a/README.md b/README.md index 25fc645..4d54904 100644 --- a/README.md +++ b/README.md @@ -288,3 +288,9 @@ This node is the same as Unary Mask Op, but will operate across all channels of * `image` - The image to convert. * `in_space` - The color space of the input image -- valid values are `RGB`, `HSV`, and `HSL`. * `out_space` - The color space of the output image -- valid values are `RGB`, `HSV`, and `HSL`. + +## Incrementer +#### Inputs +* `seed` - The current value. +* `control_after_generate` - Set to "Increment" to actually increment. +* `max_value` - The value to perform modulo against diff --git a/__init__.py b/__init__.py index 6394ad8..4881d01 100644 --- a/__init__.py +++ b/__init__.py @@ -1,3 +1,3 @@ -from .MaskNodes import NODE_CLASS_MAPPINGS +from .MaskNodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS -__all__ = ['NODE_CLASS_MAPPINGS'] +__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']