Skip to content

Commit

Permalink
to-hsla expression support (#2875)
Browse files Browse the repository at this point in the history
* Add to-hsla expression

* Add changelog entry

* Update api

* Update stylegen repo pin

* Update CHANGELOG.md
  • Loading branch information
evil159 authored Dec 9, 2024
1 parent fef824a commit a63644b
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

Mapbox welcomes participation and contributions from everyone.

# main
# 11.9.0-rc.1

* Add `toHsla` expression.

# 11.8.1 December 03, 2024
## Bug fixes 🐞
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1660,6 +1660,22 @@ class ExpressionTest : BaseStyleTest() {
assertEquals(listOf(0.0, 0.0, 255.0, 1.0), layer.iconTextFitPadding!!)
}

/**
* Returns a four-element array containing the input color's Hue, Saturation, Luminance and alpha components, in that order.
*/
@Test
@UiThreadTest
fun toHslaTest() {
val expression = toHsla {
literal("blue")
}
val layer = symbolLayer("id", "source") {
iconTextFitPadding(expression)
}
setupLayer(layer)
assertEquals(listOf(240.0, 100.0, 50.0, 1.0), layer.iconTextFitPadding!!)
}

/**
* Converts the input value to a string. If the input is `null`, the result is `""`. If the input is a boolean, the result is `"true"` or `"false"`. If the input is a number, it is converted to a string as specified by the ["NumberToString" algorithm](https://tc39.github.io/ecma262/#sec-tostring-applied-to-the-number-type) of the ECMAScript Language Specification. If the input is a color, it is converted to a string of the form `"rgba(r,g,b,a)"`, where `r`, `g`, and `b` are numerals ranging from 0 to 255, and `a` ranges from 0 to 1. Otherwise, the input is converted to a string in the format specified by the [`JSON.stringify`](https://tc39.github.io/ecma262/#sec-json.stringify) function of the ECMAScript Language Specification.
*/
Expand Down
5 changes: 5 additions & 0 deletions extension-style/api/Release/metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ package com.mapbox.maps.extension.style.expressions.dsl.generated {
method public static com.mapbox.maps.extension.style.expressions.generated.Expression tan(double value);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toBoolean(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toColor(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toHsla(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toNumber(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toRgba(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toString(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
Expand Down Expand Up @@ -481,6 +482,7 @@ package com.mapbox.maps.extension.style.expressions.generated {
method public static com.mapbox.maps.extension.style.expressions.generated.Expression tan(double value);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toBoolean(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toColor(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toHsla(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toNumber(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toRgba(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public static com.mapbox.maps.extension.style.expressions.generated.Expression toString(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
Expand Down Expand Up @@ -728,6 +730,8 @@ package com.mapbox.maps.extension.style.expressions.generated {
method public com.mapbox.maps.extension.style.expressions.generated.Expression toBoolean(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toColor(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toColor(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toHsla(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toHsla(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toNumber(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toNumber(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public com.mapbox.maps.extension.style.expressions.generated.Expression toRgba(com.mapbox.maps.extension.style.expressions.generated.Expression... expressions);
Expand Down Expand Up @@ -882,6 +886,7 @@ package com.mapbox.maps.extension.style.expressions.generated {
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder tan(double value);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toBoolean(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toColor(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toHsla(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toNumber(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toRgba(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
method public final com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder toString(kotlin.jvm.functions.Function1<? super com.mapbox.maps.extension.style.expressions.generated.Expression.ExpressionBuilder,kotlin.Unit> block);
Expand Down
5 changes: 5 additions & 0 deletions extension-style/api/extension-style.api
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ public final class com/mapbox/maps/extension/style/expressions/dsl/generated/Exp
public static final fun tan (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toBoolean (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toColor (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toHsla (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toNumber (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toRgba (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toString (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
Expand Down Expand Up @@ -453,6 +454,7 @@ public final class com/mapbox/maps/extension/style/expressions/generated/Express
public static final fun tan ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toBoolean ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toColor ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toHsla ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toNumber ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toRgba ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public static final fun toString ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
Expand Down Expand Up @@ -704,6 +706,8 @@ public final class com/mapbox/maps/extension/style/expressions/generated/Express
public final fun toBoolean ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toColor (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toColor ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toHsla (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toHsla ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toNumber (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toNumber ([Lcom/mapbox/maps/extension/style/expressions/generated/Expression;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
public final fun toRgba (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression;
Expand Down Expand Up @@ -858,6 +862,7 @@ public class com/mapbox/maps/extension/style/expressions/generated/Expression$Ex
public final fun tan (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toBoolean (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toColor (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toHsla (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toNumber (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toRgba (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
public final fun toString (Lkotlin/jvm/functions/Function1;)Lcom/mapbox/maps/extension/style/expressions/generated/Expression$ExpressionBuilder;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a63644b

Please sign in to comment.