Files
mcDandy-more_math/src/more_math/nodes.py
T
2025-07-29 17:08:19 +02:00

69 lines
1.7 KiB
Python

from .FloatMathNode import FloatMathNode
from .ConditioningMathNode import ConditioningMathNode
from .LatentMathNode import LatentMathNode
from .ImageMathNode import ImageMathNode
class IntToFloatNode:
"""
Converts int to float.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"value": ("INT", {"default": 0}),
}
}
RETURN_TYPES = ("FLOAT",)
FUNCTION = "convert"
CATEGORY = "More math"
def convert(self, value):
return (float(value),)
class FloatToIntNode:
"""
Converts float to int.
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"value": ("FLOAT", {"default": 0.0}),
}
}
RETURN_TYPES = ("INT",)
FUNCTION = "convert"
CATEGORY = "More math"
def convert(self, value):
return (int(value),)
NODE_CLASS_MAPPINGS = {
"mrmth_ConditioningMathNode": ConditioningMathNode,
"mrmth_LatentMathNode": LatentMathNode,
"mrmth_ImageMathNode": ImageMathNode,
"mrmth_IntToFloat": IntToFloatNode,
"mrmth_FloatToInt": FloatToIntNode,
"mrmth_FloatMathNode": FloatMathNode,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"mrmth_ConditioningMathNode": "Conditioning math node",
"mrmth_LatentMathNode": "Latent math node",
"mrmth_ImageMathNode": "Image math node",
"mrmth_FloatMathNode": "Float math node",
"mrmth_IntToFloat": "Int → Float",
"mrmth_FloatToInt": "Float → Int",
"Tensor": "Tensor expression",
"Latent": "Latent expression",
"Image": "Image expression",
"FloatFunc": "Float expression",
"pooled_output": "Pooled output tensor expression"
}