Java examples for 2D Graphics:Color Light
set Color Brightness
//package com.java2s; import java.awt.*; public class Main { public static Color setBrightness(Color color, float brightness) { float[] hsbvals; hsbvals = new float[3]; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbvals);//from www . ja v a 2s.c om hsbvals[2] = brightness; hsbvals[2] = Math.min(hsbvals[2], 1.0f); hsbvals[2] = Math.max(hsbvals[2], 0.0f); color = new Color( Color.HSBtoRGB(hsbvals[0], hsbvals[1], hsbvals[2])); return color; } }