Skip to content

Commit

Permalink
tooltips married with inputs, outputs and widgets as JTOOLTIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Amorano committed Jun 24, 2024
1 parent 7faa0d2 commit 1914203
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 62 deletions.
19 changes: 13 additions & 6 deletions core/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ class ComparisonNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD, WILDCARD,)
RETURN_NAMES = (Lexicon.TRIGGER, Lexicon.VALUE,)
SORT = 130
DESCRIPTION = """
The Comparison node evaluates two inputs based on a specified operation. It accepts two inputs (A and B), comparison operators, and optional values for successful and failed comparisons. The node performs the specified operation element-wise between corresponding elements of A and B. If the comparison is successful for all elements, it returns the success value; otherwise, it returns the failure value. The node supports various comparison operators such as EQUAL, GREATER_THAN, LESS_THAN, AND, OR, IS, IN, etc.
"""
Expand Down Expand Up @@ -513,6 +514,7 @@ class DelayNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD,)
RETURN_NAMES = (Lexicon.PASS_OUT,)
SORT = 240
DESCRIPTION = """
Delay node used to introduce pauses in the workflow. It accepts an optional input to pass through and a timer parameter to specify the duration of the delay. If no timer is provided, it defaults to a maximum delay. During the delay, it periodically checks for messages to interrupt the delay. Once the delay is completed, it returns the input passed to it.
"""
Expand Down Expand Up @@ -556,7 +558,7 @@ class LerpNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD,)
RETURN_NAMES = (Lexicon.ANY_OUT,)
SORT = 45
SORT = 30
DESCRIPTION = """
The Lerp Node calculates linear interpolation between two values or vectors based on a blending factor (alpha). The node accepts optional start (IN_A) and end (IN_B) points, a blending factor (FLOAT), and various input types for both start and end points, such as single values (X, Y), 2-value vectors (IN_A2, IN_B2), 3-value vectors (IN_A3, IN_B3), and 4-value vectors (IN_A4, IN_B4). Additionally, you can specify the easing function (EASE) and the desired output type (TYPE). It supports various easing functions for smoother transitions.
"""
Expand Down Expand Up @@ -585,7 +587,7 @@ def INPUT_TYPES(cls) -> dict:
"tooltip":"default value vector for B"}),
},
"outputs": {
Lexicon.ANY_OUT: {"tooltip":"testing the output tool tips"}
0: (WILDCARD, {"tooltip":f"Output can vary depending on the type chosen in the {Lexicon.TYPE} parameter."}),
}
})
return Lexicon._parse(d, cls)
Expand Down Expand Up @@ -635,7 +637,7 @@ class SwizzleNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD,)
RETURN_NAMES = (Lexicon.ANY_OUT,)
SORT = 65
SORT = 40
DESCRIPTION = """
The Swap Node swaps components between two vectors based on specified swizzle patterns and values. It provides flexibility in rearranging vector elements dynamically.
"""
Expand All @@ -660,8 +662,8 @@ def INPUT_TYPES(cls) -> dict:
return Lexicon._parse(d, cls)

