Java RGB Color Create toRGBA(float[] colors)

Here you can find the source of toRGBA(float[] colors)

Description

to RGBA

License

Open Source License

Declaration

public static int toRGBA(float[] colors) 

Method Source Code

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

public class Main {
    public static int toRGBA(int r, int g, int b, int a) {
        return (r << 16) + (g << 8) + (b << 0) + (a << 24);
    }//from   ww w . j a va 2  s .  com

    public static int toRGBA(float r, float g, float b, float a) {
        return toRGBA((int) (r * 255.f), (int) (g * 255.f), (int) (b * 255.f), (int) (a * 255.f));
    }

    public static int toRGBA(float[] colors) {
        if (colors.length != 4)
            throw new IllegalArgumentException("colors[] must have a length of 4!");
        return toRGBA(colors[0], colors[1], colors[2], colors[3]);
    }

    public static int toRGBA(double[] colors) {
        if (colors.length != 4)
            throw new IllegalArgumentException("colors[] must have a length of 4!");
        return toRGBA((float) colors[0], (float) colors[1], (float) colors[2], (float) colors[3]);
    }
}

Related

  1. toRGB(int alpha, int red, int green, int blue)
  2. toRGB(int color)
  3. toRgb(int r, int g, int b)
  4. toRGB(String hexString)
  5. toRGB15(int x)
  6. toRGBA(int argb)
  7. toRGBA(int color)
  8. toRGBA(String hexARGB)
  9. toRGBAArray(int colorBuffer)