Very basic question about how to pull hexi colors from a table. I want to have a bunch of six-character, regular ol’ hexidecimal colors in a column and use them to color my circles or lines or whatever. But it seems that adding “FF” before the color is necessary because alpha comes FIRST in hexidecimal??? This just seems wrong to me. In the super-simple code below I just create two circles from a table, one green and the other blue. And it works, but I don’t want to have to add “FF” at the front of all my hexidecimal lists. Lots of notes in the code to make it all clear:
The “SampleData” table just has two rows with X and Y positions and “ff00ff00” (green) and “ff0000ff” (blue). To repeat: I just want to have “00ff00” and “0000ff” without having to add those initial alphas. I hope I’m making sense - the code below should be very clear.
void setup() {
size (100,200);
background(#808080);
noStroke();
fill (#ff0000); circle (50,50,50); //Draws a red circle without using the table
// Now I want to draw two more circles, green and blue, using a table:
Table table1 = loadTable("SampleData.csv", "header");
for (int i = 0; i<table1.getRowCount(); i++){
TableRow row = table1.getRow(i);
int x = row.getInt("Xpos");
int y = row.getInt("Ypos");
//So far so good. Now to add color. The following code works when "FF" precedes the normal hexi:
String hs = row.getString("Hue");
int hi = unhex(hs);
fill(hi);
circle (x,y,50);
/*But that requires that I put "FF" in front of my familiar six-character hexidecimal colors
on the data table itself, because alpha comes FIRST in hexidecimal code.
Why can't I just have a table with normal hexi, like "#00ff00" and then do something like:
int c = row.getInt("Hue");
fill (c);
circle (x,y,50);
Or
color c = row.getInt("Hue");
fill (c);
circle (x,y,50);
these both just result in black circles at the moment. So: Any way to just use regular hexidecimal from a table?
*/
}
}