def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
pA = parse_param(kw, Lexicon.IN_A, EnumConvertType.VEC4, (0,0,0,0), 0, 1)
pB = parse_param(kw, Lexicon.IN_B, EnumConvertType.VEC4, (0,0,0,0), 0, 1)
pA = parse_param(kw, Lexicon.IN_A, EnumConvertType.VEC4, (0,0,0,0))
pB = parse_param(kw, Lexicon.IN_B, EnumConvertType.VEC4, (0,0,0,0))
swap_x = parse_param(kw, Lexicon.SWAP_X, EnumConvertType.STRING, EnumSwizzle.A_X.name)
x = parse_param(kw, Lexicon.X, EnumConvertType.FLOAT, 0)
swap_y = parse_param(kw, Lexicon.SWAP_Y, EnumConvertType.STRING, EnumSwizzle.A_Y.name)
Expand All @@ -673,7 +675,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
params = list(zip_longest_fill(pA, pB, swap_x, x, swap_y, y, swap_z, z, swap_w, w))
results = []
pbar = ProgressBar(len(params))
print(pA, pB, swap_x, x, swap_y, y, swap_z, z, swap_w, w)
for idx, (pA, pB, swap_x, x, swap_y, y, swap_z, z, swap_w, w) in enumerate(params):
print(pA, pB, swap_x, x, swap_y, y, swap_z, z, swap_w, w)
swap_x = EnumSwizzle[swap_x]
swap_y = EnumSwizzle[swap_y]
swap_z = EnumSwizzle[swap_z]
Expand All @@ -688,6 +692,7 @@ class TickNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD, "FLOAT", "FLOAT", WILDCARD)
RETURN_NAMES = (Lexicon.VALUE, Lexicon.LINEAR, Lexicon.FPS, Lexicon.TRIGGER)
SORT = 50
DESCRIPTION = """
The `Tick` node acts as a timer and frame counter, emitting pulses or signals based on time intervals or BPM settings. It allows precise synchronization and control over animation sequences, with options to adjust FPS, BPM, and loop points. This node is useful for generating time-based events or driving animations with rhythmic precision.
"""
Expand Down Expand Up @@ -780,7 +785,7 @@ class ValueNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = (WILDCARD, WILDCARD, WILDCARD, WILDCARD, WILDCARD,)
RETURN_NAMES = (Lexicon.ANY_OUT, Lexicon.X, Lexicon.Y, Lexicon.Z, Lexicon.W)
SORT = 1
SORT = 5
DESCRIPTION = """
The Value Node supplies raw or default values for various data types, supporting vector input with components for X, Y, Z, and W. It also provides a string input option.
"""
Expand Down Expand Up @@ -892,6 +897,7 @@ class WaveGeneratorNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("FLOAT", "INT", )
RETURN_NAMES = (Lexicon.FLOAT, Lexicon.INT, )
SORT = 90
DESCRIPTION = """
The `Wave Generator` node produces waveforms like sine, square, or sawtooth with adjustable frequency, amplitude, phase, and offset. It's handy for creating oscillating patterns or controlling animation dynamics. This node emits both continuous floating-point values and integer representations of the generated waves.
"""
Expand Down Expand Up @@ -942,6 +948,7 @@ class ParameterNode(JOVBaseNode):
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ()
RETURN_NAMES = ()
SORT = 100
DESCRIPTION = """
"""
Expand Down
80 changes: 40 additions & 40 deletions core/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,26 @@ class EnumCropMode(Enum):

# =============================================================================

class AdjustNode(JOVBaseNode):
NAME = "ADJUST (JOV) 🕸️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
class JOVImageNode(JOVBaseNode):
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
@classmethod
def INPUT_TYPES(cls) -> dict:
d = super().INPUT_TYPES()
d.update({
"outputs": {
0: ("IMAGE", {"tooltip":"Full channel [RGBA] image. If there is an alpha, the image will be masked out with it when using this output."}),
1: ("IMAGE", {"tooltip":"Three channel [RGB] image. There will be no alpha."}),
2: ("MASK", {"tooltip":"Single channel mask output."}),
}
})
return Lexicon._parse(d, cls)

# =============================================================================

