Here you can find the source of darken(final Color color, final int amount)
Parameter | Description |
---|---|
color | Color to darken. |
amount | Amont to darken the color of. |
private static Color darken(final Color color, final int amount)
//package com.java2s; //License from project: Open Source License import java.awt.Color; public class Main { /**/* w w w .j av a 2 s.c o m*/ * Darkens of the desired amount the given color. * @param color * Color to darken. * @param amount * Amont to darken the color of. * @return The darkened color. */ private static Color darken(final Color color, final int amount) { int red = (color.getRed() - amount < 0) ? 0 : color.getRed() - amount; int green = (color.getGreen() - amount < 0) ? 0 : color.getGreen() - amount; int blue = (color.getBlue() - amount < 0) ? 0 : color.getBlue() - amount; Color colorLightened = new Color(red, green, blue); return colorLightened; } }