1.0.0 • Published 2 months ago
@colorblender/converter-hks v1.0.0
Installation
This package requires the installation of the main package @colorblender/converter
.
npm install @colorblender/converter @colorblender/converter-hks
Import
import { rgbToHks, hksToRgb } from '@colorblender/converter-hks';
Usage
Model conversions
You can convert between any of the supported color models.
// hks to rgb
hksToRgb(hks: HksColor, rounded?: boolean): RgbColor
// rgb to hks
rgbToHks(rgb: RgbColor): HksColor
Example
import { rgbToHks, hksToRgb } from '@colorblender/converter-hks';
rgbToHks({
r: 255,
g: 255,
b: 255,
});
// Rounded
hksToRgb('41-E', true);
Conversion
You can convert any compatible model to RGB format and vice versa.
To convert two compatible and different RGB models you will have to go through a sub-conversion. For example to convert a HEX value to HKS you will have to do: HEX -> RGB -> HKS. This allows you to convert any compatible model to any other.
Keep in mind that large conversions may result in a loss of accuracy.
Supported color models
- HKS: string
Issues
Please file an issue for bugs, missing documentation, or unexpected behavior.
License
MIT
1.0.0
2 months ago