Expand description

Sorbet Color - We did your homework.

GitHub issues GitHub forks GitHub stars Crates.io downloads Crates.io license Crates.io version

This crate is a component of the work-in-progress GUI library by the same name, Sorbet.

It should be handy as a standalone library for all of your color-conversion needs.


This crate provides convenient types to represent colors in different formats/models/spaces. All color structures have the Color trait which specifies bounds for conversion between every other color structure.

Details

The transparency/alpha component as structure fields is always fully spelled-out as alpha, to differentiate it from any color models that may have an a component (none handled by this library thus-far).

Most of the mathematics used here will be based on the algorithms found on Wikipedia or other crowd-sourced references.

This library is incomplete and is missing important spaces such as CIE XYZ, LUV, and LAB.

Some interesting reading about the CIE 1931 color space can be found on Wikipedia.

If you would like to utilize this crate and there is a format missing, please open a new issue on the GitHub repository after searching to make sure a request hasn’t already been submitted.

Pull requests are very welcome.

Versioning

See Versioning for Sorbet.

[dependencies]
# It is recommended to use the latest version while the public API is unstable.
sorbet-color = "*"
# Otherwise, if you would like to not worry about updating the dependency,
# feel free to use the latest minor version and leave it at that.
sorbet-color = "0.X"

License

Copyright © 2022 Jacob Birkett

This project is provided under the Apache License, Version 2.0.

🟢 Permissions 🟡 Conditions 🔴 Limitations
  • Commercial use
  • Distribution
  • Modification
  • Patent use
  • Private use
  • License and copyright notice
  • State changes
  • Liability
  • Trademark use
  • Warranty

Re-exports

pub use types::*;

Modules

This module contains functions and types relating to the parsing of CSS colors in functional notation. This module typically will not be used directly. See the crate::Color::new constructor for more information.

This module contains named colors that are standard in CSS, defined by the W3C CSS Color Module Level 4 Working Draft.

This module contains all of the structures for the color-spaces and formats supported by the crate. They are re-exported in the crate-root.

Traits

This trait marks structures that have the necessary From implementations for all other color spaces. It also provides several constructors that facilitate creating the appropriate values from known-formats such as hexadecimal notation or CSS-compatible functional notations.