Here you can find the source of getDarkerColor(Color color, double diff)
Parameter | Description |
---|---|
color | Color. |
diff | Difference factor (values closer to 1.0 will produce results closer to black color). |
public static Color getDarkerColor(Color color, double diff)
//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); } }