Upload calculate_framewindow.py
Browse files- calculate_framewindow.py +46 -0
calculate_framewindow.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
|
| 3 |
+
class Calculate_Framewindow:
|
| 4 |
+
"""
|
| 5 |
+
Computes: floor((length * float(framerate)) + 1)
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
@classmethod
|
| 9 |
+
def INPUT_TYPES(cls):
|
| 10 |
+
return {
|
| 11 |
+
"required": {
|
| 12 |
+
"length": ("FLOAT", {
|
| 13 |
+
"default": 1.0,
|
| 14 |
+
"min": 0.0,
|
| 15 |
+
"max": 1.0e9,
|
| 16 |
+
"step": 0.001,
|
| 17 |
+
}),
|
| 18 |
+
"framerate": ("INT", {
|
| 19 |
+
"default": 24,
|
| 20 |
+
"min": 1,
|
| 21 |
+
"max": 1000000,
|
| 22 |
+
"step": 1,
|
| 23 |
+
}),
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
RETURN_TYPES = ("INT",)
|
| 28 |
+
RETURN_NAMES = ("result",)
|
| 29 |
+
|
| 30 |
+
FUNCTION = "compute"
|
| 31 |
+
CATEGORY = "math"
|
| 32 |
+
|
| 33 |
+
def compute(self, length: float, framerate: int):
|
| 34 |
+
framerate_f = float(framerate) # explicit internal conversion as requested
|
| 35 |
+
value = (length * framerate_f) + 1.0
|
| 36 |
+
result = int(math.floor(value)) # round down
|
| 37 |
+
return (result,)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
NODE_CLASS_MAPPINGS = {
|
| 41 |
+
"Calculate_Framewindow": Calculate_Framewindow
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
NODE_DISPLAY_NAME_MAPPINGS = {
|
| 45 |
+
"Calculate_Framewindow": "Calculate_Framewindow"
|
| 46 |
+
}
|