CSharp examples for System.Drawing:Color
linearly interpolates Color
using Microsoft.Xna.Framework; using System;/*from ww w . j a v a2 s. c om*/ public class Main{ /// <summary> /// linearly interpolates Color from - to /// </summary> /// <param name="from">From.</param> /// <param name="to">To.</param> /// <param name="t">T.</param> public static void lerp( ref Color from, ref Color to, out Color result, float t ) { result = new Color(); var t256 = (int)( t * 256 ); result.R = (byte)( from.R + ( to.R - from.R ) * t256 / 256 ); result.G = (byte)( from.G + ( to.G - from.G ) * t256 / 256 ); result.B = (byte)( from.B + ( to.B - from.B ) * t256 / 256 ); result.A = (byte)( from.A + ( to.A - from.A ) * t256 / 256 ); } /// <summary> /// linearly interpolates Color from - to /// </summary> /// <param name="from">From.</param> /// <param name="to">To.</param> /// <param name="t">T.</param> public static Color lerp( Color from, Color to, float t ) { var t256 = (int)( t * 256 ); return new Color( from.R + ( to.R - from.R ) * t256 / 256, from.G + ( to.G - from.G ) * t256 / 256, from.B + ( to.B - from.B ) * t256 / 256, from.A + ( to.A - from.A ) * t256 / 256 ); } }