Java Color Create toColors(boolean hasAlpha, int... colors)

Here you can find the source of toColors(boolean hasAlpha, int... colors)

Description

Simply calls new Color(color, hasalpha) for each color in colors and returns all of them.

License

Open Source License

Parameter

Parameter Description
hasAlpha true to consider the alpha when creating the Color.
colors the color value.

Return

the colors with alpha added.

Declaration

public static Color[] toColors(boolean hasAlpha, int... colors) 

Method Source Code


//package com.java2s;

import java.awt.*;

public class Main {
    /**//from  w  w w  .j  a v  a  2 s  . co m
     * Simply calls new Color(color, hasalpha) for each color in colors and returns all of them.
     *
     * @param hasAlpha true to consider the alpha when creating the Color.
     * @param colors   the color value.
     *
     * @return the colors with alpha added.
     */
    public static Color[] toColors(boolean hasAlpha, int... colors) {
        Color[] result = new Color[colors.length];
        for (int i = 0; i < colors.length; i++) {
            result[i] = new Color(colors[i], hasAlpha);
        }
        return result;
    }
}

Related

  1. toColor(short rgb565)
  2. toColor(String background)
  3. toColor(String hexString)
  4. toColor(String pString)
  5. toColor(String str)