I've read the note about how colours in Eclipse are handled differently than in the Processing IED, but I just can't work this out. I'm trying to take a Hex code as a string and use it for a color, but I can't get it to work as it should.
This works as it should:
Code:
int colo = parent.color(0xFF119900);
parent.fill(colo);
But I'm starting from a string. So I tried this code:
Code:
String st = "0xFF119900";
int colo = parent.color(Integer.parseInt(st,16));
parent.fill(colo);
But it produces this error:
Exception in thread "Animation Thread" java.lang.NumberFormatException: For input string: "0xFF119900"
I also tried removing '0x' from the string:
Code:
String st = "FF119900";
int colo = parent.color(Integer.parseInt(st,16));
parent.fill(colo);
It produces a similar error.
However, when I change the string as below, it works:
Code:
String st = "79119900";
int colo = parent.color(Integer.parseInt(st,16));
parent.fill(colo);
...except that it's semi-transparent. If the first two characters are 79 or lower, the code works except for the transparency, but if the characters are 80 or higher, I get the exception error.
I've also tried it using parent.unhex() rather than Integer.parseInt(), but the result is the same.
Any solutions, suggestions would be greatly appreciated!