Java Color Brighten getSlightlyBrighter(Color color)

Here you can find the source of getSlightlyBrighter(Color color)

Description

Computes and returns a Color that is slightly brighter than the specified Color.

License

Open Source License

Parameter

Parameter Description
color the color used as basis for the brightened color

Return

a slightly brighter color

Declaration

public static Color getSlightlyBrighter(Color color) 

Method Source Code

//package com.java2s;
import java.awt.*;

public class Main {
    /**// w w w.  ja v a2s  . com
     * Computes and returns a Color that is slightly brighter
     * than the specified Color. 
     * 
     * @param color   the color used as basis for the brightened color
     * @return a slightly brighter color
     */
    public static Color getSlightlyBrighter(Color color) {
        return getSlightlyBrighter(color, 1.1f);
    }

    /**
     * Computes and returns a Color that is slightly brighter
     * than the specified Color. 
     * 
     * @param color   the color used as basis for the brightened color
     * @param factor  the factor used to compute the brightness
     * @return a slightly brighter color
     */
    public static Color getSlightlyBrighter(Color color, float factor) {
        float[] hsbValues = new float[3];
        Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(),
                hsbValues);
        float hue = hsbValues[0];
        float saturation = hsbValues[1];
        float brightness = hsbValues[2];
        float newBrightness = Math.min(brightness * factor, 1.0f);
        return Color.getHSBColor(hue, saturation, newBrightness);
    }
}

Related

  1. getBrightness(Color color)
  2. getBrightness(int red, int green, int blue)
  3. getBrightness(java.awt.Color color)
  4. getGradientBrightColors(Color baseColor, float step, float max)
  5. getRandomBrightColor()
  6. getSlightlyBrighter(Color color)
  7. hsbToRgB(double hue, double sat, double brightness)
  8. HSBtoRGB(float hue, float saturation, float brightness)
  9. HSBtoRGB(float parHue, float parSaturation, float parBrightness)