Java Color Darker reallyDark(Color c)

Here you can find the source of reallyDark(Color c)

Description

Return true if the color is really dark.

License

Open Source License

Parameter

Parameter Description
c the color to look at

Return

true, if c is really dark, else false

Declaration

public static boolean reallyDark(Color c) 

Method Source Code


//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%
        }
    }
}

Related

  1. getDarkerColor(Color color, double diff)
  2. getDarkerLine(Color c, float alternateRowDarkerFactor)
  3. getLineDarkColor()
  4. initializePattern(Color light, Color dark)
  5. makeDarker(final Color color, final double percentage)
  6. setColorsDarkTheme()
  7. slightlyDarker(Color color)
  8. withAlphaAdjustingDarkness(Color c, double d)