MCPcopy Index your code
hub / github.com/simstudioai/sim / clamp

Function clamp

apps/sim/lib/colors/convert.ts:26–26  ·  view source on GitHub ↗
(v: number)

Source from the content-addressed store, hash-verified

24/** Convert RGB components (0-255 each) to a 6-digit `#rrggbb` hex string. */
25export function rgbToHex(r: number, g: number, b: number): string {
26 const clamp = (v: number): number => Math.max(0, Math.min(255, Math.round(v)))
27 return `#${[clamp(r), clamp(g), clamp(b)].map((c) => c.toString(16).padStart(2, '0')).join('')}`
28}
29

Callers 1

rgbToHexFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected