2.0.2 • Published 3 years ago

coloras v2.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

👨‍💻 User friendly color manipulation library & CLI tool

Install

Module:

$ npm install coloras

CLI:

$ npm install -g coloras

Module

Usage

const { Color } = require("coloras");

const color = new Color("#1f1f1f"); // Create a new Color instance

color.toHex(); // -> #1f1f1f
color.toRgb(); // -> rgb(31, 31, 31)
color.toHsl(); // -> hsl(0, 0%, 12%)
color.toHsv(); // -> hsv(0, 0%, 12%)
color.toCmyk(); // -> cmyk(0, 0, 0, 88)

color.toArray(); // -> ["1f","1f","1f"]

color.imageUrl; // -> https://dummyimage.com/600x400/1f1f1f/1f1f1f.png

Create a random color

const { Color } = require("coloras");

// Create a random color by not passing any parameters in the constructor
const random = new Color(); 

random.toHex(); // Generated color in hex format
random.toRgb(); // Generated color in rgb format
random.toHsl(); // Generated color in hsl format
random.toHsv(); // Generated color in hsv format
random.toCmyk(); // Generated color in cmyk format

random.toArray(); /* -> 
{ 
  hex: Array<string>,
  rgb: Array<string>,
  hsl: Array<string>,
  hsv: Array<string>,
  cmyk: Array<string>
} */

random.toArray().hex; // Array with generated hex color values

random.imageUrl; // An image url for the random color

Check if a string is a color and, if so, also check its color system

const { isColor } = require("coloras");

// isColor(color: string): { color: boolean, colorSystem: string | null }

isColor("#1f1f1f"); // -> { color: true, colorSystem: "hex" }
isColor("coloras"); // -> { color: false, colorSystem: null }

CLI

Usage

coloras <command>

See usage examples here!

Commands

  • coloras <-version|-v>
  • coloras help
  • coloras <convert|conv> [-copy|-c]
  • coloras <generate|gen> [-copy|-c]
  • coloras <image|img> [-copy|-c]
CommandAliasDescriptionFlagsExample
-version-vOutput current versioncoloras -v
helpOutput usage/help informationcoloras help
convertconvConvert a color among different color systems-copy ; -c Copy the color to clipboardcoloras conv -c
generategenGenerate a random color-copy ; -c Copy the color to clipboardcoloras gen -c
imageimgGet an image url for a color-copy ; -c Copy the url to clipboardcoloras img -c

Contributing

Contributing, issues and feature requests are welcome.

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.7

3 years ago