Here you can find the source of reallyDark(Color c)
Parameter | Description |
---|---|
c | the color to look at |
public static boolean reallyDark(Color c)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.awt.Color; public class Main { private static float hue_sat_bri[] = new float[3]; /** Return true if the color is really dark. (Technically, if its brightness is less than 10%.)/*from ww w .j a v a 2s . co m*/ <p>For example, if you're drawing black text on a region of color, you can use this method to determine when to switch to white.</p> @param c the color to look at @return true, if c is really dark, else false */ public static boolean reallyDark(Color c) { synchronized (hue_sat_bri) { Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), hue_sat_bri); return (hue_sat_bri[2] < 0.10f); // pick a value... 10% } } }