Java Utililty Methods Color Create

List of utility methods to do Color Create

Description

The list of methods to do Color Create are organized into topic(s).

Method

intcolor(float red, float green, float blue)
Unlike new Color(r,g,b).getRGB(), 1-epsilon rounds to brightest.
return 0xff000000 | (Math.max(0, Math.min((int) (red * 0x100), 0xff)) << 16)
        | (Math.max(0, Math.min((int) (green * 0x100), 0xff)) << 8)
        | Math.max(0, Math.min((int) (blue * 0x100), 0xff));
StringColor(int index)
Color
if (index >= colors.length) {
    return colors[0];
return colors[index];
intcolor(int red, int green, int blue, int alpha)
Puts back the four color components into a integer representation
return ((alpha & 0xFF) << 24) | ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 0);
Stringcolor(int val)
color
return new StringBuilder().append(COLOR_CHARACTER).append(Integer.toHexString(val)).toString();
Stringcolor(String color)
color
if (color == null) {
    return "#FF0000";
} else if (color.startsWith("#")) {
    return color;
} else {
    return "#" + color;
Stringcolor(String color, Object value)
color
return "<html><span color=" + color + ">" + value + "</span>";
Stringcolor(String msg)
Coloring message
return msg.replaceAll("&([0-9a-fA-Fk-oK-OrR])", "\u00A7$1");
Stringcolor(String msg)
color
return msg.replace('&', '\u00A7');
Stringcolor(String s)
color
return translateAlternateColorCodes('&', s);
Stringcolor(String s)
Colorizes a message.
char[] b = s.toCharArray();
for (int i = 0; i < b.length - 1; ++i) {
    if (b[i] == '&' && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
        b[i] = 167;
        b[i + 1] = Character.toLowerCase(b[i + 1]);
return new String(b);
...