Java Color Alpha deriveWithAlpha(Color color, int alpha)

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

Description

Creates a new color with the same color components but a different alpha value.

License

Open Source License

Parameter

Parameter Description
color Original color.
alpha Alpha value for new color.

Return

New color with specified alpha value.

Declaration

public static Color deriveWithAlpha(Color color, int alpha) 

Method Source Code


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

import java.awt.Color;

public class Main {
    /**//from  ww  w.jav  a 2  s.  com
     * Creates a new color with the same color components but a different
     * alpha value.
     *
     * @param color Original color.
     * @param alpha Alpha value for new color.
     * @return New color with specified alpha value.
     */
    public static Color deriveWithAlpha(Color color, int alpha) {
        return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
    }
}

Related

  1. buildColorRamp(Color startColor, Color endColor, int numColors, int alpha)
  2. changeAlpha(Color c, double alpha)
  3. changeAlpha(Color c, double newAlpha)
  4. changeAlpha(Color c, int alpha)
  5. changeColorAlpha(@Nonnull Color color, int newAlpha)
  6. newColourWithAlpha(Color color, double alpha)
  7. noAlpha(final Color col)
  8. overwriteAlpha(Color c, float alpha)
  9. premultiplyAlpha(Color fgColor, Color bgColor)