@mapbox/mapbox-gl-style-spec 14.15.0-beta.1 → 14.15.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -12950,17 +12950,19 @@ class RenderColor {
12950
12950
  0,
12951
12951
  0
12952
12952
  ];
12953
- r /= a;
12954
- g /= a;
12955
- b /= a;
12953
+ const invA = 1 / a;
12954
+ r *= invA;
12955
+ g *= invA;
12956
+ b *= invA;
12956
12957
  }
12957
12958
  const red = Math.min(Math.max(r, 0), 1);
12958
12959
  const green = Math.min(Math.max(g, 0), 1);
12959
12960
  const blue = Math.min(Math.max(b, 0), 1);
12960
12961
  const min = Math.min(red, green, blue);
12961
12962
  const max = Math.max(red, green, blue);
12962
- const l = (min + max) / 2;
12963
- if (min === max) {
12963
+ const delta = max - min;
12964
+ const l = (min + max) * 0.5;
12965
+ if (delta === 0) {
12964
12966
  return [
12965
12967
  0,
12966
12968
  0,
@@ -12968,21 +12970,22 @@ class RenderColor {
12968
12970
  a
12969
12971
  ];
12970
12972
  }
12971
- const delta = max - min;
12972
12973
  const s = l > 0.5 ? delta / (2 - max - min) : delta / (max + min);
12973
- let h = 0;
12974
- if (max === red) {
12975
- h = (green - blue) / delta + (green < blue ? 6 : 0);
12976
- } else if (max === green) {
12977
- h = (blue - red) / delta + 2;
12978
- } else if (max === blue) {
12979
- h = (red - green) / delta + 4;
12980
- }
12981
- h *= 60;
12974
+ let h;
12975
+ switch (max) {
12976
+ case red:
12977
+ h = ((green - blue) / delta + (green < blue ? 6 : 0)) * 60;
12978
+ break;
12979
+ case green:
12980
+ h = ((blue - red) / delta + 2) * 60;
12981
+ break;
12982
+ default:
12983
+ h = ((red - green) / delta + 4) * 60;
12984
+ }
12982
12985
  return [
12983
- Math.min(Math.max(h, 0), 360),
12984
- Math.min(Math.max(s * 100, 0), 100),
12985
- Math.min(Math.max(l * 100, 0), 100),
12986
+ h,
12987
+ s * 100,
12988
+ l * 100,
12986
12989
  a
12987
12990
  ];
12988
12991
  }