get Brighter Color from two color value - Java 2D Graphics

Java examples for 2D Graphics:Color Light

Description

get Brighter Color from two color value

Demo Code


//package com.java2s;
import java.awt.Color;

public class Main {
    public static Color getBrighter(Color c1, Color c2) {
        return (getNorm(c1) > getNorm(c2)) ? c1 : c2;
    }/* www .ja v  a  2  s .  c  om*/

    public static double getNorm(Color c) {
        return (c.getRed() * c.getRed() + c.getGreen() * c.getGreen() + c
                .getBlue() * c.getBlue());
    }
}

Related Tutorials