0.0.14 • Published 6 years ago

culor v0.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

Culor

Just another color converter.

https://nodei.co/npm/culor.png?downloads=true&downloadRank=true&stars=true

Installation

npm:

npm install culor

yarn:

yarn add culor

Usage example

import {color} from 'culor'

const color_name = color('red')
const color_hex = color('#ff5555')
const color_hex_short = color('#f55')
const color_rgb = color('rgb(255, 85, 85)')
const color_rgba = color('rgba(255, 85, 85, .7)')
const color_hsl = color('hsl(360deg, 100%, 67%)')
const color_hsla = color('hsla(400grad, 100%, 67%, .7)')
import {RGB, RGBA, HSL, HSLA} from 'culor'

const rgb = RGB('255', 85, 85)
const rgba = RGBA(255, '85', 85, .7)
const hsl = HSL(360, '100%', .67)
const hsla = HSLA('360deg', 1, '67%', .7)
const c = color('#00ff00ff')
c.Hex()      // '#00ff00'
c.HexA()     // '#00ff00ff'
c.RGB()      // 'rgb(0, 255, 0)'
c.RGBA()     // 'rgba(0, 255, 0, 1)'
c.HSL()      // 'hsl(120, 100%, 50%)'
c.HSLA()     // 'hsla(120, 100%, 50%, 1)'
c.keyword()  // 'lime'

Syntax

color(csscolor)
RGB(R, G, B)
RGBA(R, G, B, A)
HSL(H, S, L)
HSLA(H, S, L, A)

Parameters

KeyTypeValue
csscolorStringColor keywords, rgb(), rgba(), hsl(), hsla() or Hexadecimal notation in css data type.
RNumber Stringred, 0, 255
GNumber Stringgreen, 0, 255
BNumber Stringblue, 0, 255
HStringhue angel
SNumber Stringsaturation can be a number 0, 1, or a string between '0%' and '100%'
LNumber Stringlightness can be a number 0, 1, or a string between '0%' and '100%'
ANumber Stringalpha can be a number 0, 1, or a string between '0' and '1'

Functions

KeyTypeValue
.Hex()String#RRGGBB
.HexA()String#RRGGBBAA
.RGB()Stringrgb(r, g, b)
.RGBA()Stringrgba(r, g, b, a)
.HSL()Stringhsl(h, s, l)
.HSLA()Stringhsla(h, s, l, a)
.keyword()Stringcolor keyword or undefined

To-Do

  • support rgb() / rgba() percentage unit.
  • .Hex(A) .RGB(A) .HSL(A)
  • HSLA2RGB -> HSL2RGB
  • .keyword

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request
0.0.14

6 years ago

0.0.12

6 years ago

0.0.10

6 years ago

0.0.8

6 years ago

0.0.6

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago