1.0.2 • Published 3 years ago

orange-colors v1.0.2

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

Orange Colors

Library for working with colors: RGB to HSV and HSV to RGB transformations; color modification by any component.

Classes

OrangeColor

Class instance represents one color and allows to modify and convert it.

Static methods provide color format transformations functionality.

ElementNameDescriptionArgumentsReturn type
constructorCreates color objectinput
methodcloneClones objectOrangeColor
propertyhex_stringColor hex RRGGBB representationstring
propertyhtml_stringColor hex RRGGBB representation with starting "#"string
propertyrgbColor HSV (Hue Saturation Value) representation{"h": number, "s": number, "v": number}
propertyhColor hue componentnumber
propertysColor saturation componentnumber
propertyvColor value componentnumber
propertyrgbColor RGB (Red, Green, Blue) representation{"r": number, "g": number, "b": number}
propertyrColor red componentnumber
propertygColor green componentnumber
propertybColor blue componentnumber
static methodHEX2RGBConverts RRGGBB string to RGB objectrgb_hex_string{"r": number, "g": number, "b": number}
static methodRGB2HEXConverts RGB object to RRGGBB stringrgbstring
static methodRGB2HSVConverts RGB object to HSV objectrgb, round{"h": number, "s": number, "v": number}
static methodHSV2RGBConverts HSV object to RGB objecthsv, round{"r": number, "g": number, "b": number}

Examples

Let's say you have some color you like. You need to generate few more colors with the same saturation and value (black color component in HSV model) the same, but use different hue.

const {OrangeColor} = require('orange-color')
const my_favorite_color = 'ffb765' 
const color = new OrangeColor(my_favorite_color)
const colors = [my_favorite_color]
for (let i = 0; i < 4; i++){
  color.h += 15
  colors.push(color.hex_string)
}
console.log(colors) // [ 'ffb765', 'ffde66', 'faff66', 'd4ff66', 'adff66' ]