Java Color Darker darkerColor(Color color, double factor)

Here you can find the source of darkerColor(Color color, double factor)

Description

Creates a new Color that is a darker version of this Color.

License

Open Source License

Return

a new Color object that is a darker version of this Color.

Declaration

public static Color darkerColor(Color color, double factor) 

Method Source Code


//package com.java2s;
/*/*  ww  w  .j a  v  a2 s  .  c o m*/
 *  PHEX - The pure-java Gnutella-servent.
 *  Copyright (C) 2001 - 2005 Phex Development Group
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 *  --- CVS Information ---
 *  $Id: GUIUtils.java,v 1.33 2005/10/08 17:21:56 gregork Exp $
 */

import java.awt.*;

public class Main {
    /**
     * Creates a new <code>Color</code> that is a darker version of this
     * <code>Color</code>. This method is the same implementation
     * java.awt.Color#darker is usind except it has a configurable factor.
     * The java.awt.Color default facotr is 0.7
     * @return  a new <code>Color</code> object that is 
     *                    a darker version of this <code>Color</code>.
     * @see        java.awt.Color#brighter
     */
    public static Color darkerColor(Color color, double factor) {
        return new Color(Math.max((int) (color.getRed() * factor), 0),
                Math.max((int) (color.getGreen() * factor), 0), Math.max((int) (color.getBlue() * factor), 0));
    }
}

Related

  1. darker(final Color color, final int rgbOffset)
  2. darker(final Color color, float factor)
  3. darker(int channel, int intensity)
  4. darkerColor(Color c)
  5. darkerColor(Color c, double amount)
  6. darkerColor(String hexValue)
  7. deriveColor(Color orig, int darker)
  8. draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark, Color colorLight)
  9. getDarkColor()