@mapbox/mapbox-gl-style-spec 14.34.1-alpha.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.
@@ -120,11 +120,16 @@ function hsla(ctx: EvaluationContext, [h, s, l, a]: Expression[]) {
120
120
  const alpha = a ? a.evaluate(ctx) : 1;
121
121
  const error = validateHSLA(h, s, l, alpha);
122
122
  if (error) throw new RuntimeError(error);
123
- // eslint-disable-next-line @typescript-eslint/no-base-to-string
124
- const colorFunction = `hsla(${h}, ${s}%, ${l}%, ${alpha})`;
125
- const color = Color.parse(colorFunction);
126
- if (!color) throw new RuntimeError(`Failed to parse HSLA color: ${colorFunction}`);
127
- return color;
123
+ const hue = (h as unknown as number) % 360 / 360, sat = (s as unknown as number) / 100, lum = (l as unknown as number) / 100;
124
+ const m2 = lum <= 0.5 ? lum * (sat + 1) : lum + sat - lum * sat;
125
+ const m1 = lum * 2 - m2;
126
+ return new Color(hueToByte(m1, m2, hue + 1 / 3), hueToByte(m1, m2, hue), hueToByte(m1, m2, hue - 1 / 3), alpha as number);
127
+ }
128
+
129
+ // csscolorparser's css_hue_to_rgb, rounded to a byte
130
+ function hueToByte(m1: number, m2: number, t: number): number {
131
+ t = t < 0 ? t + 1 : t > 1 ? t - 1 : t;
132
+ 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;
128
133
  }
129
134
 
130
135
  function has<T extends object>(key: keyof T, obj: T): boolean {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/mapbox-gl-style-spec",
3
- "version": "14.34.1-alpha.1",
3
+ "version": "14.35.0-rc.1",
4
4
  "description": "a specification for mapbox gl styles",
5
5
  "author": "Mapbox",
6
6
  "license": "SEE LICENSE IN LICENSE.txt",