/** * Get a Color object, possibly from a shared map (used to avoid creating too many objects unnecessarily). * @param r * @param g * @param b * @param a * @return */ public static Color getCachedColor(final int r, final int g, final int b, final int a) { return ColorToolsAwt.getCachedColor(ColorTools.makeRGBA(r, g, b, a)); }
/** * Create a new packed-int representation of an RGB color. * * @param v A value between 0 and 255. If a single value is give, the result will be * a shade of gray (RGB all with that value). Otherwise, 3 or 4 values may be given to generate * either an RGB or RGBA color. * @return */ public static Integer getColorRGB(final int... v) { if (v.length == 1) return ColorTools.makeRGB(v[0], v[0], v[0]); if (v.length == 3) return ColorTools.makeRGB(v[0], v[1], v[2]); if (v.length == 4) return ColorTools.makeRGBA(v[0], v[1], v[2], v[3]); throw new IllegalArgumentException("Input to getColorRGB must be either 1, 3 or 4 integer values, between 0 and 255!"); }