Java Color Alpha changeAlpha(Color c, double newAlpha)

Here you can find the source of changeAlpha(Color c, double newAlpha)

Description

change Alpha

License

Open Source License

Declaration

public static Color changeAlpha(Color c, double newAlpha) 

Method Source Code


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

public class Main {
    public static Color changeAlpha(Color c, double newAlpha) {
        if (newAlpha < 0)
            newAlpha = 0;/*from  w  w w.  j  a  v a2  s .  c o  m*/
        if (newAlpha > 1)
            newAlpha = 1;
        return new Color(c.getRed(), c.getGreen(), c.getBlue(), (int) Math.round(newAlpha * 255));
    }
}

Related

  1. applyColorFilter(Image image, Color color, float alpha)
  2. buildColorRamp(Color startColor, Color endColor, int numColors, int alpha)
  3. changeAlpha(Color c, double alpha)
  4. changeAlpha(Color c, int alpha)
  5. changeColorAlpha(@Nonnull Color color, int newAlpha)
  6. deriveWithAlpha(Color color, int alpha)
  7. newColourWithAlpha(Color color, double alpha)