class AdjustNode(JOVImageNode):
NAME = "ADJUST (JOV) 🕸️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
DESCRIPTION = """
Enhance and modify images with various effects using the Adjust Node. Apply effects such as blurring, sharpening, color tweaks, and edge detection. Customize parameters like radius, value, and contrast, and use masks for selective effects. Advanced options include pixelation, quantization, and morphological operations like dilation and erosion. Handle transparency effortlessly to ensure seamless blending of effects. This node is ideal for simple adjustments and complex image transformations.
"""
Expand Down Expand Up @@ -204,11 +219,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, ...]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class BlendNode(JOVBaseNode):
class BlendNode(JOVImageNode):
NAME = "BLEND (JOV) ⚗️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 10
DESCRIPTION = """
Combines two input images using various blending modes, such as normal, screen, multiply, overlay, etc. It also supports alpha blending and masking to achieve complex compositing effects. This node is essential for creating layered compositions and adding visual richness to images.
Expand Down Expand Up @@ -302,11 +315,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class ColorBlindNode(JOVBaseNode):
class ColorBlindNode(JOVImageNode):
NAME = "COLOR BLIND (JOV) 👁‍🗨"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
DESCRIPTION = """
Use the Color Blind Node to simulate color blindness effects on images. You can select various types of color deficiencies, adjust the severity of the effect, and apply the simulation using different simulators. This node is ideal for accessibility testing and design adjustments, ensuring inclusivity in your visual content.
"""
Expand Down Expand Up @@ -343,11 +354,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class ColorMatchNode(JOVBaseNode):
class ColorMatchNode(JOVImageNode):
NAME = "COLOR MATCH (JOV) 💞"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
DESCRIPTION = """
Adjust the color scheme of one image to match another with the Color Match Node. Choose from various color matching modes, including LUT, Histogram, and Reinhard. You can specify options like color maps, the number of colors, and whether to flip or invert the images. This node allows for the creation of seamless and cohesive visuals, making it ideal for texture work or masking in motion graphics and design projects.
"""
Expand Down Expand Up @@ -468,11 +477,9 @@ def run(self, **kw) -> Tuple[List[torch.Tensor], List[torch.Tensor]]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class CropNode(JOVBaseNode):
class CropNode(JOVImageNode):
NAME = "CROP (JOV) ✂️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 5
DESCRIPTION = """
Extract a portion of an input image or resize it. It supports various cropping modes, including center cropping, custom XY cropping, and freeform polygonal cropping. This node is useful for preparing image data for specific tasks or extracting regions of interest.
Expand Down Expand Up @@ -524,11 +531,9 @@ def run(self, **kw) -> Tuple[List[torch.Tensor], List[torch.Tensor]]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class FilterMaskNode(JOVBaseNode):
class FilterMaskNode(JOVImageNode):
NAME = "FILTER MASK (JOV) 🤿"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 700
DESCRIPTION = """
Create masks based on specific color ranges within an image. Specify the color range using start and end values and an optional fuzziness factor to adjust the range. This node allows for precise color-based mask creation, ideal for tasks like object isolation, background removal, or targeted color adjustments.
Expand Down Expand Up @@ -569,11 +574,9 @@ def run(self, **kw) -> Tuple[Any, ...]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class Flatten(JOVBaseNode):
class Flatten(JOVImageNode):
NAME = "FLATTEN (JOV) ⬇️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 500
DESCRIPTION = """
Combine multiple input images into a single image by summing their pixel values. This operation is useful for merging multiple layers or images into one composite image, such as combining different elements of a design or merging masks. Users can specify the blending mode and interpolation method to control how the images are combined. Additionally, a matte can be applied to adjust the transparency of the final composite image.
Expand Down Expand Up @@ -624,11 +627,9 @@ def run(self, **kw) -> torch.Tensor:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class PixelMergeNode(JOVBaseNode):
class PixelMergeNode(JOVImageNode):
NAME = "PIXEL MERGE (JOV) 🫂"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 45
DESCRIPTION = """
Combines individual color channels (red, green, blue) along with an optional mask channel to create a composite image. This node is useful for merging separate color components into a single image for visualization or further processing.
Expand Down Expand Up @@ -702,20 +703,21 @@ def INPUT_TYPES(cls) -> dict:
def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
images = []
pA = parse_param(kw, Lexicon.PIXEL, EnumConvertType.IMAGE, None)
print(pA[0].shape)
pbar = ProgressBar(len(pA))
for idx, pA in enumerate(pA):
pA = channel_solid(chan=EnumImageType.BGRA) if pA is None else tensor2cv(pA)
print(pA.shape)
pA = image_mask_add(pA)
print(pA.shape)
pA = [cv2tensor(x, True) for x in image_split(pA)]
images.append(pA)
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class PixelSwapNode(JOVBaseNode):
class PixelSwapNode(JOVImageNode):
NAME = "PIXEL SWAP (JOV) 🔃"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 48
DESCRIPTION = """
Swap pixel values between two input images based on specified channel swizzle operations. Options include pixel inputs, swap operations for red, green, blue, and alpha channels, and constant values for each channel. The swap operations allow for flexible pixel manipulation by determining the source of each channel in the output image, whether it be from the first image, the second image, or a constant value.
Expand Down Expand Up @@ -794,11 +796,9 @@ def swapper(swap_out:EnumPixelSwizzle, swap_in:EnumPixelSwizzle) -> np.ndarray[A
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class StackNode(JOVBaseNode):
class StackNode(JOVImageNode):
NAME = "STACK (JOV) ➕"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 75
DESCRIPTION = """
Merge multiple input images into a single composite image by stacking them along a specified axis. Options include axis, stride, scaling mode, width and height, interpolation method, and matte color. The axis parameter allows for horizontal, vertical, or grid stacking of images, while stride controls the spacing between them.
Expand All @@ -811,7 +811,7 @@ def INPUT_TYPES(cls) -> dict:
"optional": {
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,
Lexicon.STEP: ("INT", {"min": 0, "step": 1, "default": 1,
"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,
Expand All @@ -827,27 +827,29 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor]:
if len(images) == 0:
logger.warning("no images to stack")
return

axis = parse_param(kw, Lexicon.AXIS, EnumConvertType.STRING, EnumOrientation.GRID.name)[0]
stride = parse_param(kw, Lexicon.STEP, EnumConvertType.INT, 1, 1)[0]
stride = parse_param(kw, Lexicon.STEP, EnumConvertType.INT, 1)[0]
mode = parse_param(kw, Lexicon.MODE, EnumConvertType.STRING, EnumScaleMode.NONE.name)[0]
wihi = parse_param(kw, Lexicon.WH, EnumConvertType.VEC2INT, (512, 512), MIN_IMAGE_SIZE)[0]
sample = parse_param(kw, Lexicon.SAMPLE, EnumConvertType.STRING, EnumInterpolation.LANCZOS4.name)[0]
matte = parse_param(kw, Lexicon.MATTE, EnumConvertType.VEC4INT, (0, 0, 0, 255), 0, 255)[0]
images = [tensor2cv(img) for img in images]
data = []
for i in images:
data.extend(i)
images = [tensor2cv(i) for i in data]
axis = EnumOrientation[axis]
img = image_stack(images, axis, stride, matte)
img = image_stack(images, axis, stride) #, matte)
mode = EnumScaleMode[mode]
if mode != EnumScaleMode.NONE:
w, h = wihi
sample = EnumInterpolation[sample]
img = image_scalefit(img, w, h, mode, sample)
return cv2tensor_full(img, matte)

class ThresholdNode(JOVBaseNode):
class ThresholdNode(JOVImageNode):
NAME = "THRESHOLD (JOV) 📉"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
DESCRIPTION = """
Use the Threshold Node to define a range and apply it to an image for segmentation and feature extraction. Choose from various threshold modes, such as binary and adaptive, and adjust the threshold value and block size to suit your needs. You can also invert the resulting mask if necessary. This node is versatile for a variety of image processing tasks.
"""
Expand Down Expand Up @@ -888,11 +890,9 @@ def run(self, **kw) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
pbar.update_absolute(idx)
return [torch.cat(i, dim=0) for i in zip(*images)]

class TransformNode(JOVBaseNode):
class TransformNode(JOVImageNode):
NAME = "TRANSFORM (JOV) 🏝️"
CATEGORY = f"JOVIMETRIX 🔺🟩🔵/{JOV_CATEGORY}"
RETURN_TYPES = ("IMAGE", "IMAGE", "MASK")
RETURN_NAMES = (Lexicon.IMAGE, Lexicon.RGB, Lexicon.MASK)
SORT = 0
DESCRIPTION = """
Applies various geometric transformations to images, including translation, rotation, scaling, mirroring, tiling, perspective projection, and more. It offers extensive control over image manipulation to achieve desired visual effects.
Expand Down
Loading

0 comments on commit 1914203

Please sign in to comment.