CSharp examples for System.Drawing:Color
Interpolate color. Used to fade the colors from green to red.
// Copyright (C) Microsoft Corporation. All rights reserved. using System.Text; using System.Collections.Generic; using System;//from w w w . j a v a 2s. c o m using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework; public class Main{ /// <summary> /// Interpolate color. Used to fade the hud colors from green to red. /// </summary> public static Color InterpolateColor(Color col1, Color col2, float percent) { return new Color( (byte)((float)col1.R * (1.0f - percent) + (float)col2.R * percent), (byte)((float)col1.G * (1.0f - percent) + (float)col2.G * percent), (byte)((float)col1.B * (1.0f - percent) + (float)col2.B * percent), (byte)((float)col1.A * (1.0f - percent) + (float)col2.A * percent)); } }