culors 1.6.0

Rust port of the culori color library. Color spaces, CSS Color Module 4 parsing, interpolation, gamut mapping, ΔE, blending, filters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! CIE76 color difference — Euclidean distance in D65 Lab.
//!
//! Equivalent to culori's `differenceCie76 = () => differenceEuclidean('lab65')`.

use crate::difference::extract::to_lab65;
use crate::Color;

/// CIE76 ΔE — Euclidean distance in D65 Lab. Fast, perceptually rough.
pub fn difference_ciede76() -> impl Fn(&Color, &Color) -> f64 {
    |std, smp| {
        let (l1, a1, b1) = to_lab65(*std);
        let (l2, a2, b2) = to_lab65(*smp);
        let dl = l1 - l2;
        let da = a1 - a2;
        let db = b1 - b2;
        (dl * dl + da * da + db * db).sqrt()
    }
}