Nodes/FizzNodes/TriangleWave πŸ“…πŸ…•πŸ…
ComfyUI Node Runs on cloud

TriangleWave πŸ“…πŸ…•πŸ…

A linear saw up and down β€” the wave that moves like a camera pan

By FizzleDorfΒ·Created 3 years agoΒ·Updated 2 years agoΒ· 479
TriangleWave πŸ“…πŸ…•πŸ…
    • FLOAT
    • INT
    β—„phase1β–Ί
    β—„amplitude0.5β–Ί
    β—„x_translation0β–Ί
    β—„y_translation0.50β–Ί
    β—„current_frame1β–Ί

    If SinWave is the breathing, TriangleWave is the panning. It ramps linearly from one extreme to the other, then turns around and ramps back - a smooth, constant-speed motion with a sharp reversal at each end. Sin eases into its peaks and valleys; a triangle wave doesn't bother, it just goes. For things like a camera or subject sliding across the frame, or any parameter that should move at a steady rate and bounce back, this is the better tool.

    The formula is the same shape as the sine family:

    value = y_translation + (amplitude / Ο€) Γ— arcsin(sin(2Ο€/phase Γ— current_frame βˆ’ x_translation))
    

    which is a classic way of turning a sine into a triangle: same five inputs (phase, amplitude, x_translation, y_translation, current_frame), same meanings - phase for cycle length in frames, amplitude for swing, y_translation for the center, x_translation to shift where the cycle starts. Output is FLOAT with an INT twin.

    When triangle beats sine

    Pick triangle whenever the speed of the motion matters more than its smoothness. A camera pan or dolly should cross the frame at constant velocity - a sine will visibly slow down near the edges, which reads as a hiccup on a long move. A triangle wave doesn't. Same for an element sliding back and forth, or a value that should spend equal time going up and down. If you want the eased, organic feel instead, stay on SinWave; if you want a sawtooth that resets sharply (think a scanning line), there's a SawtoothWave for that, which is triangle's angrier cousin.

    Install and gotchas

    Part of the FizzNodes pack: ComfyUI Manager β†’ search FizzNodes β†’ install β†’ restart, or manually:

    cd ComfyUI/custom_nodes
    git clone https://github.com/FizzleDorf/ComfyUI_FizzNodes
    cd ComfyUI_FizzNodes && pip install -r requirements.txt
    

    numpy, pandas, numexpr only. Under FizzNodes πŸ“…πŸ…•πŸ… β†’ WaveNodes.

    The thing to remember is that the reversal is abrupt by design - the value turns around in a single frame. If that sharp corner looks wrong to you, you wanted a sine. And, as with all the wave nodes, it only moves if current_frame advances: in a non-animated single render you'll get one constant output and it'll look broken. It isn't.

    CategoryFizzNodes πŸ“…πŸ…•πŸ…/WaveNodes

    Inputs (5)

    NameTypeDefaultDescription
    phaseFLOAT10–9999β€”
    amplitudeFLOAT0.50–9999β€”
    x_translationFLOAT00–9999β€”
    y_translationFLOAT0.500–9999β€”
    current_frameINT10–9999β€”

    Outputs (2)

    NameTypeDescription
    FLOATFLOATβ€”
    INTINTβ€”