Here you can find the source of deriveColor(Color orig, int darker)
Parameter | Description |
---|---|
orig | The original color. |
darker | The amount by which to decrease its r, g, and b values. Note that you can use negative values for making a color component "brighter." If this makes any of the three values less than zero, zero is used for that component value; similarly, if it makes any value greater than 255, 255 is used for that component's value. |
public static final Color deriveColor(Color orig, int darker)
//package com.java2s; /*//from www . ja v a 2s .co m * 09/08/2005 * * UIUtil.java - Utility methods for org.fife.ui classes. * Copyright (C) 2005 Robert Futrell * http://fifesoft.com/rtext * Licensed under a modified BSD license. * See the included license file for details. */ import java.awt.Color; public class Main { /** * Derives a color from another color by linearly shifting its blue, green, * and blue values. * * @param orig The original color. * @param darker The amount by which to decrease its r, g, and b values. * Note that you can use negative values for making a color * component "brighter." If this makes any of the three values * less than zero, zero is used for that component value; similarly, * if it makes any value greater than 255, 255 is used for that * component's value. */ public static final Color deriveColor(Color orig, int darker) { int red = orig.getRed() - darker; int green = orig.getGreen() - darker; int blue = orig.getBlue() - darker; if (red < 0) red = 0; else if (red > 255) red = 255; if (green < 0) green = 0; else if (green > 255) green = 255; if (blue < 0) blue = 0; else if (blue > 255) blue = 255; return new Color(red, green, blue); } }