commonMain.korlibs.math.geom.Scale.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of korma Show documentation
Show all versions of korma Show documentation
Mathematic library for Multiplatform Kotlin 1.3
package korlibs.math.geom
import korlibs.math.annotations.*
import korlibs.memory.pack.*
//@KormaValueApi
inline class Scale internal constructor(internal val raw: Float2Pack) {
val scaleX: Float get() = raw.f0
val scaleY: Float get() = raw.f1
val scaleAvg: Float get() = scaleX * .5f + scaleY * .5f
val avg: Float get() = scaleAvg
val avgD: Double get() = scaleAvg.toDouble()
val scaleXD: Double get() = scaleX.toDouble()
val scaleYD: Double get() = scaleY.toDouble()
val scaleAvgD: Double get() = scaleAvg.toDouble()
constructor() : this(1f, 1f)
constructor(scale: Float) : this(float2PackOf(scale, scale))
constructor(scale: Double) : this(scale.toFloat())
constructor(scale: Int) : this(scale.toFloat())
constructor(scaleX: Float, scaleY: Float) : this(float2PackOf(scaleX, scaleY))
constructor(scaleX: Double, scaleY: Double) : this(scaleX.toFloat(), scaleY.toFloat())
constructor(scaleX: Int, scaleY: Int) : this(scaleX.toFloat(), scaleY.toFloat())
}
fun Scale.toPoint(): Point = Point(raw)
fun Scale.toVector2(): Vector2 = Vector2(raw)
@KormaMutableApi
sealed interface IScale {
val scaleX: Double
val scaleY: Double
}
@KormaMutableApi
data class MScale(
override var scaleX: Double,
override var scaleY: Double,
) : IScale
© 2015 - 2025 Weber Informatics LLC | Privacy Policy