blend_srgb/lib.rs
1//! `blend-srgb` is a small, `#![no_std]`-compatible sRGB conversion and
2//! blending library designed for performance.
3//!
4//! It provides a small number of helper functions for converting and blending
5//! sRGB values:
6//!
7//! - [`srgb_to_rgb`], which converts a floating-point sRGB component to a
8//! floating-point Linear RGB component.
9//! - [`rgb_to_srgb`] which does the reverse.
10//! - [`srgb8_to_rgb12`] which converts an 8-bit sRGB component to a 12-bit
11//! Linear RGB component.
12//! - [`rgb12_to_srgb8`] which does the reverse.
13//! - [`rgb12_to_srgb8_unchecked`] which does not truncate the input to 12 bits.
14//! - [`blend_srgb8_channel`] which blends an sRGB foreground and background
15//! color with the provided alpha.
16//! - [`blend_srgb8`] which does the same as above but for (r, g, b) tuples.
17//!
18//! Additionally, these functions are designed to be performant enough to be
19//! used in software composition pipelines. To facilitate this, a small (4.5k)
20//! lookup table is included. The lookup table can be small due to the usage of
21//! 12-bit linear values rather than 16-bit. 12 bits are enough to store all
22//! 8-bit sRGB values in linear space.
23//!
24//! All functions other than [`srgb_to_rgb`] and [`rgb_to_srgb`] use only
25//! integer operations, and are therefore fully compatible with `#![no_std]`.
26//! To activate `#![no_std]`, just deactivate the `std` feature. To keep
27//! the floating-point methods, also add the `libm` feature.
28
29#![cfg_attr(not(feature = "std"), no_std)]
30
31#[cfg(test)]
32mod tests;
33
34pub mod convert;
35pub mod blend;
36
37#[cfg(doc)]
38use convert::*;
39#[cfg(doc)]
40use blend::*;