import { clamp01 } from "@thi.ng/math/interval" ; import { fract } from "@thi.ng/math/prec" ; import { setC4 } from "@thi.ng/vectors/setc" ; import type { Color , ReadonlyColor } from "./api.js" ; import { __ensureAlpha } from "./internal/ensure.js" ; param out param src param alpha export const clamp = ( out , src , alpha = 1 ) => setC4 ( out || src , clamp01 ( src [ 0 ] ) , clamp01 ( src [ 1 ] ) , clamp01 ( src [ 2 ] ) , __ensureAlpha ( src [ 3 ] , alpha ) ) ; /**
 * Similar to  clamp , but calls `ensureHue` to fold (instead of
 * clamping) the hue into [0,1] interval.
 *
 *  param out param src param alpha export const clampH = ( out , src , alpha = 1 ) => setC4 ( out || src , fract ( src [ 0 ] ) , clamp01 ( src [ 1 ] ) , clamp01 ( src [ 2 ] ) , __ensureAlpha ( src [ 3 ] , alpha ) ) ;