polychrome

github.com ↗

Parse a CSS colour and chain adjustments in JavaScript.

SI Score
80/100
Pricing
Open Source AI reading, not confirmed
Free plan
Not confirmed
Sign-up required
Not confirmed

Ask SI about polychrome

Answers use saved listing facts and recorded sources.
Homepage screenshot
Screenshot of the polychrome homepage

What it does

polychrome is a JavaScript library for parsing and manipulating colour strings. Its documented inputs are three- or six-digit hex, RGB and HSL forms, including alpha forms for RGB and HSL. Methods return CSS-compatible hex, RGB or HSL output. Its JavaScript source is MIT-licensed and open for modification and redistribution.

Create a colour object, apply adjustments, then choose an output method. For example, darkening and fading can be chained before requesting an RGB string; an alpha value produces the corresponding RGBA form.

Setting and adjusting have different meanings. setLightness(value) supplies an absolute lightness, while lighten(percentage) changes the existing colour. Omitted arguments also behave differently: an absolute setter makes no change, lightening defaults to 10%, and fading defaults to 50%.

The object exposes numerical channels for inspection. Hue rotation wraps around the colour wheel, while tint and shade mix the colour with white and black respectively.

Strengths

  • Absolute setters and relative adjustments are separate methods.
  • Chainable transformations finish in standard CSS string formats.

Watch out for

  • Documented hex input accepts three or six digits.

Best for

  • JavaScript interfaces deriving related CSS colours.

Sources