Turn anything into a color!
If you are using lolcolor
in javascript code, a simple install will add it to your dependencies.
npm install lolcolor
If this is getting bundled into front-end javascript, you might want to install into your devDependencies instead.
npm install -D lolcolor
If requiring easy use via command-line, install globally.
npm install -g lolcolor
If not running often, consider using npx
instead of a global install.
npx lolcolor "Hey now, you're an all star"
lolcolor
can be used from the command line.
lolcolor "get your game on, go play"
The simplest way to use lolcolor
in code is as a simple function.
const lolcolor = require('lolcolor');
const text = 'Hey now, you\'re a rock star';
console.log(lolcolor(text));
If you need a bit more control over your colors you can use the ColorBuilder.
const { ColorBuilder } = require('lolcolor');
const builderText = 'get the show on, get paid';
const colorBuilder = new ColorBuilder();
const [colorR, colorG, colorB] = colorBuilder.fromString(builderText).asRgb().butOnly64Colors().create();
console.log(`Red value:${colorR}, Green value:${colorG}, Blue value:${colorB}`);
Category | Method | Parameters | Description |
---|---|---|---|
Begin | fromString | source | The input text |
Create | create | (none) | Output your color |
Color mode | asHex | (none) | Use hex color mode |
Color mode | asHsl | (none) | Use HSL color mode |
Color mode | asRgb | (none) | Use RGB color mode |
Color limit | butOnly8Colors | (none) | Only choose from 8 colors |
Color limit | butOnly64Colors | (none) | Only choose from 64 colors (6-bit) |
Color limit | butOnly256Colors | (none) | Only choose from 256 colors |