Ogeon / palette

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

Split `Saturate` into `Saturate` and `Desaturate` #251

Closed Ogeon closed 3 years ago

Ogeon commented 3 years ago

The Saturate trait is split to give us a separate Desaturate trait, and *Assign variants are added. Just like how Shade was changed. I did also notice a small bug in how DarkenAssign was blanket implemented.

Breaking Change

desaturate and desaturate_fixed have been moved into a Desaturate trait. Saturate does also not require/imply Sized, and Saturate::Scalar does no longer require/imply Float.

github-actions[bot] commented 3 years ago

Benchmark for e229bba

Click to view benchmark | Test | PR Benchmark | Master Benchmark | % | |------|--------------|------------------|---| | Cie family/lab to lch | **3.5±0.04µs** | 3.6±0.01µs | **-2.78%** | | Cie family/lab to xyz | **982.5±13.08ns** | 1034.2±71.06ns | **-5.00%** | | Cie family/lch to lab | **2.5±0.04µs** | 2.7±0.11µs | **-7.41%** | | Cie family/linsrgb to xyz | **4.0±0.04µs** | 4.1±0.00µs | **-2.44%** | | Cie family/xyz to lab | **10.8±0.17µs** | 11.5±0.53µs | **-6.09%** | | Cie family/xyz to yxy | **634.2±4.85ns** | 668.7±71.13ns | **-5.16%** | | Cie family/yxy to xyz | **685.7±2.10ns** | 721.8±72.18ns | **-5.00%** | | Matrix functions/matrix_inverse | **13.9±0.13ns** | 14.1±0.02ns | **-1.42%** | | Matrix functions/multiply_3x3 | **10.9±0.09ns** | 11.0±0.01ns | **-0.91%** | | Matrix functions/multiply_rgb_to_xyz | 4.9±0.06ns | 4.9±0.01ns | 0.00% | | Matrix functions/multiply_xyz | **4.8±0.07ns** | 4.9±0.02ns | **-2.04%** | | Matrix functions/multiply_xyz_to_rgb | **4.9±0.06ns** | 5.1±0.19ns | **-3.92%** | | Matrix functions/rgb_to_xyz_matrix | **25.4±0.21ns** | 25.6±0.04ns | **-0.78%** | | Rgb family/hsl to hsv | 853.6±6.14ns | 851.7±5.44ns | +0.22% | | Rgb family/hsl to linear hsl | 9.6±0.02µs | 9.6±0.06µs | 0.00% | | Rgb family/hsl to rgb | 2.6±0.12µs | 2.6±0.01µs | 0.00% | | Rgb family/hsv to hsl | 1296.7±9.92ns | **1270.2±8.20ns** | **+2.09%** | | Rgb family/hsv to hwb | **275.4±2.95ns** | 277.4±0.77ns | **-0.72%** | | Rgb family/hsv to linear hsv | 9.3±0.49µs | **8.9±0.03µs** | **+4.49%** | | Rgb family/hsv to rgb | 2.5±0.02µs | 2.5±0.02µs | 0.00% | | Rgb family/hwb to hsv | 630.7±6.16ns | 632.3±3.39ns | -0.25% | | Rgb family/hwb to linear hwb | 9.7±0.01µs | 9.7±0.06µs | 0.00% | | Rgb family/linear hsl to hsl | 10.4±0.03µs | **10.3±0.11µs** | **+0.97%** | | Rgb family/linear hsv to hsv | 9.8±0.08µs | 9.8±0.04µs | 0.00% | | Rgb family/linear hwb to hwb | 10.8±0.37µs | 11.0±1.30µs | -1.82% | | Rgb family/linsrgb to rgb | 4.8±0.00µs | 4.8±0.05µs | 0.00% | | Rgb family/linsrgb_f32 to rgb_u8 | 6.5±0.03µs | 6.5±0.06µs | 0.00% | | Rgb family/rgb to hsl | **878.9±6.84ns** | 894.6±25.51ns | **-1.75%** | | Rgb family/rgb to hsv | **670.3±5.86ns** | 672.8±1.89ns | **-0.37%** | | Rgb family/rgb to linsrgb | **5.1±0.05µs** | 5.4±0.21µs | **-5.56%** | | Rgb family/rgb_u8 to linsrgb_f32 | 5.5±0.06µs | 5.5±0.02µs | 0.00% | | Rgb family/xyz to linsrgb | **7.7±0.07µs** | 7.8±0.01µs | **-1.28%** |
Ogeon commented 3 years ago

Oh I almost forgot...

bors r+

bors[bot] commented 3 years ago

Build succeeded: