Socket
Socket
Sign inDemoInstall

colorconverterjs

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    colorconverterjs

Color Conversion between Hex, RGB and CMYK


Version published
Maintainers
1
Install size
17.3 kB
Created

Readme

Source

Color Converter

Easy color conversion between Hex, RGB and CMYK

Instaling

// to-do

Using

Instance methods

colorconverter.from_rgb({r: 10, g: 20, b:30 }).hex()
// "#0a141e"

colorconverter.from_hex('#0a141e').rgb()
// {r: 10, g: 20, b:30 }

colorconverter.from_hex('#8a796b').cmyk()
// {c: 0, m: 12, y: 22, k: 46 }

colorconverter.from_cmyk({c: 0, m: 12, y: 22, k: 46 }).hex()
// "#8a796b"
  • Available methods

    • hex() - returns a string with a hexadecimal value
    • rbg() - returns an object with a RGB value
    • cmyk() - returns an object with a CMYK value

Static methods

colorconverter.rgb_to_hex({r: 10, g: 20, b:30 })
// "#0a141e"

colorconverter.hex_to_rgb('#0a141e')
// {r: 10, g: 20, b:30 }

colorconverter.hex_to_cmyk('#8a796b')
// {c: 0, m: 12, y: 22, k: 46 }

colorconverter.cmyk_to_hex({c: 0, m: 12, y: 22, k: 46 })
// "#8a796b"
  • Available conversion methods

    • rgb_to_hex(object) - returns a string with a hexadecimal value for the RGB color object
    • hex_to_rgb(string) - returns an object with the RGB color values from a Hexadecimal string
    • cmyk_to_hex(object) - returns a string with a hexadecimal value for the CMYK color object
    • hex_to_cmyk(string) - returns an object with the CMYK color values from a Hexadecimal string
  • Available helper methods

    • from_hex(string) - creates an instance of the converter using the hexadecimal value received as the seed
    • from_rgb(object) - creates an instance of the converter using the RGB object received as the seed
    • from_cmyk(object) - creates an instance of the converter using the CMYK object received as the seed

Manually compile

configure:

$ npm install

test:

$ grunt test

compile:

$ grunt build

FAQs

Last updated on 26 Dec 2013

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc