Increases the luminosity of a color by a specified amount. - CSharp System.Drawing

CSharp examples for System.Drawing:Color Brightness

Description

Increases the luminosity of a color by a specified amount.

Demo Code


using Microsoft.Xna.Framework;
using System;//from   w  w w.  j  a  v a  2  s  .  co  m

public class Main{
        /// <summary>
        /// Increases the luminosity of a color by a specified amount.
        /// </summary>
        public static Color Lighten(this Color color, float amount)
        {
            var vector = color.ToVector3();
            return new Color(vector + amount * (Vector3.One - vector));
        }
        /// <summary>
        /// Increases the luminosity of a color by a random amount that is between a specified range.
        /// </summary>
        public static Color Lighten(this Color color, float minAmount, float maxAmount)
        {
            return Lighten(color, (float)Random.NextDouble() * (maxAmount - minAmount) + minAmount);
        }
        /// <summary>
        /// Increases the luminosity of a color by a random amount.
        /// </summary>
        public static Color Lighten(this Color color)
        {
            return Lighten(color, 0, 1);
        }
}

Related Tutorials