@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.es.js CHANGED
@@ -17378,10 +17378,14 @@ function hsla(ctx, [h, s, l, a]) {
17378
17378
  const alpha = a ? a.evaluate(ctx) : 1;
17379
17379
  const error = validateHSLA(h, s, l, alpha);
17380
17380
  if (error) throw new RuntimeError(error);
17381
- const colorFunction = `hsla(${h}, ${s}%, ${l}%, ${alpha})`;
17382
- const color = Color.parse(colorFunction);
17383
- if (!color) throw new RuntimeError(`Failed to parse HSLA color: ${colorFunction}`);
17384
- return color;
17381
+ const hue = h % 360 / 360, sat = s / 100, lum = l / 100;
17382
+ const m2 = lum <= 0.5 ? lum * (sat + 1) : lum + sat - lum * sat;
17383
+ const m1 = lum * 2 - m2;
17384
+ return new Color(hueToByte(m1, m2, hue + 1 / 3), hueToByte(m1, m2, hue), hueToByte(m1, m2, hue - 1 / 3), alpha);
17385
+ }
17386
+ function hueToByte(m1, m2, t) {
17387
+ t = t < 0 ? t + 1 : t > 1 ? t - 1 : t;
17388
+ 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;
17385
17389
  }
17386
17390
  function has(key, obj) {
17387
17391
  return key in obj;