gradstop

github.com ↗

Generate a short sequence of gradient stops from supplied colours.

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

Ask SI about gradstop

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

What it does

gradstop is a small JavaScript library that creates intermediate colour values. Its configuration sets the stop count, input format and up to four source colours, using hex, RGB or HSL inputs. The code uses the MIT licence.

Install the package with npm install gradstop, import it and pass an object containing stops, inputFormat and colorArray. The supplied example turns two hex colours into five RGB values, which can feed a chart legend or another stepped colour display.

Both three-digit and six-digit hex inputs are accepted. Five stops and a white-to-black input are the defaults. Environments without Math.trunc need a replacement implementation of that JavaScript function.

The MIT licence permits commercial use and modification. Keep its copyright and permission notices with copies or substantial portions of the library.

Strengths

  • The stop count and input format are explicit configuration options.
  • Output is a sequence of values that can be used by other code.

Watch out for

  • The input array supports at most four source colours.
  • JavaScript environments missing Math.trunc need a compatibility replacement.

Best for

  • Developers generating short stepped colour sequences in JavaScript.

Sources