commonMain.Operations.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of color Show documentation
Show all versions of color Show documentation
A collection of drawing/charting utilities
package com.juul.krayon.color
import kotlin.math.roundToInt
/** Linear interpolate towards another color. */
public fun lerp(from: Color, to: Color, percent: Float): Color = Color(
alpha = (from.alpha + (to.alpha - from.alpha) * percent).roundToInt(),
red = (from.red + (to.red - from.red) * percent).roundToInt(),
green = (from.green + (to.green - from.green) * percent).roundToInt(),
blue = (from.blue + (to.blue - from.blue) * percent).roundToInt()
)
© 2015 - 2025 Weber Informatics LLC | Privacy Policy