package hsluv

  1. Overview
  2. Docs
HSLuv human-friendly color space implementation in OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

hsluv-0.1.0.tbz
sha256=9eb31d2b6881d19a36d5ec41ccd12b146f9b313bbc44abcc24259ab0d73a314a
sha512=c1f444deb8566e18a1b000fec2033c64eaa32606d7c2a990654c6f651946b508fe730f21c64fd3380e1dced6ad374ae8f6700a0f55c193a2e646a3345a9a4e72

Description

This package implements the HSLuv color space model, providing a perceptually uniform alternative to traditional HSL. It includes functions for converting between HSLuv/HPLuv and other color spaces like RGB, XYZ, LCH, and LUV, as well as hexadecimal color representation.

README

ocaml-hsluv

HSLuv human-friendly color space implementation in OCaml.

See https://www.hsluv.org/.

Description

This OCaml package implements the HSLuv color space model, providing a perceptually uniform alternative to traditional HSL. It includes functions for converting between HSLuv/HPLuv and other color spaces like RGB, XYZ, and Luv.

The HSLuv color space is particularly beneficial in scenarios where perceptual uniformity and intuitive color manipulation are crucial:

  1. Design and Visualization: Ideal for creating balanced and harmonious color palettes with consistent hues.

  2. Data Representation: Useful in data visualization for accurate and non-misleading representations, such as in heatmaps and graphs.

  3. Accessibility in User Interfaces: Helps in maintaining consistent contrast, crucial for users with visual impairments.

  4. Digital Art and Image Processing: Offers fine-tuning of colors for subtle and precise adjustments.

In summary, HSLuv's appeal lies in its ability to provide visually consistent and natural-looking colors, making it suitable for design, data visualization, and artistic applications.

Implementation Notes

This started as a port of the Go implementation of hsluv.org.

The following color conversions are provided:

From/To HSLuv HPLuv RGB XYZ LUV LCH HEX
HSLuv - - hsluv_to_rgb - - conv_hsluv_lch hsluv_to_hex
HPLuv - - hpluv_to_rgb - - conv_hpluv_lch hpluv_to_hex
RGB hsluv_from_rgb hpluv_from_rgb - conv_rgb_xyz - conv_rgb_lch conv_rgb_hex
XYZ - - conv_xyz_rgb - conv_xyz_luv - -
LUV - - - conv_luv_xyz - conv_luv_lch -
LCH conv_lch_hsluv conv_lch_hpluv conv_lch_rgb - conv_luv_lch - -
HEX hsluv_from_hex hpluv_from_hex conv_hex_rgb - - - -

In addition to the HSLuv and HPLuv conversion functions, this package also exposes

  • color conversion functions between the various color spaces used to enable the HSLuv and HPluv conversions

  • pretty printers pp_hsluv, pp_hpluv, etc.

  • a library hsluv.float_conv for conversions between float triples and the provided color types

Tests

The implementation is tested against the hsluv snapshot (revision 4). Tests for all conversion functions are included and can be run with

opam exec -- dune test

Dependencies (2)

  1. dune >= "3.7"
  2. ocaml >= "4.08.0"

Dev Dependencies (3)

  1. odoc with-doc
  2. ppx_yojson_conv with-test
  3. yojson with-test

Used by

None

Conflicts

None