#---------------------------------------------------------------------------------------------------------------------# # CR Animation Nodes by RockOfFire and Akatsuzi https://github.com/Suzie1/CR-Animation-Nodes # for ComfyUI https://github.com/comfyanonymous/ComfyUI #---------------------------------------------------------------------------------------------------------------------# import torch from ..categories import icons #---------------------------------------------------------------------------------------------------------------------# # NODES #---------------------------------------------------------------------------------------------------------------------# class CR_GradientInteger: @classmethod def INPUT_TYPES(s): gradient_profiles = ["Lerp"] return {"required": {"start_value": ("INT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "end_value": ("INT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "start_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "frame_duration": ("INT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "gradient_profile": (gradient_profiles,) }, } RETURN_TYPES = ("INT", "STRING", ) RETURN_NAMES = ("INT", "show_help", ) FUNCTION = "gradient" CATEGORY = icons.get("Comfyroll/Animation/Interpolate") def gradient(self, start_value, end_value, start_frame, frame_duration, current_frame, gradient_profile): show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Interpolation-Nodes#cr-gradient-integer" if current_frame < start_frame: return (start_value, show_help, ) if current_frame > start_frame + frame_duration: return (end_value, show_help, ) step = (end_value - start_value) / frame_duration current_step = current_frame - start_frame int_out = start_value + int(current_step * step) return (int_out, show_help, ) #---------------------------------------------------------------------------------------------------------------------# class CR_GradientFloat: @classmethod def INPUT_TYPES(s): gradient_profiles = ["Lerp"] return {"required": {"start_value": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 0.01,}), "end_value": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 0.01,}), "start_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "frame_duration": ("INT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "gradient_profile": (gradient_profiles,) }, } RETURN_TYPES = ("FLOAT", "STRING", ) RETURN_NAMES = ("FLOAT", "show_help", ) FUNCTION = "gradient" CATEGORY = icons.get("Comfyroll/Animation/Interpolate") def gradient(self, start_value, end_value, start_frame, frame_duration, current_frame, gradient_profile): show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Interpolation-Nodes#cr-gradient-float" if current_frame < start_frame: return (start_value, show_help, ) if current_frame > start_frame + frame_duration: return (end_value, show_help, ) step = (end_value - start_value) / frame_duration current_step = current_frame - start_frame float_out = start_value + current_step * step return (float_out, show_help, ) #---------------------------------------------------------------------------------------------------------------------# class CR_IncrementFloat: @classmethod def INPUT_TYPES(s): return {"required": {"start_value": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 0.001,}), "step": ("FLOAT", {"default": 0.1, "min": -9999.0, "max": 9999.0, "step": 0.001,}), "start_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.00,}), "frame_duration": ("INT", {"default": 1.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), "current_frame": ("INT", {"default": 0.0, "min": 0.0, "max": 9999.0, "step": 1.0,}), }, } RETURN_TYPES = ("FLOAT", "STRING", ) RETURN_NAMES = ("FLOAT", "show_help", ) OUTPUT_NODE = True FUNCTION = "increment" CATEGORY = icons.get("Comfyroll/Animation/Interpolate") def increment(self, start_value, step, start_frame, frame_duration, current_frame): show_help = "https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes/wiki/Interpolation-Nodes#cr-increment-float" #print(f"current frame {current_frame}") if current_frame < start_frame: return (start_value, show_help, ) current_value = start_value + (current_frame - start_frame) * step if current_frame <= start_frame + frame_duration: current_value += step #print(f"