allc
v0.2.0
Published
A small typescript package for color conversion.
Downloads
23
Maintainers
Readme
Allc
A small typescript package for color conversion.
Color Models And Spaces
This library provides these:
RGB<"sRGB">
(3xnumber
)RGBNumber
(3xinteger 0..=255
)Hex
(3xinteger 0..=255
)HSL
(3xnumber
)HSB
(3xnumber
)
CIE 1931 XYZ
The following color spaces are in development:
- OKLAB
- OKLCH
- Display P3
- Adobe RGB
More color spaces might be added in the future.
How To Use This Library
You can create colors by using the literal syntax {r: ..., g: ..., b: ...}
.
Converting between colors is straight forward. It uses the scheme to{TARGET}From{SOURCE}
where {TARGET}
and {SOURCE}
are color spaces.
This library does not have a fully featured conversion matrix (meaning, you cannot convert every type in every other directly). Instead, do the following:
Hex
↔RGBNumber
↔RGB
HSL
↔RGB
HSV
↔RGB
From there you can convert to CIE1931XYZ
and from there you can convert to any other type.
Guarantees
- This package does not throw.
- Only types and functions are used.
- This package is side effect free (only pay for what you use).
The implementation decisions section is gone; a replacement article will be published on https://trombecher.github.io/.