get Mixed Color - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

get Mixed Color

Demo Code


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

public class Main {
    public static Color getMixed(Color c1, Color c2) {
        int r1, r2, g1, g2, b1, b2;
        r1 = c1.getRed();/*from  w  w w.  jav  a  2s. co  m*/
        g1 = c1.getGreen();
        b1 = c1.getBlue();
        r2 = c2.getRed();
        g2 = c2.getGreen();
        b2 = c2.getBlue();
        return new Color((r1 + r2) >> 1, (g1 + g2) >> 1, (b1 + b2) >> 1);
    }
}

Related Tutorials