Ogeon / palette

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

Remove the `Gradient` type and its module #301

Closed Ogeon closed 1 year ago

Ogeon commented 1 year ago

As discussed in #218, the Gradient type has not gotten the attention it deserves and it's better to remove it in favor of other alternatives. This will also make the library more focused and easier to maintain. The predefined, named gradient constants are also removed.

Closed Issues

Breaking Change

Both Gradient and gradient::named are gone with no replacement, in favor of better alternatives in other crates.

Ogeon commented 1 year ago

I'm thinking of making it possible to multiply hues as if they are just regular numbers but will probably do that separately. That should make it possible to skip having an interpolation adapter for those types.

github-actions[bot] commented 1 year ago

Benchmark for aab81e1

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Cie family/lab to lch | 4.1±0.16µs | 4.1±0.13µs | 0.00% | | Cie family/lab to xyz | 1055.4±64.45ns | 1051.7±41.48ns | -0.35% | | Cie family/lch to lab | 2.7±0.15µs | 2.7±0.11µs | 0.00% | | Cie family/linsrgb to xyz | **5.2±0.15µs** | 5.5±0.33µs | **+5.77%** | | Cie family/linsrgb to xyz - wide::f32x8 | 1133.0±37.58ns | **1032.9±23.60ns** | **-8.83%** | | Cie family/xyz to lab | 22.2±1.41µs | 21.8±0.94µs | -1.80% | | Cie family/xyz to yxy | 770.4±119.55ns | **745.1±22.35ns** | **-3.28%** | | Cie family/yxy to xyz | 747.4±43.13ns | 743.0±30.51ns | -0.59% | | Matrix functions/matrix_inverse | 14.4±1.57ns | **13.6±0.42ns** | **-5.56%** | | Matrix functions/multiply_3x3 | 10.5±0.50ns | 10.8±0.62ns | +2.86% | | Matrix functions/multiply_rgb_to_xyz | **5.8±0.25ns** | 6.1±0.35ns | **+5.17%** | | Matrix functions/multiply_xyz | 6.0±0.76ns | 5.9±0.18ns | -1.67% | | Matrix functions/multiply_xyz_to_rgb | 5.8±0.32ns | 5.9±0.20ns | +1.72% | | Matrix functions/rgb_to_xyz_matrix | 29.3±0.94ns | 29.6±1.91ns | +1.02% | | Rgb family/hsl to hsv | 902.5±41.55ns | 890.6±33.02ns | -1.32% | | Rgb family/hsl to linear hsl | 16.9±0.72µs | 16.7±0.98µs | -1.18% | | Rgb family/hsl to rgb | 2.7±0.16µs | 2.7±0.19µs | 0.00% | | Rgb family/hsv to hsl | 1108.3±66.82ns | 1060.2±55.22ns | -4.34% | | Rgb family/hsv to hwb | 233.2±23.45ns | 235.8±16.85ns | +1.11% | | Rgb family/hsv to linear hsv | 15.8±0.62µs | 15.9±0.75µs | +0.63% | | Rgb family/hsv to rgb | 2.4±0.08µs | 2.4±0.11µs | 0.00% | | Rgb family/hwb to hsv | 596.6±29.98ns | 596.9±27.23ns | +0.05% | | Rgb family/hwb to linear hwb | 16.9±0.88µs | 16.7±0.46µs | -1.18% | | Rgb family/linear hsl to hsl | 14.0±0.55µs | 13.9±0.50µs | -0.71% | | Rgb family/linear hsv to hsv | 13.0±0.51µs | 13.0±0.46µs | 0.00% | | Rgb family/linear hwb to hwb | 14.0±0.49µs | 14.3±0.69µs | +2.14% | | Rgb family/linsrgb to rgb | 7.4±0.35µs | 7.6±0.55µs | +2.70% | | Rgb family/linsrgb to rgb - wide::f32x8 | **8.0±0.19µs** | 8.5±0.27µs | **+6.25%** | | Rgb family/linsrgb_f32 to rgb_u8 | 1072.5±35.45ns | 1081.9±81.79ns | +0.88% | | Rgb family/linsrgb_f64 to rgb_u8 | 1412.9±51.97ns | 1424.3±60.08ns | +0.81% | | Rgb family/rgb to hsl | 1050.7±34.93ns | 1058.4±47.92ns | +0.73% | | Rgb family/rgb to hsl - wide::f32x8 | 663.8±29.65ns | 666.9±30.86ns | +0.47% | | Rgb family/rgb to hsv | 766.9±40.21ns | 763.1±22.45ns | -0.50% | | Rgb family/rgb to hsv - wide::f32x8 | 642.7±31.81ns | 639.8±29.17ns | -0.45% | | Rgb family/rgb to linsrgb | 10.6±0.49µs | 10.4±0.37µs | -1.89% | | Rgb family/rgb to linsrgb - wide::f32x8 | 6.0±0.25µs | 6.2±0.33µs | +3.33% | | Rgb family/rgb_u8 to linsrgb_f32 | 342.4±15.51ns | 350.9±21.61ns | +2.48% | | Rgb family/rgb_u8 to linsrgb_f64 | 346.2±12.90ns | 345.3±11.49ns | -0.26% | | Rgb family/xyz to linsrgb | **8.6±0.27µs** | 9.1±0.52µs | **+5.81%** | | Rgb family/xyz to linsrgb - wide::f32x8 | 1330.6±70.35ns | 1396.6±263.11ns | +4.96% |
Ogeon commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded:

