Given 2 rgb colors and a rectangular area, I\'d like to generate a basic linear gradient between the colors. I\'ve done a quick search and the only thing I\'ve been able to
Following up on the execllent answer of David Crow, here's a Kotlin example implementation
fun gradientColor(x: Double, minX: Double, maxX: Double,
from: Color = Color.RED, to: Color = Color.GREEN): Color {
val range = maxX - minX
val p = (x - minX) / range
return Color(
from.red * p + to.red * (1 - p),
from.green * p + to.green * (1 - p),
from.blue * p + to.blue * (1 - p),
1.0
)
}