Java Color Lighten lighter(Color c)

Here you can find the source of lighter(Color c)

Description

lighter

License

Open Source License

Return

a lighter color, as opposed to a brighter color as in Color.brighter(). This prevents light colors from getting bleached out.

Declaration

public static Color lighter(Color c) 

Method Source Code

//package com.java2s;
/*/*  w  w  w. ja v a 2s.  com*/
 * This software copyright by various authors including the RPTools.net
 * development team, and licensed under the LGPL Version 3 or, at your option,
 * any later version.
 * 
 * Portions of this software were originally covered under the Apache Software
 * License, Version 1.1 or Version 2.0.
 * 
 * See the file LICENSE elsewhere in this distribution for license details.
 */

import java.awt.Color;

public class Main {
    /**
     * @return a lighter color, as opposed to a brighter color as in
     *         Color.brighter(). This prevents light colors from getting
     *         bleached out.
     */
    public static Color lighter(Color c) {
        if (c == null)
            return null;
        else {
            int r = c.getRed();
            int g = c.getGreen();
            int b = c.getBlue();

            r += 64 * (255 - r) / 255;
            g += 64 * (255 - g) / 255;
            b += 64 * (255 - b) / 255;

            return new Color(r, g, b);
        }
    }
}

Related

  1. lighten(Color color, double strength)
  2. lighten(final Color color, final int amount)
  3. lighten(int r, int g, int b, double percent)
  4. lightenColor(Color col, float factor)
  5. lightenColor(Color color)
  6. lighter(Color c)
  7. lighter(Color c, boolean transparant)
  8. lighter(Color c, float factor)
  9. lighter(Color clr)