hi
i'm loading an xml with - among other information - html color codes. I use the color code in the fill function but it always shows me black. When i retrieve the color code i typecast it to String and then later i want to convert this value to color but it gives me an error, and so i typecast it to integer which seems to ruin the color code since it's always black.
I must be missing something simple.. can anyone see what i'm missing?
Code:
import processing.xml.*;
XMLElement xml;
int largenumber = 500; //hack
Circle[] circles = new Circle[largenumber];
int numCircles;
void setup() {
size(600, 600);
xml = new XMLElement(this, "2008-04-20.xml");
int numCircles = xml.getChildCount();
println(numCircles);
for (int i = 0; i < numCircles; i++) {
XMLElement kid = xml.getChild(i);
XMLElement title_el = kid.getChild("title");
String title = title_el.getContent();
XMLElement word_el = kid.getChild("word");
String word = word_el.getContent();
XMLElement guid_el = kid.getChild("guid");
String guid = guid_el.getContent();
XMLElement color_el = kid.getChild("color");
String colorrgb = "#"+color_el.getContent();
println(title + " | " + word + " | " + colorrgb);
//circles[i] = new Circle(title, word, guid, "#CC6600"); DOES NOT WORK
circles[i] = new Circle(title, word, guid, colorrgb);
}
}
class Circle
{
float x, y;
String title, word, guid;
Circle(String title, String word, String guid, String colorrgb){
//color ccode = int(#CC6600); WORKS
color ccode = int(colorrgb); // DOES NOT WORK
fill(ccode, 100);
float x = random(50, 550);
float y = random(50, 550);
smooth();
strokeWeight(1);
stroke(204, 102, 100);
ellipse(x, y, 50, 50);
}
}