Java Color Lighten lighten(final Color color, final int amount)

Here you can find the source of lighten(final Color color, final int amount)

Description

Lightens of the desired amount the given color.

License

Open Source License

Parameter

Parameter Description
color Color to lighten.
amount Amont to lighten the color of.

Return

The lightened color.

Declaration

private static Color lighten(final Color color, final int amount) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.Color;

public class Main {
    /**/*from  www  . j a v  a2  s. c om*/
     * Lightens of the desired amount the given color.
     * @param color
     *            Color to lighten.
     * @param amount
     *            Amont to lighten the color of.
     * @return The lightened color.
     */
    private static Color lighten(final Color color, final int amount) {
        int red = (color.getRed() + amount > 255) ? 255 : color.getRed() + amount;
        int green = (color.getGreen() + amount > 255) ? 255 : color.getGreen() + amount;
        int blue = (color.getBlue() + amount > 255) ? 255 : color.getBlue() + amount;
        Color colorLightened = new Color(red, green, blue);
        return colorLightened;
    }
}

Related

  1. lighten(Color color)
  2. lighten(Color color, double strength)
  3. lighten(int r, int g, int b, double percent)
  4. lightenColor(Color col, float factor)
  5. lightenColor(Color color)
  6. lighter(Color c)