This is a weaker version of Color#brighter() Uses a factor closer to 1. - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

This is a weaker version of Color#brighter() Uses a factor closer to 1.

Demo Code

/**//from w  w w . ja v  a 2 s  .  com
 * Copyright 1998-2008, CHISEL Group, University of Victoria, Victoria, BC, Canada.
 * All rights reserved.
 */
//package com.java2s;
import java.awt.Color;

public class Main {
    /**
     * This is a weaker version of {@link Color#brighter()}
     * Uses a factor closer to 1.
     * @see Color#darker()
     * @return darker Color
     */
    public static Color darker(Color c) {
        float[] hsb = new float[3];
        int r = c.getRed();
        int g = c.getGreen();
        int b = c.getBlue();
        Color.RGBtoHSB(r, g, b, hsb);
        //System.out.println("Saturation: " + hsb[1] + "   ->   " + (hsb[1] * 0.95f));
        //System.out.println("Brightness: " + hsb[2] + "   ->   " + (hsb[2] * 0.95f));
        return Color.getHSBColor(hsb[0], hsb[1] * 0.7f, hsb[2] * 0.95f);
    }
}

Related Tutorials