1.2.5 • Published 2 months ago

@colorx/color-converter v1.2.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Installation

npm install @colorx/color-converter

Import

import { converter } from '@colorx/color-converter';

Usage

Model conversions

You can convert between any of the supported color models.

converter.{{fromColor}}To{{ToColor}}(fromColorValue: {{ColorType}}, rounded?: boolean)

Other conversions

converter.alphaToHex(alpha: number): string;
converter.findClosestColor(arrayOfColors: Record<ColorName, HexColor>, HexColor): HexColor;

Example

import { converter } from '@colorx/color-converter';

converter.rgbToHsl({
  r: 255,
  g: 255,
  b: 255,
});

// Rounded
converter.rgbToHsl(
  {
    r: 167,
    g: 40,
    b: 13,
  },
  true,
);

Supported color models

  • HEX: string
  • RGB { r: number, g: number, b: number }
  • HSL { h: number, s: number, l: number }
  • HSV { h: number, s: number, v: number }
  • HWB { h: number, w: number, b: number }
  • HCG { h: number, c: number, g: number }
  • CMYK { c: number, m: number, y: number, k: number }
  • XYZ { x: number, y: number, z: number }
  • LAB { l: number, a: number, b: number }
  • LCH { l: number, c: number, h: number }
  • ANSI16 number
  • ANSI256 number
  • APPLE { r: number, g: number, b: number }
  • GRAY number
  • NAME string
  • RAL string
  • HKS string
  • HSI { h: number, s: number, i: number }

Issues

Please file an issue for bugs, missing documentation, or unexpected behavior.

File an issue

License

MIT

1.2.5

2 months ago

1.2.4

2 months ago

1.2.0

2 months ago

1.1.0

2 months ago

1.2.3

2 months ago

1.2.2

2 months ago

1.2.1

2 months ago

1.0.2

2 months ago

1.0.1

2 months ago

1.0.0

2 months ago