github-actions[bot] commented 1 year ago

Benchmark for 19623cf

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Cie family/lab to lch | 3.1±0.01µs | 3.1±0.02µs | 0.00% | | Cie family/lab to xyz | **762.2±3.44ns** | 773.6±54.45ns | **+1.50%** | | Cie family/lch to lab | 2.4±0.01µs | 2.4±0.01µs | 0.00% | | Cie family/linsrgb to xyz | 4.4±0.03µs | **4.3±0.02µs** | **-2.27%** | | Cie family/linsrgb to xyz - wide::f32x8 | 780.6±12.02ns | **762.0±19.05ns** | **-2.38%** | | Cie family/xyz to lab | 21.1±0.10µs | 21.2±0.31µs | +0.47% | | Cie family/xyz to yxy | 657.6±5.44ns | 662.8±12.14ns | +0.79% | | Cie family/yxy to xyz | **527.4±1.97ns** | 529.5±5.56ns | **+0.40%** | | Matrix functions/matrix_inverse | 11.5±0.04ns | 11.5±0.06ns | 0.00% | | Matrix functions/multiply_3x3 | **10.5±0.07ns** | 10.6±0.43ns | **+0.95%** | | Matrix functions/multiply_rgb_to_xyz | **6.4±0.03ns** | 6.7±0.43ns | **+4.69%** | | Matrix functions/multiply_xyz | **6.4±0.04ns** | 6.5±0.21ns | **+1.56%** | | Matrix functions/multiply_xyz_to_rgb | **6.4±0.02ns** | 6.6±0.32ns | **+3.13%** | | Matrix functions/rgb_to_xyz_matrix | 30.1±0.09ns | 30.1±0.16ns | 0.00% | | Rgb family/hsl to hsv | 643.9±6.70ns | 644.3±3.69ns | +0.06% | | Rgb family/hsl to linear hsl | **12.7±0.05µs** | 12.8±0.08µs | **+0.79%** | | Rgb family/hsl to rgb | 1983.3±7.67ns | 1982.3±7.74ns | -0.05% | | Rgb family/hsv to hsl | **826.4±8.94ns** | 845.6±11.53ns | **+2.32%** | | Rgb family/hsv to hwb | **223.0±0.85ns** | 229.5±0.93ns | **+2.91%** | | Rgb family/hsv to linear hsv | **12.2±0.08µs** | 12.6±0.12µs | **+3.28%** | | Rgb family/hsv to rgb | 1865.4±12.93ns | 1861.0±136.43ns | -0.24% | | Rgb family/hwb to hsv | 464.9±3.78ns | 465.3±5.52ns | +0.09% | | Rgb family/hwb to linear hwb | **12.7±0.05µs** | 13.2±0.13µs | **+3.94%** | | Rgb family/linear hsl to hsl | 10.7±0.03µs | 10.7±0.12µs | 0.00% | | Rgb family/linear hsv to hsv | 10.1±0.04µs | 10.1±0.05µs | 0.00% | | Rgb family/linear hwb to hwb | 10.8±0.05µs | 10.8±0.05µs | 0.00% | | Rgb family/linsrgb to rgb | 5.5±0.02µs | 5.5±0.02µs | 0.00% | | Rgb family/linsrgb to rgb - wide::f32x8 | 7.4±0.03µs | 7.4±0.03µs | 0.00% | | Rgb family/linsrgb_f32 to rgb_u8 | 908.5±4.55ns | 906.7±3.06ns | -0.20% | | Rgb family/linsrgb_f64 to rgb_u8 | 1169.1±9.12ns | 1167.3±5.31ns | -0.15% | | Rgb family/rgb to hsl | **793.4±3.35ns** | 799.9±3.60ns | **+0.82%** | | Rgb family/rgb to hsl - wide::f32x8 | 501.4±10.48ns | **494.8±4.21ns** | **-1.32%** | | Rgb family/rgb to hsv | **498.1±1.88ns** | 500.8±1.78ns | **+0.54%** | | Rgb family/rgb to hsv - wide::f32x8 | 443.2±1.66ns | 443.4±7.96ns | +0.05% | | Rgb family/rgb to linsrgb | **7.4±0.03µs** | 7.5±0.06µs | **+1.35%** | | Rgb family/rgb to linsrgb - wide::f32x8 | 5.6±0.02µs | 5.6±0.03µs | 0.00% | | Rgb family/rgb_u8 to linsrgb_f32 | 327.9±1.03ns | 327.8±1.09ns | -0.03% | | Rgb family/rgb_u8 to linsrgb_f64 | 331.3±1.26ns | **328.4±1.80ns** | **-0.88%** | | Rgb family/xyz to linsrgb | 8.0±0.05µs | **7.9±0.02µs** | **-1.25%** | | Rgb family/xyz to linsrgb - wide::f32x8 | 1239.5±6.89ns | 1238.0±6.02ns | -0.12% |