Java examples for 2D Graphics:Color
returns a r g b a float array that openGL likes
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { int color = 2; System.out// w w w. j a v a 2 s .c o m .println(java.util.Arrays.toString(getRGBAFromInt(color))); } /** * returns a r g b a float array that openGL likes * @param color * @return the r g b a float array */ public static float[] getRGBAFromInt(int color) { float b = ((color) & 0xFF) / 255.0f; float g = ((color >> 8) & 0xFF) / 255.0f; float r = ((color >> 16) & 0xFF) / 255.0f; float a = ((color >> 24) & 0xFF) / 255.0f; return new float[] { r, g, b, a }; } }