Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PreyeaRegmi/0f65a1b3a73b82e3af16440be81091fe to your computer and use it in GitHub Desktop.
Save PreyeaRegmi/0f65a1b3a73b82e3af16440be81091fe to your computer and use it in GitHub Desktop.
verticalscroll-gauss-compose
fun getFactor(index: Int, draggedIndex: Int): Float {
val distance = Math.abs(index - draggedIndex).toFloat()
val sigma = 1f // Adjust the sigma for the width of the bell curve
val max = .9f
// Gaussian function
val bellCurve = exp((-distance.pow(2)) / (2 * sigma.pow(2)))
// Scale the bell curve to be in the range 0f to 0.8f
val scaledValue = bellCurve * max
// Ensure the value is within the desired range
return if (scaledValue > max) max else scaledValue.toFloat()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment