Ogeon / palette

A Rust library for linear color calculations and conversion
Apache License 2.0
748 stars 60 forks source link

Add `EuclideanDistance` and `Ciede2000` traits, deprecate `ColorDifference` #316

Closed Ogeon closed 1 year ago

Ogeon commented 1 year ago

The EuclideanDistance and Ciede2000 traits are added as more specific replacements for ColorDifference. The main reason why is that there are more than one measurement of difference, with different pros, cons and uses. That means there's not really any universally canonical color difference measurement for all uses.

Closed Issues

github-actions[bot] commented 1 year ago

Benchmark for 13247c1

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Cie family/lab to lch | 3.1±0.02µs | 3.1±0.03µs | 0.00% | | Cie family/lab to xyz | 766.6±4.26ns | 766.5±3.32ns | -0.01% | | Cie family/lch to lab | 2.4±0.01µs | 2.4±0.01µs | 0.00% | | Cie family/linsrgb to xyz | 285.1±1.64ns | 285.0±1.23ns | -0.04% | | Cie family/linsrgb to xyz - wide::f32x8 | 103.3±0.33ns | 103.1±1.39ns | -0.19% | | Cie family/xyz to lab | **21.1±0.09µs** | 21.2±0.28µs | **+0.47%** | | Cie family/xyz to yxy | 655.5±3.36ns | 654.6±2.98ns | -0.14% | | Cie family/yxy to xyz | 529.4±4.73ns | 532.0±5.20ns | +0.49% | | Matrix functions/matrix_inverse | 11.7±0.07ns | 11.7±0.05ns | 0.00% | | Matrix functions/multiply_3x3 | 10.5±0.07ns | 10.5±0.04ns | 0.00% | | Matrix functions/multiply_rgb_to_xyz | 6.4±0.15ns | 6.4±0.06ns | 0.00% | | Matrix functions/multiply_xyz | 6.4±0.03ns | 6.4±0.03ns | 0.00% | | Matrix functions/multiply_xyz_to_rgb | 6.4±0.10ns | 6.4±0.03ns | 0.00% | | Matrix functions/rgb_to_xyz_matrix | 30.1±0.22ns | 30.0±0.13ns | -0.33% | | Rgb family/hsl to hsv | 664.1±14.73ns | 664.2±14.35ns | +0.02% | | Rgb family/hsl to linear hsl | **12.1±0.05µs** | 12.2±0.06µs | **+0.83%** | | Rgb family/hsl to rgb | 2.0±0.01µs | 2.0±0.02µs | 0.00% | | Rgb family/hsv to hsl | 821.3±7.31ns | 824.1±15.64ns | +0.34% | | Rgb family/hsv to hwb | **222.7±1.16ns** | 227.3±0.82ns | **+2.07%** | | Rgb family/hsv to linear hsv | **10.7±0.09µs** | 10.8±0.10µs | **+0.93%** | | Rgb family/hsv to rgb | 1906.9±20.07ns | 1905.9±16.14ns | -0.05% | | Rgb family/hwb to hsv | 466.5±10.37ns | 466.2±7.68ns | -0.06% | | Rgb family/hwb to linear hwb | **11.3±0.05µs** | 11.4±0.05µs | **+0.88%** | | Rgb family/linear hsl to hsl | 10.7±0.05µs | 10.7±0.05µs | 0.00% | | Rgb family/linear hsv to hsv | 10.1±0.05µs | 10.1±0.05µs | 0.00% | | Rgb family/linear hwb to hwb | 10.8±0.05µs | 10.8±0.06µs | 0.00% | | Rgb family/linsrgb to rgb | 5.5±0.02µs | 5.5±0.03µs | 0.00% | | Rgb family/linsrgb to rgb - wide::f32x8 | 5.5±0.03µs | 5.5±0.04µs | 0.00% | | Rgb family/linsrgb_f32 to rgb_u8 | 922.2±5.35ns | **904.7±4.28ns** | **-1.90%** | | Rgb family/linsrgb_f64 to rgb_u8 | 1173.4±14.70ns | 1170.5±10.47ns | -0.25% | | Rgb family/rgb to hsl | **793.4±4.09ns** | 801.7±6.06ns | **+1.05%** | | Rgb family/rgb to hsl - wide::f32x8 | 500.0±2.36ns | 497.9±3.71ns | -0.42% | | Rgb family/rgb to hsv | 498.0±3.44ns | 497.5±2.19ns | -0.10% | | Rgb family/rgb to hsv - wide::f32x8 | 440.4±2.12ns | **436.7±4.23ns** | **-0.84%** | | Rgb family/rgb to linsrgb | **7.4±0.05µs** | 7.5±0.03µs | **+1.35%** | | Rgb family/rgb to linsrgb - wide::f32x8 | 3.7±0.03µs | 3.7±0.02µs | 0.00% | | Rgb family/rgb_u8 to linsrgb_f32 | 329.2±3.91ns | 328.9±2.18ns | -0.09% | | Rgb family/rgb_u8 to linsrgb_f64 | 329.0±2.83ns | 329.9±1.57ns | +0.27% | | Rgb family/xyz to linsrgb | **340.0±2.03ns** | 352.2±1.28ns | **+3.59%** | | Rgb family/xyz to linsrgb - wide::f32x8 | 103.2±0.52ns | 103.6±1.39ns | +0.39% |
Ogeon commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded: