Just a little html color generator i wrote to work with my chat client to set user name colors, i wanted something that was random for each user, but would produce the same color for a returning user. thought maybe someone else might like it
[java]
public class HTMLColorGenerator {
private int color;
public String getColorFromName(String name){
color = (int) name.getBytes()[0];
for(int i = 1; i < name.length(); i++){
color += name.getBytes() * 31337;
}
color = Math.abs((color * color) / 7);
return "#" + Integer.toString(color).substring(0, 6);
}
}
[/java]
1 Like
sorry i dont looked into code before, jsut looked at “HTMLColorGenerator”
for a normal color cast
other way back
[java]public ColorRGBA processColor(String attrValue) {
Color bColor = Color.decode(“0x”+attrValue);
ColorRGBA trueColor = new ColorRGBA(bColor.getRed(), bColor.getGreen(), bColor.getBlue(), 1.0f);
return trueColor;
}[/java]
and
[java]Color color;
color.hashCode()[/java]