@mapbox/mapbox-gl-style-spec 14.34.2 → 14.35.0
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 +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +8 -4
- package/dist/index.es.js.map +1 -1
- package/expression/definitions/index.ts +10 -5
- package/package.json +1 -1
|
@@ -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
|
-
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
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 {
|