Files
CavinHuang-comfyui-nodes-docs/docs/CR Increment Float.md
2024-05-26 20:35:16 +08:00

2.8 KiB

Documentation

CR_IncrementFloat 是一个设计用来在指定的持续时间内逐步调整浮点数值的节点。它在动画时间轴内的当前帧基础上,平滑地过渡从一个起始值到一个递增的值,促进了动态和基于时间的动画的创建。

Input types

Required

  • start_value
    • 增量开始的初始值。它作为节点操作的参考点,影响动画序列的起始点。
    • Comfy dtype: FLOAT
    • Python dtype: float
  • step
    • 增量步长值,定义了每个帧浮点数的变化。它在确定动画中增加或减少的速率方面至关重要。
    • Comfy dtype: FLOAT
    • Python dtype: float
  • start_frame
    • 增量过程开始的帧号。它决定了动画增量变化开始的时间。
    • Comfy dtype: INT
    • Python dtype: int
  • frame_duration
    • 增量发生的总帧数。它设置了增量动画效果的持续时间。
    • Comfy dtype: INT
    • Python dtype: int
  • current_frame
    • 动画时间轴中的当前帧。它用于根据帧的进展计算增量的当前值。
    • Comfy dtype: INT
    • Python dtype: int

Output types

  • FLOAT
    • 在当前帧的基础上应用增量逻辑后得到的递增浮点数值的结果。
    • Comfy dtype: FLOAT
    • Python dtype: float
  • show_help
    • 指向节点文档的URL链接,以获取有关其使用的进一步帮助和信息。
    • Comfy dtype: STRING
    • Python dtype: str

Usage tips

  • Infra type: CPU

Source code

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.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})}}
    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'
        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
            return (current_value, show_help)
        return (current_value, show_help)