Android examples for Graphics:Color Darken
Calculate whether a color is light or dark, based on a commonly known brightness formula.
//package com.java2s; import android.graphics.Color; public class Main { private static final int BRIGHTNESS_THRESHOLD = 130; /**/*from ww w.j a v a 2 s . com*/ * Calculate whether a color is light or dark, based on a commonly known * brightness formula. * * @see {@literal http://en.wikipedia.org/wiki/HSV_color_space%23Lightness} */ public static boolean isColorDark(int color) { return (((30 * Color.red(color)) + (59 * Color.green(color)) + (11 * Color .blue(color))) / 100) <= BRIGHTNESS_THRESHOLD; } }