Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/finanalyst/raku-hcl-colorspace
HCL is a colorspace adapted to human perception, in contrast to RGB which is frequency based.
https://github.com/finanalyst/raku-hcl-colorspace
Last synced: 17 days ago
JSON representation
HCL is a colorspace adapted to human perception, in contrast to RGB which is frequency based.
- Host: GitHub
- URL: https://github.com/finanalyst/raku-hcl-colorspace
- Owner: finanalyst
- License: artistic-2.0
- Created: 2019-12-02T21:22:02.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2019-12-13T19:13:07.000Z (almost 5 years ago)
- Last Synced: 2024-10-08T14:01:14.537Z (about 1 month ago)
- Language: Perl 6
- Size: 8.79 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hue Chroma Luminance Color Space
The HLS colorspace is more adapted to human visual perception than the RGB rainbow, which is suited to
computer representations. For instance, the human eye has five times more receptors for luminance than for
colour.The colorspace was introduced by [Sarifuddin and Missaoui](https://pdfs.semanticscholar.org/206c/a4c4bb4a5b6c7b614b8a8f4461c0c6b87710.pdf?_ga=2.9335922.611436885.1505557968-1463367387.1505557968)
and is also described on [the HCL website](http://hclwizard.org/why-hcl/).The algorithms here are taken from [chroma.js](https://github.com/gka/chroma.js).
Currently, only the RGB <-> HCL algorithms are implemented.
# Usage
```
use v6.*;
use Colorspace::HCL;for
[0xd2, 0x69, 0x1d], # almost Chocolate, CSS3
[210, 105, 29], # same but in decimal
'#d2691d', # in html notation
[0.823529, 0.411765, 0.113725] #same normalized to unity
# note that signature 1,1,1 could be ambiguous, so normalised to unity must be real
# max 255 form must be integers
{
say .&rgb-to-hcl
}
# 57 68 56
# 57 68 56
# 57 68 56
# 57 68 56say hcl-2-rgb( 57, 68, 56 ); # default output format is html
# '#d2691d'
for {
say hcl-to-rgb( 57, 68, 56, :form($_) ); # default output format is html
}
# '#d2691e'
# [ 210, 105, 29]
# [ 0.823529, 0.411765, 0.113725 ]
```