1.0.5 • Published 4 years ago

colorise v1.0.5

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

colorise.js

A small JavaScript library for color manipulation. Inspired by color.js but I'm aiming to write simplified and robust source code with some different functionalities.

Installation in npm

npm i colorise --save

Usage

const colorise = require('colorise');

// create instance of class
let c = new colorise();

// use different functions 
let result = c.getColorName('#7cb9e8'); 
console.log(result); // 'Aero'

Function NameDescriptionParametersreturns
getColorName(colorCode)function to get name of color from hex-color-code.hex-color-code : stringcolor : string
getColorCode(colorName)function to get hexadecimal color code from color namecolor : stringhex-color-code : string
rgbPercentage(r,g,b)function to calculate r,g,b percentage in colorr : number,g : number,b : numberreturns array
hexToRgb(hexCode)function to get r,g,b values from hexCoder : number,g : number,b : numberreturns array
rgbToCMYK(r,g,b)function to get cyan, magneta, yellow, black values from r,g,b valuesr : number,g : number,b : numberreturn array
rgbToHsl(r,g,b)function to get hue, saturation and lightness from r,g,b valuesr : number,g : number, b : numberreturns object
rgbToHwb(r,g,b)function to get hue, whiteness and blackness values from r,g,br : number, g : number, b : numberreturns object
whitenColor(r,g,b,ratio),darkenColor(r,g,b,ratio), lightenColor(r,g,b,ratio),blackenColor(r,g,b,ratio)these functions perform whitening, darkening, lightning and blackening r,g,b color as per given ratior : number, g : number, b : number, ratio : number < 0returns array/object
negateColor(r,g,b)function takes negation of colorr : number,g : number,b : numberreturns array
hslToRgb(h,s,l)function to get r,g,b color from h,s,l values0<=hue<=360,0<=s<=100, 0<=l<=100returns array
rgbToHex(r,g,b)function to get hex-color-code from rgbr : number,g : number,b : numberreturns string

Disclaimer

This code is originally written and no part can be copied/used/modified/changed/improved without permission of author. The code is licensed under MIT License Copyright (C) 2020.

For writing some conversion functions the functions are learned from 'https://www.rapidtables.com/' The color-data used in code is provided by Jonathan Neal on his github which is obvious, how can anyone know all these color codes and their names XD. All right.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. If anyone finds that something in code need to changed/improved/modified please drop mail.

Please make sure to update tests as appropriate.

License

MIT

Recent Updates

  • Feb 2020 : Raw functions are created. The code is very much raw and library is currently under development.
  • March 2020 : Required changes done. small code is published.

Dependancies

  • No external dependancies till date.