-
Notifications
You must be signed in to change notification settings - Fork 0
/
ard_math.py
85 lines (78 loc) · 3.39 KB
/
ard_math.py
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
"""
@author: initials AMA
@title: Ardenius
@nickname: Ardenius
@description: ARD Integer variable
"""
# licensed under General Public License v3.0 all rights reserved © 2024
# Owner initials: AMAA
# nickname: Ardenius
# email: ardenius7@gmail.com
# website: https://ko-fi.com/ardenius
# ➡️ follow me at https://ko-fi.com/ardenius in the top right corner (follow)
# 📸 Change the mood ! by Visiting my AI Image Gallery
# 🏆 Support me by getting Premium Members only Perks (Premium SD Models, ComfyUI custom nodes, and more to come)
# below code is based upon ComfyUI code licensed under General Public License v3.0 https://www.gnu.org/licenses/gpl-3.0.txt by
# contributers found here https://github.com/comfyanonymous/ComfyUI
# thus all code here is released to the user as per the GPL V3.0 terms.
class ARD_MATH:
# def __init__(self):
# pass
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"Ix": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 9999999, "step": 0.0001, "tooltip": "input float if you want to input integer use ARD integer to float node"}),
"Iy": ("FLOAT", {"default": 1.0, "min": 0.1, "max": 9999999, "step": 0.0001, "tooltip": "input float if you want to input integer use ARD integer to float node"}),
"operation": (["multiply", "divide", "subtract", "add"], {"default": "divide", "tooltip": "pick math operation"}),
},
}
RETURN_NAMES = ("result_integer", "result_float")
RETURN_TYPES = ("INT", "FLOAT")
FUNCTION = "ard_math"
CATEGORY = "Ardenius"
DESCRIPTION = "ARD math node mathematical operations node."
def ard_math(self, Ix, Iy, operation):
try:
if isinstance(Ix, int):
Ix = float(Ix)
elif isinstance(Ix, float):
pass
else:
print("ARD math node ERROR: inputs need to be either integer or float")
return (0, 0.0)
if isinstance(Iy, int):
Iy = float(Iy)
elif isinstance(Iy, float):
pass
else:
print("ARD math node ERROR: inputs need to be either integer or float")
return (0, 0.0)
if operation == "multiply":
result_integer = int(Ix * Iy)
elif operation == "divide":
result_integer = int(Ix/Iy)
elif operation == "subtract":
result_integer = int(Ix - Iy)
elif operation == "add":
result_integer = int(Ix + Iy)
else:
print("pick a math operation")
result_integer = 0
if operation == "multiply":
result_float = float(Ix * Iy)
elif operation == "divide":
result_float = float(Ix / Iy)
elif operation == "subtract":
result_float = float(Ix - Iy)
elif operation == "add":
result_float = float(Ix + Iy)
else:
print("ARD Math ERROR: pick a math operation")
result_float = 0.0
return (result_integer, result_float)
except Exception as e:
print("*****************************************")
print(f"ARD math: check inputs ERROR {e}")
print("*****************************************")
return (0, 0.0)