@mapbox/mapbox-gl-style-spec 14.34.1 → 14.35.0-rc.1

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.cjs CHANGED
@@ -17384,10 +17384,14 @@
17384
17384
  const alpha = a ? a.evaluate(ctx) : 1;
17385
17385
  const error = validateHSLA(h, s, l, alpha);
17386
17386
  if (error) throw new RuntimeError(error);
17387
- const colorFunction = `hsla(${h}, ${s}%, ${l}%, ${alpha})`;
17388
- const color = Color.parse(colorFunction);
17389
- if (!color) throw new RuntimeError(`Failed to parse HSLA color: ${colorFunction}`);
17390
- return color;
17387
+ const hue = h % 360 / 360, sat = s / 100, lum = l / 100;
17388
+ const m2 = lum <= 0.5 ? lum * (sat + 1) : lum + sat - lum * sat;
17389
+ const m1 = lum * 2 - m2;
17390
+ return new Color(hueToByte(m1, m2, hue + 1 / 3), hueToByte(m1, m2, hue), hueToByte(m1, m2, hue - 1 / 3), alpha);
17391
+ }
17392
+ function hueToByte(m1, m2, t) {
17393
+ t = t < 0 ? t + 1 : t > 1 ? t - 1 : t;
17394
+ return Math.round(255 * (t * 6 < 1 ? m1 + (m2 - m1) * t * 6 : t * 2 < 1 ? m2 : t * 3 < 2 ? m1 + (m2 - m1) * (2 / 3 - t) * 6 : m1)) / 255;
17391
17395
  }
17392
17396
  function has(key, obj) {
17393
17397
  return key in obj;