Add descriptions and tooltips to nodes

Add DESCRIPTION class attributes to all node classes for UI documentation. Add OUTPUT_TOOLTIPS to describe output values and 'tooltip' keys to input parameters for better user guidance in the ComfyUI interface. Also standardize formatting and remove unnecessary docstrings.
This commit is contained in:
MdONeilsl
2026-07-14 10:15:27 -04:00
parent b6a2d1dd79
commit 1975140d82
3 changed files with 339 additions and 243 deletions
+79 -23
View File
@@ -1,4 +1,3 @@
from ..py.libs.color import pack_rgb
module_cat = "md/color"
@@ -9,18 +8,26 @@ MAX_RGB_INT = 0xFFFFFF
# RGB
# =============================================================================
class mdPrimitiveColorRGB:
DESCRIPTION = "Converts RGB values to an integer color code and a hexadecimal string representation."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"Red": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1}),
"Green": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1}),
"Blue": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1}),
"Red": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1, "tooltip": "Red component value (0-255)."}),
"Green": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1, "tooltip": "Green component value (0-255)."}),
"Blue": ("FLOAT", {"default": 0, "min": 0, "max": 255, "step": 1, "tooltip": "Blue component value (0-255)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -37,18 +44,26 @@ class mdPrimitiveColorRGB:
# HSV
# =============================================================================
class mdPrimitiveColorHSV:
DESCRIPTION = "Converts HSV color values to an integer color code and a hexadecimal string representation."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"Hue": ("FLOAT", {"default": 0, "min": 0, "max": 360, "step": 0.1}),
"Saturation": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Value": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Hue": ("FLOAT", {"default": 0, "min": 0, "max": 360, "step": 0.1, "tooltip": "Hue value in degrees (0-360)."}),
"Saturation": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Saturation percentage (0-100%)."}),
"Value": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Value (brightness) percentage (0-100%)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -85,18 +100,26 @@ class mdPrimitiveColorHSV:
# HSL
# =============================================================================
class mdPrimitiveColorHSL:
DESCRIPTION = "Converts HSL color values to an integer color code and a hexadecimal string representation."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"Hue": ("FLOAT", {"default": 0, "min": 0, "max": 360, "step": 0.1}),
"Saturation": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Lightness": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Hue": ("FLOAT", {"default": 0, "min": 0, "max": 360, "step": 0.1, "tooltip": "Hue value in degrees (0-360)."}),
"Saturation": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Saturation percentage (0-100%)."}),
"Lightness": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Lightness percentage (0-100%)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -128,19 +151,27 @@ class mdPrimitiveColorHSL:
# CMYK
# =============================================================================
class mdPrimitiveColorCMYK:
DESCRIPTION = "Converts CMYK color values to an integer color code and a hexadecimal string representation."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"Cyan": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Magenta": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Yellow": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Key": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1}),
"Cyan": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Cyan percentage (0-100%)."}),
"Magenta": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Magenta percentage (0-100%)."}),
"Yellow": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Yellow percentage (0-100%)."}),
"Key": ("FLOAT", {"default": 0, "min": 0, "max": 100, "step": 0.1, "tooltip": "Key (black) percentage (0-100%)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -160,18 +191,26 @@ class mdPrimitiveColorCMYK:
# CIE 1931 XYZ
# =============================================================================
class mdPrimitiveColorXYZ:
DESCRIPTION = "Converts CIE XYZ color values to an integer color code and a hexadecimal string representation (D65 white point)."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"X": ("FLOAT", {"default": 0.95047, "min": 0.0, "max": 1.0, "step": 0.001}),
"Y": ("FLOAT", {"default": 1.00000, "min": 0.0, "max": 1.0, "step": 0.001}),
"Z": ("FLOAT", {"default": 1.08883, "min": 0.0, "max": 1.0, "step": 0.001}),
"X": ("FLOAT", {"default": 0.95047, "min": 0.0, "max": 1.0, "step": 0.001, "tooltip": "X coordinate in CIE XYZ color space."}),
"Y": ("FLOAT", {"default": 1.00000, "min": 0.0, "max": 1.0, "step": 0.001, "tooltip": "Y coordinate in CIE XYZ color space."}),
"Z": ("FLOAT", {"default": 1.08883, "min": 0.0, "max": 1.0, "step": 0.001, "tooltip": "Z coordinate in CIE XYZ color space."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -197,18 +236,26 @@ class mdPrimitiveColorXYZ:
# CIELAB
# =============================================================================
class mdPrimitiveColorLAB:
DESCRIPTION = "Converts CIELAB color values to an integer color code and a hexadecimal string representation (D65 white point)."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"L": ("FLOAT", {"default": 50, "min": 0, "max": 100, "step": 0.1}),
"A": ("FLOAT", {"default": 0, "min": -128, "max": 128, "step": 0.1}),
"B": ("FLOAT", {"default": 0, "min": -128, "max": 128, "step": 0.1}),
"L": ("FLOAT", {"default": 50, "min": 0, "max": 100, "step": 0.1, "tooltip": "Lightness component (0-100)."}),
"A": ("FLOAT", {"default": 0, "min": -128, "max": 128, "step": 0.1, "tooltip": "A component (green-red axis)."}),
"B": ("FLOAT", {"default": 0, "min": -128, "max": 128, "step": 0.1, "tooltip": "B component (blue-yellow axis)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -251,18 +298,26 @@ class mdPrimitiveColorLAB:
# Y′CbCr
# =============================================================================
class mdPrimitiveColorYCbCr:
DESCRIPTION = "Converts Y′CbCr color values to an integer color code and a hexadecimal string representation."
@classmethod
def INPUT_TYPES(cls) -> dict:
return {
"required": {
"Luma": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001}),
"BlueDiff": ("FLOAT", {"default": 0.0, "min": -0.5, "max": 0.5, "step": 0.001}),
"RedDiff": ("FLOAT", {"default": 0.0, "min": -0.5, "max": 0.5, "step": 0.001}),
"Luma": ("FLOAT", {"default": 0.0, "min": 0.0, "max": 1.0, "step": 0.001, "tooltip": "Luma (brightness) component (0-1)."}),
"BlueDiff": ("FLOAT", {"default": 0.0, "min": -0.5, "max": 0.5, "step": 0.001, "tooltip": "Blue chroma difference component (-0.5 to 0.5)."}),
"RedDiff": ("FLOAT", {"default": 0.0, "min": -0.5, "max": 0.5, "step": 0.001, "tooltip": "Red chroma difference component (-0.5 to 0.5)."}),
},
}
RETURN_TYPES = ("INT", "STRING")
RETURN_NAMES = ("int", "HEX")
OUTPUT_TOOLTIPS = [
"Packed 24-bit integer color value (0-16777215).",
"Hexadecimal color string (e.g., #FF0000)."
]
FUNCTION = "exec"
CATEGORY = module_cat
@@ -300,3 +355,4 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"mdPrimitiveColorLAB": "Primitive Color CIELAB (MD)",
"mdPrimitiveColorYCbCr": "Primitive Color YCbCr (MD)",
}
+249 -213
View File
File diff suppressed because it is too large Load Diff
+11 -7
View File
@@ -1,4 +1,3 @@
module_cat = "md/layers"
from ..py.layers_blending import composite_layer_stack
@@ -11,13 +10,14 @@ class mdLayerStackNode:
Composites a layer over a background using a blend mode, a mask, and a global transparency.
Handles RGBA images (4 channels) and respects the layer's own alpha channel.
"""
DESCRIPTION = "Composites a layer over a background using a blend mode, mask, and transparency. Supports multiple blend modes including Normal, Screen, Multiply, Overlay, etc."
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"background": ("IMAGE",),
"layer": ("IMAGE",),
"background": ("IMAGE", {"tooltip": "The base image to which the layer will be composited."}),
"layer": ("IMAGE", {"tooltip": "The layer to composite over the background."}),
"blending_mode": (["Normal", "Screen", "Multiply", "Overlay", "Difference",
"Dissolve", "Clear", "Add", "Subtract", "Replace",
"Darken Only", "Lighten Only", "Color Dodge", "Color Burn",
@@ -25,11 +25,11 @@ class mdLayerStackNode:
"Linear Burn (Multiply)", "Vivid Light", "Halo", "Negate",
"Merge RGB", "Merge Cyan", "Merge Magenta", "Merge Yellow",
"Merge Black", "Fill with FG Color", "Fill with BG Color",
"Average", "Composite", "Behind", "Template"],),
"transparency": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01}),
"Average", "Composite", "Behind", "Template"], {"tooltip": "The blend mode to use when compositing the layer."}),
"transparency": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 1.0, "step": 0.01, "tooltip": "Global transparency for the layer (0.0 = fully transparent, 1.0 = fully opaque)."}),
},
"optional": {
"mask": ("MASK",),
"mask": ("MASK", {"tooltip": "Optional mask to control where the layer is applied (white = visible, black = hidden)."}),
}
}
@@ -37,6 +37,9 @@ class mdLayerStackNode:
FUNCTION = "exec"
CATEGORY = module_cat
OUTPUT_TOOLTIPS = ["Composited image result"]
RETURN_NAMES = ("Composited Image",)
def exec(self, background, layer, blending_mode, transparency, mask=None):
return composite_layer_stack(background, layer, blending_mode, transparency, mask)
@@ -48,3 +51,4 @@ NODE_CLASS_MAPPINGS = {
NODE_DISPLAY_NAME_MAPPINGS = {
"mdLayerStackNode": "Layer Stack Node (MD)",
}