lerp method
Blends two colors using Lerp
FromColor: Color ToColor: Another color Amount: Blending index
Returns the blended color
Implementation
Color lerp(Color toColor, double amount) {
if (amount.isNaN) return this;
// start colours as lerp-able floats
double sr = this.r.toDouble();
double sg = this.g.toDouble();
double sb = this.b.toDouble();
// end colours as lerp-able floats
double er = toColor.r.toDouble();
double eg = toColor.g.toDouble();
double eb = toColor.b.toDouble();
// lerp the colours to get the difference
int r = (sr + (er - sr) * amount).round();
int g = (sg + (eg - sg) * amount).round();
int b = (sb + (eb - sb) * amount).round();
// return the new colour
return Color.fromRGBO(r, g, b, 1.0);
}