Socket
Socket
Sign inDemoInstall

@fantasy-color/hcl-to-rgb

Package Overview
Dependencies
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fantasy-color/hcl-to-rgb

Transform HCL objects to RGB objects


Version published
Maintainers
9
Created
Source

@fantasy-color/hcl-to-rgb

Transform a HCL color object to a RGB color object.

type hclToRgb = (color: HCL) => RGB

Example usage:

import hclToRgb from '@fantasy-color/hcl-to-rgb'

hclToRgb({
  hue: 40.85261277607024,
  chroma: 106.83899941284552,
  luminance: 54.29173376861782
})
// { red: 255, green: 0, blue: 0 }

Note that this transformation can yield results where the values of the colors are outside the 0-255 boundary. So for example, dark red:

import hclToRgb from '@fantasy-color/hcl-to-rgb'

hclToRgb({
  hue: 40.85261277607024,
  chroma: 106.83899941284552,
  luminance: 24.29173376861782
})
// { red: 157, green: -147, blue: -70 }

…yields -147 for green and -70 for blue. These are valid CSS values:

Colors outside the sRGB gamut can be specified in Cascading Style Sheets by making one or more of the red, green and blue components negative or greater than 100%, so the color space is theoretically an unbounded extrapolation of sRGB similar to scRGB.

https://en.wikipedia.org/wiki/Web_colors

They will just get clipped to the range 0-255. The color specified above will be represented by the browser as:

const color = { red: 157, green: 0, blue: 0 }

FAQs

Package last updated on 06 May 2021

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