Java Color Darker getDarker(Color color, double factor)

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

Description

get Darker

License

Open Source License

Declaration

public static Color getDarker(Color color, double factor) 

Method Source Code


//package com.java2s;
/*//from   w ww.j  av  a 2 s.  co  m
 * UIUtils.java  2/6/13 1:04 PM
 *
 * Copyright (C) 2012-2013 Nick Ma
 *
 * 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 3
 * of the License, or 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.
 */

import java.awt.Color;

public class Main {
    public static Color getDarker(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. draw3DFrame(Graphics g, Rectangle rect, Color colorBackground, Color colorDark, Color colorLight)
  2. getDarkColor()
  3. getDarkColors(Color[] colors, double fraction)
  4. getDarker(Color c)
  5. getDarker(Color color)
  6. getDarkerColor(Color color)
  7. getDarkerColor(Color color, double diff)
  8. getDarkerLine(Color c, float alternateRowDarkerFactor)
  9. getLineDarkColor()