heygen-com/hyperframes · error · RangeError
A color curve supports at most ${HF_COLOR_CURVE_MAX_POINTS}
Error message
A color curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points What it means
compileHfColorCurve() caps the number of control points at HF_COLOR_CURVE_MAX_POINTS (sourced from COLOR_GRADING_MAX_CURVE_POINTS in the parsers contract). More points than the cap is a RangeError. The limit exists because the GPU shader / LUT pipeline reserves fixed storage and because shape-preserving cubic interpolation degrades with dense, noisy control sets.
Source
Thrown at packages/core/src/colorGradingCurves.ts:159
input,
start,
end,
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");View on GitHub (pinned to c2996c8626)
Solutions
- Downsample/simplify the curve to at most HF_COLOR_CURVE_MAX_POINTS (e.g. Douglas-Peucker or uniform resampling) before compiling.
- Cap the number of points a user can add in the UI to the same constant.
Example fix
// before
compileHfColorCurve(hugePoints); // > MAX_POINTS
// after — resample to the cap
import { HF_COLOR_CURVE_MAX_POINTS } from "@hyperframes/core";
const step = Math.ceil(hugePoints.length / HF_COLOR_CURVE_MAX_POINTS);
const trimmed = hugePoints.filter((_, i) => i % step === 0).slice(0, HF_COLOR_CURVE_MAX_POINTS);
compileHfColorCurve(trimmed); Defensive patterns
Strategy: validation
Validate before calling
import { HF_COLOR_CURVE_MAX_POINTS } from "@hyperframes/core";
if (points.length > HF_COLOR_CURVE_MAX_POINTS) {
const step = Math.ceil(points.length / HF_COLOR_CURVE_MAX_POINTS);
points = points.filter((_, i) => i % step === 0).slice(0, HF_COLOR_CURVE_MAX_POINTS);
} Type guard
import { HF_COLOR_CURVE_MAX_POINTS } from "@hyperframes/core";
function withinPointLimit(points: readonly unknown[]): boolean {
return points.length <= HF_COLOR_CURVE_MAX_POINTS;
} Try / catch
try { compileHfColorCurve(pts); }
catch (err) { if (/at most .* points/.test(String(err))) { /* downsample */ } else throw err; } Prevention
- Downsample dense curves (uniform resample or simplification) to <= HF_COLOR_CURVE_MAX_POINTS.
- Cap the UI point count to the same constant.
When it happens
Trigger: Passing an array longer than HF_COLOR_CURVE_MAX_POINTS to compileHfColorCurve; a curve-editing tool that lets the user add unlimited points; importing an oversized curve from another tool.
Common situations: Automated point generation (e.g. sampling a photo's tone response at many stops) exceeding the cap; UI with no upper bound on point count; merging multiple curves into one.
Related errors
- A color curve requires at least two points
- Curve LUT size must be at least 2
- Color curve inputs must be strictly increasing
- Curve output bounds must be finite and increasing
- Curve outputs must be between ${outputMin} and ${outputMax}
AI-assisted analysis of heygen-com/hyperframes@c2996c8626 (2026-08-12).
Data as JSON: /api/errors/d7d96af3e9ee3f50.
Report an issue: GitHub.