Java Color Alpha transparentColor(Color color, int alpha)

Here you can find the source of transparentColor(Color color, int alpha)

Description

transparent Color

License

Open Source License

Parameter

Parameter Description
alpha 0: completely transparent; 255: completely opaque.

Declaration

public static final Color transparentColor(Color color, int alpha) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.*;

public class Main {
    /**//w  w w  . ja v a 2  s.  c o  m
     * @param alpha 0: completely transparent; 255: completely opaque.
     */
    public static final Color transparentColor(Color color, int alpha) {
        if (color == null)
            return null;

        /*
        int rgba = color.getRGB();
        rgba |= 0x000000ff;
        alpha |= 0xffffff00;
        rgba &= alpha;
        return new Color (rgba, true);
         */
        return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
    }
}

Related

  1. overwriteAlpha(Color c, float alpha)
  2. premultiplyAlpha(Color fgColor, Color bgColor)
  3. setColorAlpha(Color c, int alpha)
  4. setColorAlpha(Color color, int alpha)
  5. transparent(final Color color, final int alpha)
  6. washColor(int red, int green, int blue, int alpha, int amountToWash)