heygen-com/hyperframes · error · RangeError

Hue curve inputs must be from 0 up to 360 degrees

Error message

Hue curve inputs must be from 0 up to 360 degrees

What it means

Hue is periodic over [0, 360). The check at line 184 rejects any point whose first element is negative or >= 360. 360 itself is excluded because it is identical to 0 on the circle and would collide with a 0-anchored point after the periodic padding step adds clones at +/-360.

Source

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

  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`);
  }
  const sorted = [...points].sort((a, b) => a[0] - b[0]);
  for (let index = 0; index < sorted.length; index += 1) {
    const point = sorted[index];
    if (!point || point[0] < 0 || point[0] >= 360) {
      throw new RangeError("Hue curve inputs must be from 0 up to 360 degrees");
    }
    if (index > 0 && point[0] === sorted[index - 1]?.[0]) {
      throw new RangeError("Hue curve inputs must be unique");
    }
  }
  const before = sorted.slice(-2).map(([hue, delta]) => [hue - 360, delta] as const);
  const after = sorted.slice(0, 2).map(([hue, delta]) => [hue + 360, delta] as const);
  const periodic = [...before, ...sorted, ...after];
  validateCurvePoints(periodic, size);
  return compileCurveSamples(periodic, size, (index) => (index / size) * 360, outputMin, outputMax);
}

View on GitHub (pinned to c2996c8626)

Solutions

  1. Wrap any hue h into [0, 360) with ((h % 360) + 360) % 360 before building the point.
  2. Replace a literal 360 with 0 (or with a value just under 360 if you need a near-seam control point).
  3. If consuming normalized 0..1 hue, multiply by 360 first.

Example fix

// before
compileHfHueCurve([[0, 0.1], [180, 0.0], [360, 0.1]], -1, 1);

// after — wrap 360 to 0 (use 359 if you need a near-seam point)
compileHfHueCurve([[0, 0.1], [180, 0.0], [359, 0.1]], -1, 1);
Defensive patterns

Strategy: validation

Validate before calling

function wrapHue(h: number): number {
  return ((h % 360) + 360) % 360;
}

const wrapped = points.map(([hue, delta]) => [wrapHue(hue), delta] as const);
compileHfHueCurve(wrapped, -1, 1);

Type guard

function isHueInValidRange(points: readonly unknown[]): points is [number, number][] {
  return Array.isArray(points) && points.every(
    (p) => Array.isArray(p) && typeof p[0] === 'number' && p[0] >= 0 && p[0] < 360,
  );
}

Try / catch

try {
  compileHfHueCurve(points, -1, 1);
} catch (err) {
  if (err instanceof RangeError && err.message === 'Hue curve inputs must be from 0 up to 360 degrees') {
    // wrap all hues into [0,360) and retry
  } else throw err;
}

Prevention

When it happens

Trigger: Calling compileHfHueCurve with a point like [360, 0.2], [-10, 0.1], or [400, 0]. The sort at line 181 runs first, so order does not matter.

Common situations: Using 360 as the 'end' value (common when authors think of hue as a closed 0..360 segment); passing hue expressed as a 0..1 normalized float; signed hue offsets that go negative.

Related errors


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