Here you can find the source of lighter(Color color, double fraction)
Parameter | Description |
---|---|
color | Color to make lighter. |
fraction | Darkness fraction. |
public static Color lighter(Color color, double fraction)
//package com.java2s; // licensed under GNU LGPL import java.awt.Color; public class Main { /**/*from ww w .jav a 2 s . c o m*/ * Make a color lighter. * @param color Color to make lighter. * @param fraction Darkness fraction. * @return Lighter color. */ public static Color lighter(Color color, double fraction) { int red = (int) Math.round(color.getRed() * (1.0 + fraction)); int green = (int) Math.round(color.getGreen() * (1.0 + fraction)); int blue = (int) Math.round(color.getBlue() * (1.0 + fraction)); return new Color(normalize(red), normalize(green), normalize(blue), color.getAlpha()); } private static int normalize(int comp) { if (comp < 0) return 0; else if (comp > 255) return 255; else return comp; } }