chickadee » web-colors » normalize-web-color

normalize-web-color color-listprocedure

Returns a normalized copy of the given color list. All values are clamped or wrapped to their typical range.

  • For rgb color lists, red/green/blue are rounded to the nearest integers and clamped to [0, 255], and alpha is clamped to [0, 1].
  • For rgb% color lists, all values are clamped to [0, 1].
  • For hsl color lists, hue is rounded to the nearest integer and wrapped (not clamped) to [0, 360), and alpha is clamped to [0, 1].

Signals an error if the color list is invalid.