{"record":{"id":"2ba45fc1c9ef72c5","repo":"heygen-com/hyperframes","slug":"hue-curve-inputs-must-be-from-0-up-to-360-degrees","errorCode":null,"errorMessage":"Hue curve inputs must be from 0 up to 360 degrees","messagePattern":"Hue curve inputs must be from 0 up to 360 degrees","errorType":"validation","errorClass":"RangeError","httpStatus":null,"severity":"error","filePath":"packages/core/src/colorGradingCurves.ts","lineNumber":185,"sourceCode":"  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  }\n  const sorted = [...points].sort((a, b) => a[0] - b[0]);\n  for (let index = 0; index < sorted.length; index += 1) {\n    const point = sorted[index];\n    if (!point || point[0] < 0 || point[0] >= 360) {\n      throw new RangeError(\"Hue curve inputs must be from 0 up to 360 degrees\");\n    }\n    if (index > 0 && point[0] === sorted[index - 1]?.[0]) {\n      throw new RangeError(\"Hue curve inputs must be unique\");\n    }\n  }\n  const before = sorted.slice(-2).map(([hue, delta]) => [hue - 360, delta] as const);\n  const after = sorted.slice(0, 2).map(([hue, delta]) => [hue + 360, delta] as const);\n  const periodic = [...before, ...sorted, ...after];\n  validateCurvePoints(periodic, size);\n  return compileCurveSamples(periodic, size, (index) => (index / size) * 360, outputMin, outputMax);\n}\n","sourceCodeStart":167,"sourceCodeEnd":197,"githubUrl":"https://github.com/heygen-com/hyperframes/blob/c2996c8626135db5253519359d8a063d3bafad8d/packages/core/src/colorGradingCurves.ts#L167-L197","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Wrap any hue h into [0, 360) with ((h % 360) + 360) % 360 before building the point.","Replace a literal 360 with 0 (or with a value just under 360 if you need a near-seam control point).","If consuming normalized 0..1 hue, multiply by 360 first."],"exampleFix":"// before\ncompileHfHueCurve([[0, 0.1], [180, 0.0], [360, 0.1]], -1, 1);\n\n// after — wrap 360 to 0 (use 359 if you need a near-seam point)\ncompileHfHueCurve([[0, 0.1], [180, 0.0], [359, 0.1]], -1, 1);","handlingStrategy":"validation","validationCode":"function wrapHue(h: number): number {\n  return ((h % 360) + 360) % 360;\n}\n\nconst wrapped = points.map(([hue, delta]) => [wrapHue(hue), delta] as const);\ncompileHfHueCurve(wrapped, -1, 1);","typeGuard":"function isHueInValidRange(points: readonly unknown[]): points is [number, number][] {\n  return Array.isArray(points) && points.every(\n    (p) => Array.isArray(p) && typeof p[0] === 'number' && p[0] >= 0 && p[0] < 360,\n  );\n}","tryCatchPattern":"try {\n  compileHfHueCurve(points, -1, 1);\n} catch (err) {\n  if (err instanceof RangeError && err.message === 'Hue curve inputs must be from 0 up to 360 degrees') {\n    // wrap all hues into [0,360) and retry\n  } else throw err;\n}","preventionTips":["Wrap hue with ((h % 360) + 360) % 360 at the data boundary.","Replace literal 360 with 0 (or 359 for a near-seam point).","If consuming 0..1 normalized hue, multiply by 360 before constructing points."],"tags":["color-grading","hue","range","range-error"],"backgroundTag":null,"analyzedSha":"c2996c8626135db5253519359d8a063d3bafad8d","analyzedAt":"2026-08-12T22:18:56.877Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}