translucent Color - Java 2D Graphics

Java examples for 2D Graphics:Color

Description

translucent Color

Demo Code


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

public class Main {
    public static Color translucent(Color c, int newAlpha) {
        int r = c.getRed();
        int g = c.getGreen();
        int b = c.getBlue();
        if (newAlpha < 0) {
            newAlpha = 0;//from   ww w .j  a v a  2  s  . c  om
        }
        if (newAlpha > 255) {
            newAlpha = 255;
        }
        return new Color(r, g, b, newAlpha);
    }
}

Related Tutorials