JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 786642
  • Score
    100M100P100Q179368F
  • License MIT

Beautiful gradients in terminal stdout

Package Exports

  • gradient-string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (gradient-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

gradient-string

XO code style

Beautiful gradients in terminal stdout

Install

$ npm install --save gradient-string

Usage

const gradient = require('gradient-string');
const log = console.log;

log(gradient('cyan', 'pink')('Hello world!'));

Initialize a gradient

// using varargs
let coolGradient = gradient('red', 'green', 'blue');

// using array
let coolGradient = gradient([ '#FF0000', '#00FF00', '#0000FF' ]);

The colors are parsed with TinyColor, multiple formats are accepted.

let coolGradient = gradient([
  tinycolor('#FFBB65'),       // tinycolor object
  {r: 0, g: 255, b: 0},       // RGB object
  {h: 240, s: 1, v: 1, a: 1}, // HSVa object
  'rgb(120, 120, 0)',         // RGB CSS string
  'gold'                      // named color
]);

You can also specify the position of each color stop (between 0 and 1). If no position is specified, stops are distributed equidistantly.

let coolGradient = gradient([
  {color: '#d8e0de', pos: 0},
  {color: '#255B53', pos: 0.8},
  {color: '#000000', pos: 1}
]);

Use a gradient

let coolString = coolGradient('This is a string colored with gradient-string!')
log(coolString);

Dependencies

License

MIT © Boris K