Skip to content

This is my color utility library. It helps a lot for converting colors for a simple UX designer.

Notifications You must be signed in to change notification settings

clemator/color-library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

color-library

This is my color utility library. It helps a lot for converting colors.

Who can use my library?

This library is designed for UX designers that do not know how to code and want a quick and easy way to use.

Supported formats:

  • Rgb
  • Hsl
  • Hex

Working on:

  • Xyz

Installation

npm install

Build

npm run build

Test

npm run test

Develop

npm run start

Factories

RGB(r, g, b)

Initialize your RGB color:

const red = RGB(255, 0, 0)

HEX(str)

Initialize your hexa color:

const hex = HEX('FF0000')

HSL(h, s, l)

Initialize your HSL color:

const hsl = HSL(0, 0.5, 1)

Public API

.toString()

Get your color on string format:

const red = RGB(255, 0, 0).toString()      //-> "rgb(255, 0, 0)"
const green = HEX('00FF00').toString()     //-> "#00FF00"
const blue = HSL(0.666, 1, 0.5).toString() //-> "hsl(0.666, 1, 0.5)"

.get()

Get the color value:

const red = RGB(255, 0, 0).get()           //-> [255, 0, 0]
const green = HEX('00FF00').get()          //-> '00FF00'
const blue = HSL(0.666, 1, 0.5).get()      //-> [0.666, 1, 0.5]

.set()

Chainable

Set the color value:

const blue = RGB(255, 0, 0).set(0, 0, 255)
const red = HEX('00FF00').set('FF0000')
const green = HSL(0.666, 1, 0.5).set(0.333, 1, 0.5)

.toRgb()

Chainable

Get color value to RGB format:

var red = HEX('FF0000').toRgb().get()      //-> [255, 0, 0]

.toHex()

Chainable

Get color value to HEX format:

var red = HSL(0, 0.5, 1).toHex().get()     //-> 'FF0000'

.toHsl()

Chainable

Get color value to HSL format:

var red = RGB(255, 0, 0).toHsl().get()     //-> [0, 0.5, 1]

.format()

Return the color format property:

const red = RGB(255, 0, 0).format()        //-> "rgb"
const green = HEX('00FF00').format()       //-> "hex"
const blue = HSL(0.666, 1, 0.5).format()   //-> "hsl"

About

This is my color utility library. It helps a lot for converting colors for a simple UX designer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published