heygen-com/hyperframes · error · RangeError

Color curve inputs must be between 0 and 1

Error message

Color curve inputs must be between 0 and 1

What it means

compileHfColorCurve() requires every point's input (first element) to be within [0, 1] inclusive. Inputs outside that range are a RangeError because the color curve maps the normalized [0,1] tonal range to output values; an input like -0.1 or 1.2 has no defined texel in the LUT sampling grid (which spans 0..1 via index/(size-1)).

Source

Thrown at packages/core/src/colorGradingCurves.ts:162

      valueAt(tangents, segment),
      valueAt(tangents, segment + 1),
    );
    samples[index] = Math.min(outputMax, Math.max(outputMin, output));
  }
  return samples;
}

/** Samples a shape-preserving cubic curve into a GPU-ready 1D lookup table. */
export function compileHfColorCurve(
  points: readonly HfColorCurvePoint[],
  size = HF_COLOR_CURVE_LUT_SIZE,
): Float32Array {
  validateCurvePoints(points, size);
  if (points.length > HF_COLOR_CURVE_MAX_POINTS) {
    throw new RangeError(`A color curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points`);
  }
  if (points.some(([input]) => input < 0 || input > 1)) {
    throw new RangeError("Color curve inputs must be between 0 and 1");
  }
  if (points[0]?.[0] !== 0 || points[points.length - 1]?.[0] !== 1) {
    throw new RangeError("Color curves must include input endpoints 0 and 1");
  }
  return compileCurveSamples(points, size, (index) => index / (size - 1), 0, 1);
}

/** Samples a periodic hue curve without duplicating the 0/360-degree texel. */
export function compileHfHueCurve(
  points: readonly HfHueCurvePoint[],
  outputMin: number,
  outputMax: number,
  size = HF_COLOR_CURVE_LUT_SIZE,
): Float32Array {
  if (points.length < 3) throw new RangeError("A hue curve requires at least three points");
  if (points.length > HF_COLOR_CURVE_MAX_POINTS) {
    throw new RangeError(`A hue curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points`);
  }

View on GitHub (pinned to c2996c8626)

Solutions

  1. Normalize all inputs to [0,1] before compiling: divide 0-255 values by 255, or 0-100 by 100.
  2. Clamp stray inputs: points.map(([i,o]) => [Math.min(1, Math.max(0, i)), o]).

Example fix

// before — inputs on a 0-255 scale
compileHfColorCurve([[0, 0], [128, 0.5], [255, 1]]); // 128 and 255 > 1

// after — normalize to 0..1
const norm = [[0,0],[128,0.5],[255,1]].map(([i,o]) => [i/255, o] as const);
compileHfColorCurve(norm);
Defensive patterns

Strategy: validation

Validate before calling

const normalized = points.map(([i, o]) => [Math.min(1, Math.max(0, i)), o] as const);
// if source is 0-255: i/255; if 0-100: i/100

Type guard

function inputsInUnitRange(points: readonly (readonly [number, number])[]): boolean {
  return points.every(([i]) => i >= 0 && i <= 1);
}

Try / catch

try { compileHfColorCurve(pts); }
catch (err) { if (/between 0 and 1/.test(String(err))) { pts = pts.map(([i,o]) => [Math.min(1, Math.max(0, i)), o] as const); } else throw err; }

Prevention

When it happens

Trigger: A point with input -0.05 or 1.1; inputs expressed in a different unit (0-255, 0-100) instead of normalized 0-1; a slider with a range beyond [0,1].

Common situations: Importing a curve whose x-axis is 0-255 (8-bit) or 0-100 (percent) without normalizing; UI slider configured with the wrong bounds; signed-error input.

Related errors


AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12). Data as JSON: /api/errors/3ebeff6cca62fca9. Report an issue: GitHub.