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

Function rgbToHex

apps/sim/lib/colors/convert.ts:25–28  ·  view source on GitHub ↗
(r: number, g: number, b: number)

Source from the content-addressed store, hash-verified

23
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
30/** Convert RGB (0-255) to HSL (h: 0-360, s: 0-1, l: 0-1). */
31export function rgbToHsl(r: number, g: number, b: number): { h: number; s: number; l: number } {

Callers 12

applyTintFunction · 0.90
applyShadeFunction · 0.90
applyLumModFunction · 0.90
applyLumOffFunction · 0.90
applySatModFunction · 0.90
applyHueModFunction · 0.90
applyHueOffFunction · 0.90
applySatOffFunction · 0.90
mixRgbFunction · 0.90
renderShapeFunction · 0.90
resolveColorUncachedFunction · 0.90
convert.test.tsFile · 0.90

Calls 3

joinMethod · 0.80
clampFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected