1.0.4 • Published 4 years ago
js-colors v1.0.4
JS-Colors
- Color in JS
Example usage
Get data from a color rgb
import { Color } from "js-colors"; // Or const { Color } = require("js-colors")
let blue = new Color(0, 0, 255); // input can be a number or a hex string or a rgb
console.log(blue.name); // blue
console.log(blue.hex); // #0000ff
console.log(blue.rgb); // [0, 0, 255]
console.log(blue.colorNumber); // 255
Get data from a color name
import { Color } from "js-colors"; // Or const { Color } = require("js-colors")
let blue = new Color("blue"); // input can be a number or a hex string or a rgb
console.log(blue.name); // blue
console.log(blue.hex); // #0000ff
console.log(blue.rgb); // [0, 0, 255]
console.log(blue.colorNumber); // 255
Get data from a color number
import { Color } from "js-colors"; // Or const { Color } = require("js-colors")
let blue = new Color(255); // input can be a number or a hex string or a rgb
console.log(blue.name); // blue
console.log(blue.hex); // #0000ff
console.log(blue.rgb); // [0, 0, 255]
console.log(blue.colorNumber); // 255