Files
Derfuu-Derfuu_ComfyUI_Modde…/Nodes/Functions/Tuples.py
T
Derfuu cc43376402 Updated to last ComfyUI version (on 26.03.23) to use conversion between fields and connection points
- Fixed types issues
- Added:
 - Int2Tuple node
- Deleted due to last ComfyUI update which made them nearly useless now:
 - ConditioningSetAreaEXT (modded)
 - EmptyLatentImage (modded)
- NOT Deleted, but now might be useless (IMHO):
 - LatentComposite (modded)
 - ConditioningSetArea (modded)
- TUPLES moved to their own subfolder in UI
- ALL custom nodes with FLOAT, INT, STRING values now can use their own fields as inputs (use original conversion to points to connect)
- Refactored nearly all code... again
2023-03-26 20:20:41 +03:00

156 lines
3.0 KiB
Python

import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.fields as field
import math
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.tree import TREE_TUPLES
class Float2Tuple:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"FLOAT_A": field.FLOAT,
"FLOAT_B": field.FLOAT,
"Ceil2Int": ([False, True],),
}
}
RETURN_TYPES = ("TUPLE",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, FLOAT_A=0, FLOAT_B=0, Ceil2Int=False):
if Ceil2Int == True:
FLOAT_A = math.ceil(FLOAT_A)
FLOAT_B = math.ceil(FLOAT_B)
return ((FLOAT_A, FLOAT_B),)
class Int2Tuple:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"INT_A": field.INT,
"INT_B": field.INT,
}
}
RETURN_TYPES = ("TUPLE",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, INT_A=0, INT_B=0):
return ((INT_A, INT_B),)
class Tuple2Float:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"TUPLE": ("TUPLE",),
}
}
RETURN_TYPES = ("FLOAT", "FLOAT",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, TUPLE):
return (TUPLE[0], TUPLE[1],)
class Tuple2Int:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"TUPLE": ("TUPLE",),
}
}
RETURN_TYPES = ("INT", "INT",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, TUPLE):
return (int(TUPLE[0]), int(TUPLE[1]),)
class FlipTuple:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"TUPLE": ("TUPLE",)
}
}
RETURN_TYPES = ("TUPLE",)
FUNCTION = "flip"
CATEGORY = TREE_TUPLES
def flip(self, TUPLE):
return ((TUPLE[1], TUPLE[0]),)
class MergeTuples:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"TUPLE_A": ("TUPLE",),
"TUPLE_B": ("TUPLE",),
}
}
RETURN_TYPES = ("TUPLE",)
FUNCTION = "merge"
CATEGORY = TREE_TUPLES
def merge(self, TUPLE_A, TUPLE_B):
return ((TUPLE_A, TUPLE_B),)
class Tuple2Tuple:
def __init__(self):
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"TUPLE": ("TUPLE",),
}
}
RETURN_TYPES = ("TUPLE", "TUPLE",)
FUNCTION = "spl"
CATEGORY = TREE_TUPLES
def spl(self, TUPLE):
return (TUPLE[0], TUPLE[1],)