-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use Length in fill extrusion base and height expressions
- Loading branch information
Showing
11 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...ssions/src/commonMain/kotlin/dev/sargunv/maplibrecompose/expressions/ast/MetersLiteral.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package dev.sargunv.maplibrecompose.expressions.ast | ||
|
||
import dev.sargunv.maplibrecompose.expressions.ExpressionContext | ||
import dev.sargunv.maplibrecompose.expressions.value.MetersValue | ||
import io.github.kevincianfarini.alchemist.scalar.toLength | ||
import io.github.kevincianfarini.alchemist.type.Length | ||
import io.github.kevincianfarini.alchemist.unit.LengthUnit.International.Meter | ||
|
||
/** A [Literal] representing a [Length] value. */ | ||
public data class MetersLiteral private constructor(override val value: Length) : | ||
Literal<MetersValue, Length> { | ||
|
||
override fun compile(context: ExpressionContext): CompiledLiteral<MetersValue, Float> = | ||
FloatLiteral.of(value.toDouble(Meter).toFloat()).cast() | ||
|
||
override fun visit(block: (Expression<*>) -> Unit): Unit = block(this) | ||
|
||
public companion object { | ||
private val cache = FloatCache { MetersLiteral(it.toDouble().toLength(Meter)) } | ||
|
||
public fun of(value: Length): MetersLiteral = cache[value.toDouble(Meter).toFloat()] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters