Added addtional getters and logic gates

This commit is contained in:
dumbdemon
2026-03-16 11:34:30 -05:00
parent 25bf578de4
commit 2bc4a06c40
3 changed files with 363 additions and 30 deletions
+35 -6
View File
@@ -1,12 +1,41 @@
# DD-LogicNodes
A collection of Logic Nodes missing in core ComfyUI.
A collection of Logic Nodes that I think are missing in core ComfyUI.
## Incomplete Yet Complete
This currently has only two node.
This currently has 14 nodes.
- If Not
- Returns a flipped boolean
- If Any
- Returns one of two different values if provided with anything.
### Logic
- DD If Not
- Returns a flipped boolean.
- DD Or Gate
- Returns __true__ if either expression is true.
- DD And Getter
- Returns __true__ ___only___ if __both__ ezpressions are true.
- DD XOR Getter
- Returns __true__ ___only___ if __one__ expression is true.
- DD NOR Getter
- Returns __true__ ___only___ if __both__ ezpressions are false.
- DD NAND Getter
- Returns __true__ except when __both__ expressions are true.
- DD XNOR Getter
- Returns __true__ if __both__ expresions are true or if __both__ expresions are false.
### Logical Getters
- DD If Any Getter
- Returns `on_true` if any value is passed through.
- DD Or Getter
- Returns `on_true` if the expression is true.
- DD And Getter
- Returns `on_true` ___only___ if __both__ ezpressions are true.
- DD XOR Getter
- Returns `on_true` ___only___ if __one__ expression is true.
- DD NOR Getter
- Returns `on_true` ___only___ if __both__ ezpressions are false.
- DD NAND Getter
- Returns `on_true` except when __both__ expressions are true.
- DD XNOR Getter
- Returns `on_true` if __both__ expresions are true or if __both__ expresions are false.
+2 -2
View File
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
[project]
name = "DD-LogicNodes"
version = "0.0.1"
description = "A collection of Logic Nodes missing in core ComfyUI."
version = "0.1.0"
description = "A collection of Logic Nodes that I think are missing in core ComfyUI."
authors = [
{name = "DumbDemon", email = "ecchimanga@outlook.com"}
]
+326 -22
View File
@@ -7,25 +7,9 @@ class AnyType(str):
any_typ = AnyType("*")
class IfNot:
CATEGORY = "DD Logic Nodes"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"boolean": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "invertBoolean"
def invertBoolean(self, boolean: bool):
return (not boolean,)
# Getters
class IfAnyGet:
CATEGORY = "DD Logic Nodes"
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@@ -47,16 +31,336 @@ class IfAnyGet:
return True
RETURN_TYPES = (any_typ,)
RETURN_NAMES = ("?",)
FUNCTION = "ifAnyThenGet"
def ifAnyThenGet(self, ANY, on_true, on_false):
def ifAnyThenGet(self, ANY: AnyType, on_true: AnyType, on_false: AnyType):
return (on_true if ANY else on_false,)
class OrGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "orGet"
def orGet(self, on_true: AnyType, on_false: AnyType, expression: bool):
return (on_true if expression else on_false,)
class AndGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression1": ("BOOLEAN", {"default": True}),
"expression2": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "andGet"
def andGet(self, on_true: AnyType, on_false: AnyType, expression1: bool, expression2: bool):
if expression1 and expression2:
return (on_true,)
else:
return (on_false,)
class XorGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression1": ("BOOLEAN", {"default": True}),
"expression2": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "xorGet"
def xorGet(self, on_true: AnyType, on_false: AnyType, expression1: bool, expression2: bool):
if expression1 and expression2:
return (on_false,)
elif not expression1 and not expression2:
return (on_false,)
else:
return (on_true,)
class NorGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression1": ("BOOLEAN", {"default": False}),
"expression2": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "norGet"
def norGet(self, on_true: AnyType, on_false: AnyType, expression1: bool, expression2: bool):
if not expression1 and not expression2:
return (on_true,)
else:
return (on_false,)
class XnorGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression1": ("BOOLEAN", {"default": True}),
"expression2": ("BOOLEAN", {"default": True}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "xnorGet"
def xnorGet(self, on_true: AnyType, on_false: AnyType, expression1: bool, expression2: bool):
if expression1 and expression2:
return (on_true,)
elif not expression1 and not expression2:
return (on_true,)
else:
return (on_false,)
class NandGet:
CATEGORY = "DD Logic Nodes/Getters"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"on_true": (any_typ,),
"on_false": (any_typ,),
"expression1": ("BOOLEAN", {"default": False}),
"expression2": ("BOOLEAN", {"default": False}),
}
}
RETURN_TYPES = (any_typ,)
FUNCTION = "nandGet"
def nandGet(self, on_true: AnyType, on_false: AnyType, expression1: bool, expression2: bool):
if expression1 and expression2:
return (on_false,)
else:
return (on_true,)
class IfNot:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"boolean": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "invertBoolean"
def invertBoolean(self, boolean: bool):
return (not boolean,)
# Logic Gates
class OrGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": True}), "expression2": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "orGate"
def orGate(self, expression1: bool, expression2: bool):
return (expression1 or expression2,)
class AndGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": True}), "expression2": ("BOOLEAN", {"default": True})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "andGate"
def andGate(self, expression1: bool, expression2: bool):
return (expression1 and expression2,)
class XorGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": True}), "expression2": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "xorGate"
def xorGate(self, expression1: bool, expression2: bool):
if expression1 and expression2:
return (False,)
elif not expression1 and not expression2:
return (False,)
else:
return (True,)
class NorGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": False}), "expression2": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "norGate"
def norGate(self, expression1: bool, expression2: bool):
return (not expression1 and not expression2,)
class NandGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": False}), "expression2": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "nandGate"
def nandGate(self, expression1: bool, expression2: bool):
return (not (expression1 and expression2),)
class XnorGate:
CATEGORY = "DD Logic Nodes/Logic Gates"
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {"required": {"expression1": ("BOOLEAN", {"default": False}), "expression2": ("BOOLEAN", {"default": False})}}
RETURN_TYPES = ("BOOLEAN",)
FUNCTION = "Gate"
def orGate(self, expression1: bool, expression2: bool):
if expression1 and expression2:
return (True,)
elif not expression1 and not expression2:
return (True,)
return (False,)
# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {"IfNot": IfNot, "IfAnyGetAorB": IfAnyGet}
NODE_CLASS_MAPPINGS = {
"DDIfAnyGet": IfAnyGet,
"DDOrGetter": OrGet,
"DDAndGetter": AndGet,
"DDIfXorGet": XorGet,
"DDIfNorGet": NorGet,
"DDifNandGet": NandGet,
"DDifXnorGet": XnorGet,
"DDNotGate": IfNot,
"DDOrGate": OrGate,
"DDAndGate": AndGate,
"DDIfXorGate": XorGate,
"DDIfNorGate": NorGate,
"DDifNandGate": NandGate,
"DDifXnorGate": XnorGate,
}
# A dictionary that contains the friendly/humanly readable titles for the nodes
NODE_DISPLAY_NAME_MAPPINGS = {"IfNot": "DD If Not", "IfAnyGetAorB": "DD If Any"}
NODE_DISPLAY_NAME_MAPPINGS = {
"DDIfAnyGet": "DD If Any Getter",
"DDOrGetter": "DD Or Getter",
"DDAndGetter": "DD And Getter",
"DDIfXorGet": "DD XOR Getter",
"DDIfNorGet": "DD NOR Getter",
"DDifNandGet": "DD NAND Getter",
"DDifXnorGet": "DD XNOR Getter",
"DDNotGate": "DD Not Gate",
"DDOrGate": "DD Or Gate",
"DDAndGate": "DD And Gate",
"DDIfXorGate": "DD XOR Gate",
"DDIfNorGate": "DD NOR Gate",
"DDifNandGate": "DD NAND Gate",
"DDifXnorGate": "DD XNOR Gate",
}