{"record":{"id":"3ebeff6cca62fca9","repo":"heygen-com/hyperframes","slug":"color-curve-inputs-must-be-between-0-and-1","errorCode":null,"errorMessage":"Color curve inputs must be between 0 and 1","messagePattern":"Color curve inputs must be between 0 and 1","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/colorGradingCurves.ts","lineNumber":162,"sourceCode":"      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\");\n  if (points.length > HF_COLOR_CURVE_MAX_POINTS) {\n    throw new RangeError(`A hue curve supports at most ${HF_COLOR_CURVE_MAX_POINTS} points`);\n  }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/core/src/colorGradingCurves.ts#L144-L180","documentation":"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)).","triggerScenarios":"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].","commonSituations":"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.","solutions":["Normalize all inputs to [0,1] before compiling: divide 0-255 values by 255, or 0-100 by 100.","Clamp stray inputs: points.map(([i,o]) => [Math.min(1, Math.max(0, i)), o])."],"exampleFix":"// before — inputs on a 0-255 scale\ncompileHfColorCurve([[0, 0], [128, 0.5], [255, 1]]); // 128 and 255 > 1\n\n// after — normalize to 0..1\nconst norm = [[0,0],[128,0.5],[255,1]].map(([i,o]) => [i/255, o] as const);\ncompileHfColorCurve(norm);","handlingStrategy":"validation","validationCode":"const normalized = points.map(([i, o]) => [Math.min(1, Math.max(0, i)), o] as const);\n// if source is 0-255: i/255; if 0-100: i/100","typeGuard":"function inputsInUnitRange(points: readonly (readonly [number, number])[]): boolean {\n  return points.every(([i]) => i >= 0 && i <= 1);\n}","tryCatchPattern":"try { compileHfColorCurve(pts); }\ncatch (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; }","preventionTips":["Normalize all inputs to [0,1] (divide 0-255 by 255, 0-100 by 100) before compiling.","Clamp stray inputs into [0,1].","Configure UI sliders with bounds [0,1]."],"tags":["color-grading","curve","validation","range","normalization"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}