Skip to content

🌈 • Small library to help you dealing with conversions between Hex and RGB colours (and vice-versa).

Notifications You must be signed in to change notification settings

ss-javascript/sth-hexrgb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this library for?

This tiny library is very useful when you need to make simple conversions between hexadecimal and RGB values. It can convert an hexadecimal value into a RGB one and vice-versa. For example, you can easily transform #fff into 255, 255, 255.

Installing

You can install it via npm or Yarn:

# Using npm
$ npm install sth-hex-rgb

# Using Yarn
$ yarn add sth-hex-rgb

Note: if you're new in the web development, be aware that you can use either npm option or Yarn to install it, but not both at the same time.

Hexadecimal

You can use the Hexadecimal to convert your hex value into an RGB object.

const hexadecimal = require('sth-hex-rgb').hexadecimal;

hexadecimal.toRGB('#ffffff');
// => { r: 255, g: 255, b: 255 }

hexadecimal.toRGB('#000');
// => { r: 0, g: 0, b: 0 }

hexadecimal.toRGB('ffffff');
// => { r: 255, g: 255, b: 255}

RGB

Just like the Hexadecimal, the RGB can be used when you want to convert your RGB object into an hexadecimal value.

const rgb = require('sth-hex-rgb').rgb;

rgb.toHexadecimal({ r: 255, g: 255, b: 255 });
// => #ffffff

About

🌈 • Small library to help you dealing with conversions between Hex and RGB colours (and vice-versa).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages