-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathloop_float.py
29 lines (24 loc) · 1.01 KB
/
loop_float.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
from decimal import Decimal, ROUND_HALF_UP
class LoopFloat:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"from_this": ("FLOAT", {"default": 0.00, "min": 0.00, "max": 1000.00, "step": 0.01}),
"to_that": ("FLOAT", {"default": 10.00, "min": 0.00, "max": 1000.00, "step": 0.01}),
"jump": ("FLOAT", {"default": 1.00, "min": 0.00, "max": 1000.00, "step": 0.01}),
},
}
RETURN_TYPES = ("FLOAT",)
OUTPUT_IS_LIST = (True, False)
FUNCTION = "create_loop_float"
CATEGORY = "Bjornulf"
def create_loop_float(self, from_this, to_that, jump):
range_values = []
current_value = Decimal(str(from_this))
to_that = Decimal(str(to_that))
jump = Decimal(str(jump))
while current_value <= to_that:
range_values.append(float(current_value.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)))
current_value += jump
return (range_values,)