File size: 3,345 Bytes
e0e88f3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | import custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.fields as field
import math
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.components.tree import TREE_TUPLES
class Tuple:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Value_A": field.FLOAT,
"Value_B": field.FLOAT,
"round": (["No", "Yes", "Ceil", "Floor"],),
}
}
RETURN_TYPES = ("TUPLE",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, Value_A=0, Value_B=0, round="No"):
match round:
case "No":
return ((Value_A, Value_B),)
case "Yes":
return ((int(Value_A), int(Value_B)),)
case "Ceil":
return ((math.ceil(Value_A), math.ceil(Value_B)),)
case "Floor":
return ((math.floor(Value_A), math.floor(Value_B)),)
class Int2Tuple:
def __init__(self) -> None:
pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Value_A": field.INT,
"Value_B": field.INT,
}
}
RETURN_TYPES = ("TUPLE",)
CATEGORY = TREE_TUPLES
FUNCTION = 'get_tuple'
def get_tuple(self, Value_A=0, Value_B=0):
return ((Value_A, Value_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],)
|