Here you can find the source of modifyBrightness(Color c, float brightness)
Parameter | Description |
---|---|
c | The color |
brightness | The brightness |
public static Color modifyBrightness(Color c, float brightness)
//package com.java2s; /* Copyright 2012 Yaqiang Wang, * yaqiang.wang@gmail.com/* w w w.ja v a 2s . c o m*/ * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2.1 of the License, or (at * your option) any later version. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser * General Public License for more details. */ import java.awt.Color; public class Main { /** * Modifies an existing brightness level of a color * * @param c The color * @param brightness The brightness * @return Adjusted color */ public static Color modifyBrightness(Color c, float brightness) { float hsbVals[] = Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null); return Color.getHSBColor(hsbVals[0], hsbVals[1], brightness * hsbVals[2]); } }