Ogeon / palette

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

Fix NaN values from `Okhsv` when `saturation` is > 0 and `value` == 0 #332

Closed Ogeon closed 1 year ago

Ogeon commented 1 year ago

Changes the check so it looks for value == 0, regardless of saturation.

Closed Issues

github-actions[bot] commented 1 year ago

Benchmark for 18d47eb

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Cie family/lab to lch | 3.2±0.05µs | 3.2±0.09µs | 0.00% | | Cie family/lab to xyz | 761.8±8.16ns | 761.3±7.85ns | -0.07% | | Cie family/lch to lab | 2.4±0.04µs | 2.4±0.05µs | 0.00% | | Cie family/linsrgb to xyz | 308.1±5.54ns | 307.3±3.56ns | -0.26% | | Cie family/linsrgb to xyz - wide::f32x8 | 99.9±1.66ns | 100.0±1.61ns | +0.10% | | Cie family/xyz to lab | 17.9±0.25µs | 17.9±0.27µs | 0.00% | | Cie family/xyz to yxy | 623.3±7.50ns | 627.4±15.06ns | +0.66% | | Cie family/yxy to xyz | 546.7±6.60ns | 548.9±9.52ns | +0.40% | | Matrix functions/matrix_inverse | **10.7±0.15ns** | 11.1±0.15ns | **+3.74%** | | Matrix functions/multiply_3x3 | 9.7±0.16ns | 9.7±0.24ns | 0.00% | | Matrix functions/multiply_rgb_to_xyz | 6.0±0.13ns | 6.0±0.08ns | 0.00% | | Matrix functions/multiply_xyz | 6.0±0.10ns | 6.0±0.12ns | 0.00% | | Matrix functions/multiply_xyz_to_rgb | 6.0±0.11ns | 6.0±0.08ns | 0.00% | | Matrix functions/rgb_to_xyz_matrix | 24.9±0.32ns | 24.9±0.41ns | 0.00% | | Rgb family/hsl to hsv | 650.1±6.85ns | 649.4±18.05ns | -0.11% | | Rgb family/hsl to linear hsl | 13.0±0.17µs | 12.9±0.16µs | -0.77% | | Rgb family/hsl to rgb | 2.1±0.05µs | 2.1±0.04µs | 0.00% | | Rgb family/hsv to hsl | 821.8±9.91ns | 822.4±11.80ns | +0.07% | | Rgb family/hsv to hwb | 235.6±4.87ns | 233.8±2.82ns | -0.76% | | Rgb family/hsv to linear hsv | 11.7±0.16µs | 11.7±0.17µs | 0.00% | | Rgb family/hsv to rgb | 1905.9±24.54ns | 1921.3±26.12ns | +0.81% | | Rgb family/hwb to hsv | 482.6±6.33ns | 480.0±6.37ns | -0.54% | | Rgb family/hwb to linear hwb | 12.5±0.25µs | 12.4±0.24µs | -0.80% | | Rgb family/linear hsl to hsl | 11.1±0.14µs | 11.2±0.46µs | +0.90% | | Rgb family/linear hsv to hsv | 10.4±0.13µs | **10.2±0.21µs** | **-1.92%** | | Rgb family/linear hwb to hwb | 11.2±0.15µs | 11.2±0.17µs | 0.00% | | Rgb family/linsrgb to rgb | 6.2±0.09µs | **5.9±0.08µs** | **-4.84%** | | Rgb family/linsrgb to rgb - wide::f32x8 | 5.2±0.16µs | **5.1±0.08µs** | **-1.92%** | | Rgb family/linsrgb_f32 to rgb_u8 | 961.8±20.11ns | 955.3±18.92ns | -0.68% | | Rgb family/linsrgb_f64 to rgb_u8 | 1222.0±30.72ns | 1224.7±32.86ns | +0.22% | | Rgb family/rgb to hsl | 851.1±8.15ns | 851.7±12.26ns | +0.07% | | Rgb family/rgb to hsl - wide::f32x8 | 469.7±8.71ns | 469.9±6.46ns | +0.04% | | Rgb family/rgb to hsv | 527.3±10.29ns | **510.6±6.04ns** | **-3.17%** | | Rgb family/rgb to hsv - wide::f32x8 | 427.2±5.75ns | 428.1±5.85ns | +0.21% | | Rgb family/rgb to linsrgb | 8.8±0.21µs | **8.3±0.10µs** | **-5.68%** | | Rgb family/rgb to linsrgb - wide::f32x8 | 3.3±0.04µs | 3.3±0.05µs | 0.00% | | Rgb family/rgb_u8 to linsrgb_f32 | 307.0±4.67ns | 309.2±6.83ns | +0.72% | | Rgb family/rgb_u8 to linsrgb_f64 | 311.2±4.13ns | 311.7±4.25ns | +0.16% | | Rgb family/xyz to linsrgb | 354.6±3.88ns | 357.4±5.31ns | +0.79% | | Rgb family/xyz to linsrgb - wide::f32x8 | 106.5±2.44ns | 105.8±1.91ns | -0.66% |
Ogeon commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here. For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.