None of the nodes showed description text in ComfyUI because ComfyUI reads obj_class.DESCRIPTION when it builds node_info - it does not read the class docstring, which is what these nodes had. Every registered node now carries a one-line DESCRIPTION, kept to 29-67 characters so it fits the limited space in ComfyUI Manager and the node search results. Image Transform Pro's four-sentence description is shortened to match. Descriptions are derived from each node's existing docstring, or from the README for the five classes that had no docstring (ImageBlendPro, ColorMatchBlend and the three Boolean switch nodes). README also updated for the recent changes: the New Nodes table now lists the real "Rotate & Scale" category, the XY placement direction is documented on both nodes (positive X right, positive Y up), and the v2.2.0 changelog records the placement convention, the node outputs and the MP_ImageTransform internal name.
221 lines
5.9 KiB
Python
221 lines
5.9 KiB
Python
# boolean_utils.py
|
|
# Combined boolean utility nodes for MachinePaintingNodes
|
|
|
|
import random
|
|
|
|
|
|
class Boolean:
|
|
"""
|
|
Simple standalone Boolean toggle
|
|
MachinePaintingNodes - For use with boolean toggle inputs on nodes.
|
|
"""
|
|
|
|
DESCRIPTION = "Standalone true/false toggle."
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"boolean": ("BOOLEAN", {
|
|
"default": True,
|
|
"label_on": "true",
|
|
"label_off": "false"
|
|
}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("BOOLEAN",)
|
|
RETURN_NAMES = ("boolean",)
|
|
FUNCTION = "execute"
|
|
CATEGORY = "MachinePaintingNodes/Util"
|
|
|
|
def execute(self, boolean=True):
|
|
return (boolean,)
|
|
|
|
@classmethod
|
|
def IS_CHANGED(cls, **kwargs):
|
|
return float("NaN")
|
|
|
|
|
|
class BooleanInvert:
|
|
"""
|
|
Inverts a boolean value. True becomes False, False becomes True.
|
|
"""
|
|
|
|
DESCRIPTION = "Flip a boolean: true becomes false, false becomes true."
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"value": ("BOOLEAN", {"default": False}),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("BOOLEAN",)
|
|
RETURN_NAMES = ("inverted",)
|
|
FUNCTION = "invert"
|
|
CATEGORY = "MachinePaintingNodes/Util"
|
|
|
|
def invert(self, value):
|
|
return (not value,)
|
|
|
|
|
|
class BooleanSwitchValueOutput:
|
|
|
|
DESCRIPTION = "Output one of two values depending on a boolean."
|
|
|
|
TITLE = "Boolean Switch Value - (INT/FLOAT)"
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"true_value": ("FLOAT", {
|
|
"default": 1.00,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
"false_value": ("FLOAT", {
|
|
"default": 0.00,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
},
|
|
"optional": {
|
|
"boolean": ("BOOLEAN", {"label": "boolean"}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("INT", "FLOAT")
|
|
RETURN_NAMES = ("INT", "FLOAT")
|
|
FUNCTION = "switch"
|
|
CATEGORY = "MachinePaintingNodes/Util"
|
|
|
|
def switch(self, true_value=1.00, false_value=0.00, boolean=None):
|
|
value = boolean if boolean is not None else True
|
|
result = true_value if value else false_value
|
|
return (int(result), float(result))
|
|
|
|
|
|
class BooleanInputValueSwitch:
|
|
|
|
DESCRIPTION = "Route one of two inputs through based on a boolean."
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"FLOAT_input": ("FLOAT", {
|
|
"forceInput": True,
|
|
}),
|
|
"true_min": ("FLOAT", {
|
|
"default": 0.51,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
"true_max": ("FLOAT", {
|
|
"default": 1.00,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
"false_min": ("FLOAT", {
|
|
"default": 0.00,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
"false_max": ("FLOAT", {
|
|
"default": 0.50,
|
|
"min": -9999.0,
|
|
"max": 9999.0,
|
|
"step": 0.01,
|
|
"display": "number"
|
|
}),
|
|
"overlap_behavior": ([
|
|
"randomize",
|
|
"force_true",
|
|
"force_false"
|
|
], {
|
|
"default": "randomize",
|
|
"tooltip": "What to do when value falls in both ranges"
|
|
}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("BOOLEAN",)
|
|
RETURN_NAMES = ("boolean",)
|
|
FUNCTION = "evaluate"
|
|
CATEGORY = "MachinePaintingNodes/Util"
|
|
|
|
@classmethod
|
|
def IS_CHANGED(cls, FLOAT_input, true_min, true_max, false_min, false_max, overlap_behavior, **kwargs):
|
|
if overlap_behavior == "randomize":
|
|
return float("nan")
|
|
return float("inf")
|
|
|
|
def evaluate(self, FLOAT_input,
|
|
true_min=0.51, true_max=1.00,
|
|
false_min=0.00, false_max=0.50,
|
|
overlap_behavior="randomize"):
|
|
|
|
value = FLOAT_input
|
|
|
|
in_true = true_min <= value <= true_max
|
|
in_false = false_min <= value <= false_max
|
|
|
|
if in_true and in_false:
|
|
if overlap_behavior == "randomize":
|
|
return (random.choice([True, False]),)
|
|
elif overlap_behavior == "force_true":
|
|
return (True,)
|
|
else:
|
|
return (False,)
|
|
elif in_true:
|
|
return (True,)
|
|
elif in_false:
|
|
return (False,)
|
|
else:
|
|
return (False,)
|
|
|
|
|
|
class BooleanMasterSwitch:
|
|
|
|
DESCRIPTION = "Drive several boolean outputs from one master toggle."
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"master": ("BOOLEAN", {
|
|
"default": True,
|
|
"label_on": "TRUE",
|
|
"label_off": "FALSE"
|
|
}),
|
|
}
|
|
}
|
|
|
|
RETURN_TYPES = ("BOOLEAN",)
|
|
RETURN_NAMES = ("out_1",)
|
|
FUNCTION = "execute"
|
|
CATEGORY = "MachinePaintingNodes/Util"
|
|
|
|
OUTPUT_IS_LIST = (True,)
|
|
OUTPUT_MAX_LIST_LENGTH = 25
|
|
|
|
def execute(self, master: bool):
|
|
return ([master],)
|
|
|
|
@classmethod
|
|
def IS_CHANGED(cls, **kwargs):
|
|
return float("NaN")
|