Lightens a color based on the float value entered. - Android Graphics

Android examples for Graphics:Color Value

Description

Lightens a color based on the float value entered.

Demo Code


import android.graphics.Color;

public class Main {
  /**/*  w  w  w  .  j av  a 2 s.  c  om*/
   * Lightens a color based on the float value entered.
   * 
   * @param color
   *          your color int.
   * @param factor
   *          0.1 = 10% light; 0.9 = 90% light.
   * @return Color int.
   */
  public static int lightenColor(int color, float factor) {
    float[] hsv = new float[3];
    Color.colorToHSV(color, hsv);
    hsv[2] *= -factor;
    return Color.HSVToColor(hsv);
  }
}

Related Tutorials