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