Skip to content

Instantly share code, notes, and snippets.

@indrih17
Last active April 4, 2022 23:11
Show Gist options
  • Save indrih17/db94c88555c8ae95efeb1089df0b1594 to your computer and use it in GitHub Desktop.
Save indrih17/db94c88555c8ae95efeb1089df0b1594 to your computer and use it in GitHub Desktop.
/**
* Найти цвет в точке между двумя цветами в заданном месте.
* @param percent Значение в диапазоне от 0 до 1.
*/
fun pointBetweenColors(from: Float, to: Float, percent: Float): Float =
from + percent * (to - from)
/**
* Найти цвет в точке между двумя цветами в заданном месте.
* @param percent Значение в диапазоне от 0 до 1.
*/
fun pointBetweenColors(from: Color, to: Color, percent: Float) = Color(
red = pointBetweenColors(from.red, to.red, percent),
green = pointBetweenColors(from.green, to.green, percent),
blue = pointBetweenColors(from.blue, to.blue, percent),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment