Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-color-converter

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-color-converter

Converts CSS colors from one representation to another

  • 1.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

css-color-converter Build Status

Converts CSS colors from one representation to another

Installation

npm install css-color-converter

Usage

var color = require('css-color-converter');

color('rgb(255, 255, 255)').toHslString(); // hsl(0, 0%, 100%)
color('rgba(255, 255, 255, 0.5)').toHslString(); // hsla(0, 0%, 100%, 0.5)
color('blue').toRgbString(); // rgb(0, 0, 255)
color('red').toHexString(); // #ff0000

Methods

fromRgb([r, g, b])

parametertypedescription
rintred (0-255)
gintgreen (0-255)
bintblue (0-255)

Returns instance

fromRgba([r, g, b, a])

parametertypedescription
rintred (0-255)
gintgreen (0-255)
bintblue (0-255)
afloatalpha (0-1)

Returns instance

fromHsl([h, s, l])

parametertypedescription
hinthue (0-360)
sintsaturation (0-100)
lintluminosity (0-100)

Returns instance

fromHsla([h, s, l, a])

parametertypedescription
hinthue (0-360)
sintsaturation (0-100)
lintluminosity (0-100)
afloatalpha (0-1)

Returns instance

toRgbString()

Returns rgb() or rgba(), depending on the alpha.

toHslString()

Returns hsl() or hsla(), depending on the alpha.

toHexString()

Returns 6-digit or 8-digit hex, depending on the alpha.

toRgbaArray()

Returns [r, g, b, a] array.

Keywords

FAQs

Package last updated on 20 Mar 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc