Removed(commented) "Tuples" nodes; Removed "TUPLES" type from "Get size" nodes; (DON'T FORGET TO REPLACE THEM IF THEY'RE PERSISTS IN YOUR WORKFLOW) Types moved into their own class with class methods and default parameters instead of just tuples with strings and dicts; Added "Logic node" (>, <, =, AND, OR, XOR); (idk why i did this one, but got an idea that with object recognition models to count objects and correct them in next iterations would be not so bad idea as i think. Or something like this) changed README.md to current state of this repo
136 lines
2.8 KiB
Python
136 lines
2.8 KiB
Python
import math
|
|
|
|
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.pyscripts.components.fields import Field
|
|
from custom_nodes.Derfuu_ComfyUI_ModdedNodes.pyscripts.components.tree import TREE_MATH
|
|
|
|
|
|
class MultiplyNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Value_A": Field.float(),
|
|
"Value_B": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT",)
|
|
FUNCTION = "multiply"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def multiply(self, Value_A, Value_B):
|
|
total = float(Value_A * Value_B)
|
|
return (total,)
|
|
|
|
|
|
class DivideNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Numerator": Field.float(),
|
|
"Denominator": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT",)
|
|
FUNCTION = "divide"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def divide(self, Numerator, Denominator):
|
|
total = float(Numerator / Denominator)
|
|
return (total,)
|
|
|
|
|
|
class SumNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Value_A": Field.float(),
|
|
"Value_B": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT",)
|
|
FUNCTION = "sum"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def sum(self, Value_A, Value_B):
|
|
total = float(Value_A + Value_B)
|
|
return (total,)
|
|
|
|
|
|
class SubtractNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Value_A": Field.float(),
|
|
"Value_B": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT",)
|
|
FUNCTION = "sub"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def sub(self, Value_A, Value_B):
|
|
total = float(Value_A - Value_B)
|
|
return (total,)
|
|
|
|
|
|
class PowNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Value": Field.float(),
|
|
"Exponent": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT",)
|
|
FUNCTION = "pow"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def pow(self, Value, Exponent):
|
|
total = math.pow(Value, Exponent)
|
|
return (total,)
|
|
|
|
|
|
class SquareRootNode:
|
|
def __init__(self) -> None:
|
|
pass
|
|
|
|
@classmethod
|
|
def INPUT_TYPES(cls):
|
|
return {
|
|
"required": {
|
|
"Value": Field.float(),
|
|
},
|
|
}
|
|
|
|
RETURN_TYPES = ("FLOAT", "FLOAT",)
|
|
FUNCTION = "sqrt"
|
|
CATEGORY = TREE_MATH
|
|
|
|
def sqrt(self, Value):
|
|
total = math.sqrt(Value)
|
|
return (total, -total,)
|