Skip to content

feat: add CurveInput wrapper class with interp method#12986

Merged
jtydhr88 merged 1 commit intocurve-nodefrom
curve-node-wrapper
Mar 16, 2026
Merged

feat: add CurveInput wrapper class with interp method#12986
jtydhr88 merged 1 commit intocurve-nodefrom
curve-node-wrapper

Conversation

@christian-byrne
Copy link
Copy Markdown
Contributor

Summary

Demo PR targeting curve-node branch to show what the wrapper class + interpolation function should look like.

Changes

CurveInput class (comfy_api/latest/_input/basic_types.py):

  • Wraps raw list[tuple[float, float]] control points
  • interp(x): Monotone cubic Hermite interpolation matching the frontend createMonotoneInterpolator in curveUtils.ts
  • to_lut(size): Generate a lookup table of evenly-spaced samples
  • Pre-computes slopes on construction for efficient repeated evaluation

Type wiring:

  • Curve.Type = CurveInput (under TYPE_CHECKING)
  • Exported from comfy_api.input and comfy_api.latest._input

CurveEditor node:

  • Now wraps raw widget points in CurveInput before outputting
  • Handles both raw lists and already-wrapped CurveInput instances

Usage by downstream nodes

def execute(self, curve: io.Curve.Type):
    # Evaluate the curve at x=0.5
    y = curve.interp(0.5)
    # Generate a 256-entry LUT
    lut = curve.to_lut(256)
    # Access raw points
    points = curve.points

cc @jtydhr88 — this demonstrates the wrapper class and interp function we discussed. Feel free to merge into your branch or adapt as needed.

CurveInput is an abstract base class so future curve representations
(bezier, LUT-based, analytical functions) can be added without breaking
downstream nodes that type-check against CurveInput.

MonotoneCubicCurve is the concrete implementation that:
- Mirrors frontend createMonotoneInterpolator (curveUtils.ts) exactly
- Pre-computes slopes as numpy arrays at construction time
- Provides vectorised interp_array() using numpy for batch evaluation
- interp() for single-value evaluation
- to_lut() for generating lookup tables

CurveEditor node wraps raw widget points in MonotoneCubicCurve.
@jtydhr88 jtydhr88 merged commit 62d9a99 into curve-node Mar 16, 2026
8 checks passed
@jtydhr88
Copy link
Copy Markdown
Contributor

I merged this and will add one more type of curve - linear, then make changes on FE

@jtydhr88 jtydhr88 deleted the curve-node-wrapper branch March 16, 2026 18:39
jtydhr88 pushed a commit that referenced this pull request Mar 18, 2026
CurveInput is an abstract base class so future curve representations
(bezier, LUT-based, analytical functions) can be added without breaking
downstream nodes that type-check against CurveInput.

MonotoneCubicCurve is the concrete implementation that:
- Mirrors frontend createMonotoneInterpolator (curveUtils.ts) exactly
- Pre-computes slopes as numpy arrays at construction time
- Provides vectorised interp_array() using numpy for batch evaluation
- interp() for single-value evaluation
- to_lut() for generating lookup tables

CurveEditor node wraps raw widget points in MonotoneCubicCurve.
jtydhr88 pushed a commit that referenced this pull request Mar 21, 2026
CurveInput is an abstract base class so future curve representations
(bezier, LUT-based, analytical functions) can be added without breaking
downstream nodes that type-check against CurveInput.

MonotoneCubicCurve is the concrete implementation that:
- Mirrors frontend createMonotoneInterpolator (curveUtils.ts) exactly
- Pre-computes slopes as numpy arrays at construction time
- Provides vectorised interp_array() using numpy for batch evaluation
- interp() for single-value evaluation
- to_lut() for generating lookup tables

CurveEditor node wraps raw widget points in MonotoneCubicCurve.
jtydhr88 added a commit that referenced this pull request Mar 24, 2026
* CURVE node

* remove curve to sigmas node

* feat: add CurveInput ABC with MonotoneCubicCurve implementation (#12986)

CurveInput is an abstract base class so future curve representations
(bezier, LUT-based, analytical functions) can be added without breaking
downstream nodes that type-check against CurveInput.

MonotoneCubicCurve is the concrete implementation that:
- Mirrors frontend createMonotoneInterpolator (curveUtils.ts) exactly
- Pre-computes slopes as numpy arrays at construction time
- Provides vectorised interp_array() using numpy for batch evaluation
- interp() for single-value evaluation
- to_lut() for generating lookup tables

CurveEditor node wraps raw widget points in MonotoneCubicCurve.

* linear curve

* refactor: move CurveEditor to comfy_extras/nodes_curve.py with V3 schema

* feat: add HISTOGRAM type and histogram support to CurveEditor

* code improve

---------

Co-authored-by: Christian Byrne <cbyrne@comfy.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants