@urpflanze/color
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

Color

This is a tool for color management.

Install

npm i -s @urpflanze/color

Usage

You can convert this format:

  • hsla(360, 100%, 100%, 1) string
  • rgb(255, 255, 255, 1) string
  • 0xFFFFFF - 0xFFFFFFFF number, number with alpha
  • #FFF - #FFFFFF string
import { parseColor } from '@urpflanze/color'
// Or
// const { parseColor } = require('@urpflanze/color')

const color = parseColor('#1fcc9a')

console.log(color)

// Output
// { type: 'rgb', r: 31, g: 204, b: 154, alpha: 1 }

Conversions

import { hslToRgb /* rgbToHsl */ } from '@urpflanze/color'

const { r, g, b } = hslToRgb('hsl(163, 74%, 46%)')

console.log([r, g, b])

// Output
// [31, 204, 154]

Parsing and conversions

import { parseColorAndConvert } from '@urpflanze/color'

const converted = hslToRgb('hsl(163, 74%, 46%)')

console.log(converted)

// Output
// {
// 	    r: 31, g: 204, b: 154
// 	    h: 163, s: 74, l: 46
// 	    alpha: 1
// }

Readme

Keywords

Package Sidebar

Install

npm i @urpflanze/color

Weekly Downloads

3

Version

0.0.5

License

GPL-3.0-or-later

Unpacked Size

153 kB

Total Files

51

Last publish

Collaborators

  • genbs