Skip to content

🎨 JS utilities for converting known color formats - RGB/HEX/HSL/HSB

License

Notifications You must be signed in to change notification settings

bartektelec/color-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

color-utils

A utility module created to easily convert color values to different formats.

Planned support for RGB, HEX, HSL, HSB, with or without alpha channel values.

tool demo animation

Currently supported formats

  • RGB
  • Hex
  • HSL
  • HSB
  • RGBA
  • Hex w/ alpha channel
  • HSLA
  • HSBA

How to

Import the Color object to your project and create a new instance of Color

import Color from '.../index.ts';
const myColor = new Color();

Assign it a value using any supported color format

myColor.setRGB(255,100,50);
myColor.setHex("")
...

Known issues and to-dos

  • Need more tests, it seems like converting RGB to HEX doesn't work as expected, has problems with double 0's
  • Min-max values
  • Values for hsl-saturation and hsb-saturation should be stored separately
  • Lacks conversion from HSL to RGB
  • Lacks conversion from HSB to RGB
  • Lacks conversion from HSL/RGB or HEX to HSB
  • Utility function for rgbToHsb
  • Utility function for hexToHsl and hexToHsb
  • Utility function for hslToRgb, hslToHex and hslToHsb
  • Utility function for hsbToRgb, hsbToHex and hsbToHsl
  • Hsl and Hsb-String getters should use % for S-L/B values
  • Add alphaPrecent getter

Read more

About

🎨 JS utilities for converting known color formats - RGB/HEX/HSL/HSB

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published