CSharp examples for System.Drawing:Color Brightness
Decreases the luminosity of a color by a specified amount.
using Microsoft.Xna.Framework; using System;/*from w w w .ja v a 2 s . c o m*/ public class Main{ /// <summary> /// Decreases the luminosity of a color by a specified amount. /// </summary> public static Color Darken(this Color color, float amount) { return new Color(color.ToVector3() * (1 - amount)); } /// <summary> /// Decreases the luminosity of a color by a random amount that is between a specified range. /// </summary> public static Color Darken(this Color color, float minAmount, float maxAmount) { return Darken(color, (float)Random.NextDouble() * (maxAmount - minAmount) + minAmount); } /// <summary> /// Decreases the luminosity of a color by a random amount. /// </summary> public static Color Darken(this Color color) { return Darken(color, 0, 1); } }