Sub InterpolateColor(StartClr As Int, EndClr As Int, Fraction As Float) As Int
Dim clr As Int
For i = 0 To 3
Dim shift As Int = 8 * i
Dim src As Int = Bit.UnsignedShiftRight(Bit.And(StartClr, Bit.ShiftLeft(0xff, shift)), shift)
Dim target As Int = Bit.UnsignedShiftRight(Bit.And(EndClr, Bit.ShiftLeft(0xff, shift)), shift)
clr = clr + Bit.ShiftLeft(Max(0, Min(255, src + (target - src) * Fraction)), shift)
Next
Return clr
End Sub