Code Explainers

Code explainers tagged #clamping

typescript
type RGB = { r: number; g: number; b: number };
 
function parseHex(hex: string): RGB {
  const normalized = hex.replace(/^#/, "").trim();

Lightening and darkening hex colors in TypeScript

bitwise color-manipulation parsing
Intermediate 9 steps