{"record":{"id":"d7d96af3e9ee3f50","repo":"heygen-com/hyperframes","slug":"a-color-curve-supports-at-most-hf-color-curve-ma","errorCode":null,"errorMessage":"A color curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points","messagePattern":"A color curve supports at most (.+?) points","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/colorGradingCurves.ts","lineNumber":159,"sourceCode":"      input,\n      start,\n      end,\n      valueAt(tangents, segment),\n      valueAt(tangents, segment + 1),\n    );\n    samples[index] = Math.min(outputMax, Math.max(outputMin, output));\n  }\n  return samples;\n}\n\n/** Samples a shape-preserving cubic curve into a GPU-ready 1D lookup table. */\nexport function compileHfColorCurve(\n  points: readonly HfColorCurvePoint[],\n  size = HF_COLOR_CURVE_LUT_SIZE,\n): Float32Array {\n  validateCurvePoints(points, size);\n  if (points.length > HF_COLOR_CURVE_MAX_POINTS) {\n    throw new RangeError(`A color curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points`);\n  }\n  if (points.some(([input]) => input < 0 || input > 1)) {\n    throw new RangeError(\"Color curve inputs must be between 0 and 1\");\n  }\n  if (points[0]?.[0] !== 0 || points[points.length - 1]?.[0] !== 1) {\n    throw new RangeError(\"Color curves must include input endpoints 0 and 1\");\n  }\n  return compileCurveSamples(points, size, (index) => index / (size - 1), 0, 1);\n}\n\n/** Samples a periodic hue curve without duplicating the 0/360-degree texel. */\nexport function compileHfHueCurve(\n  points: readonly HfHueCurvePoint[],\n  outputMin: number,\n  outputMax: number,\n  size = HF_COLOR_CURVE_LUT_SIZE,\n): Float32Array {\n  if (points.length < 3) throw new RangeError(\"A hue curve requires at least three points\");","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/core/src/colorGradingCurves.ts#L141-L177","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\ncompileHfColorCurve(hugePoints); // > MAX_POINTS\n\n// after — resample to the cap\nimport { HF_COLOR_CURVE_MAX_POINTS } from \"@hyperframes/core\";\nconst step = Math.ceil(hugePoints.length / HF_COLOR_CURVE_MAX_POINTS);\nconst trimmed = hugePoints.filter((_, i) => i % step === 0).slice(0, HF_COLOR_CURVE_MAX_POINTS);\ncompileHfColorCurve(trimmed);","handlingStrategy":"validation","validationCode":"import { HF_COLOR_CURVE_MAX_POINTS } from \"@hyperframes/core\";\nif (points.length > HF_COLOR_CURVE_MAX_POINTS) {\n  const step = Math.ceil(points.length / HF_COLOR_CURVE_MAX_POINTS);\n  points = points.filter((_, i) => i % step === 0).slice(0, HF_COLOR_CURVE_MAX_POINTS);\n}","typeGuard":"import { HF_COLOR_CURVE_MAX_POINTS } from \"@hyperframes/core\";\nfunction withinPointLimit(points: readonly unknown[]): boolean {\n  return points.length <= HF_COLOR_CURVE_MAX_POINTS;\n}","tryCatchPattern":"try { compileHfColorCurve(pts); }\ncatch (err) { if (/at most .* points/.test(String(err))) { /* downsample */ } else throw err; }","preventionTips":["Downsample dense curves (uniform resample or simplification) to <= HF_COLOR_CURVE_MAX_POINTS.","Cap the UI point count to the same constant."],"tags":["color-grading","curve","validation","range","limits"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}