Skip to content

Commit

Permalink
feat: add SliderValue Distribution builder for checkpoint inside cmpa…
Browse files Browse the repository at this point in the history
…nion object
  • Loading branch information
levinzonr committed Apr 29, 2024
1 parent d5a80dc commit 2dda459
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,24 @@ public interface SliderValueDistribution {
return ParabolicValueDistribution(a, b, c)
}

/**
* Creates a [SliderValueDistribution] with a distribution strategy based on a list of check points.
* Each check point is a pair of offset fraction and value that will be associated with with this progress
* The distribution will interpolate between the check points using linear equations.
*
* Example:
* For the value range of 0..100
* CheckPointsValueDistribution(listOf(0f to 0f, 0.5f to 80f, 1f to 100f))
* This will create a distribution that will place value of 80 at 0.5 progress allowing the user to
* have more precision while selecting values between 80 and 100
*
* @param values a list of check points, each check point is a pair of offset fraction and value
* @return a [SliderValueDistribution] instance with a check points distribution strategy
*/
public fun checkpoints(vararg values: Pair<Float, Float>): SliderValueDistribution {
return CheckPointsValueDistribution(values.toList())
}

/**
* A linear distribution strategy where the input value is directly mapped to the output value.
* Used in [Slider] by default
Expand Down

0 comments on commit 2dda459

Please sign in to comment.