kcolor
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

kcolor

  • Create color from any supported type
  • Convert color to any supported type
  • Supported types: RGB, RGBA, HSL, HSLA, HSV, HSVA, CMYK, CMYKA, HEX (./src/color/types.ts)
  • Many other color utility functions (./src/color/color.ts)

Install

npm i kcolor

Basic Usage

import { Color } from 'kcolor';

const color = Color.rgb(85, 77, 68)

console.log(color.rgba1)    // { r: 0.33, g: 0.3, b: 0.26, a: 1 }
console.log(color.rgb1)     // { r: 0.33, g: 0.3, b: 0.26 }
console.log(color.rgba)     // { r: 85, g: 77, b: 68, a: 255 }
console.log(color.rgba255)  // { r: 85, g: 77, b: 68, a: 255 }
console.log(color.rgb)      // { r: 85, g: 77, b: 68 }
console.log(color.rgb255)   // { r: 85, g: 77, b: 68 }
console.log(color.hsva)     // { h: 32, s: 20, v: 33, a: 1 }
console.log(color.hsv)      // { h: 32, s: 20, v: 33 }
console.log(color.hsla)     // { h: 32, s: 11, l: 30, a: 1 }
console.log(color.hsl)      // { h: 32, s: 11, l: 30 }
console.log(color.cmyka)    // { c: 0, m: 9, y: 20, k: 67, a: 1 }
console.log(color.cmyk)     // { c: 0, m: 9, y: 20, k: 67 }
console.log(color.hexa)     // 554d44ff
console.log(color.hex)      // 554d44
console.log(color.intValue) // 1431127295

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.0.4
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.0.4
    2
  • 0.0.3
    1
  • 0.0.2
    1

Package Sidebar

Install

npm i kcolor

Weekly Downloads

4

Version

0.0.4

License

ISC

Unpacked Size

58.2 kB

Total Files

21

Last publish

Collaborators

  • kkristof200