Java Color Darker getDarkerColor(Color color, double diff)

Here you can find the source of getDarkerColor(Color color, double diff)

Description

Returns darker version of the specified color.

License

Open Source License

Parameter

Parameter Description
color Color.
diff Difference factor (values closer to 1.0 will produce results closer to black color).

Return

Darker version of the specified color.

Declaration

public static Color getDarkerColor(Color color, double diff) 

Method Source Code

//package com.java2s;
import java.awt.Color;

public class Main {
    /**/*from  ww w .  j a va 2  s .  c o  m*/
     * Returns darker version of the specified color.
     * 
     * @param color
     *            Color.
     * @param diff
     *            Difference factor (values closer to 1.0 will produce results
     *            closer to black color).
     * @return Darker version of the specified color.
     */
    public static Color getDarkerColor(Color color, double diff) {
        int r = (int) ((1.0 - diff) * color.getRed());
        int g = (int) ((1.0 - diff) * color.getGreen());
        int b = (int) ((1.0 - diff) * color.getBlue());
        return new Color(r, g, b);
    }
}

Related

  1. getDarkColors(Color[] colors, double fraction)
  2. getDarker(Color c)
  3. getDarker(Color color)
  4. getDarker(Color color, double factor)
  5. getDarkerColor(Color color)
  6. getDarkerLine(Color c, float alternateRowDarkerFactor)
  7. getLineDarkColor()
  8. initializePattern(Color light, Color dark)
  9. makeDarker(final Color color, final double percentage)