Skip to content

Commit e35455b

Browse files
committed
add LinearEquation and RangedLinearEquation classes
1 parent f015d38 commit e35455b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package io.monstarlab.mosaic.slider
2+
3+
public data class LinearEquation(
4+
private val m: Float,
5+
private val c: Float,
6+
) {
7+
public fun valueFromOffset(offset: Float): Float = m * offset + c
8+
9+
public fun offsetFromValue(value: Float): Float = (value - c) / m
10+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.monstarlab.mosaic.slider
2+
3+
public data class RangedLinearEquation(
4+
val equation: LinearEquation,
5+
val offsetRange: ClosedFloatingPointRange<Float>,
6+
val valueRange: ClosedFloatingPointRange<Float>,
7+
)

0 commit comments

Comments
 (0)