Hey community - thanks for being there.
I have looked elsewhere, but haven’t found a solution to what ought to be extremely simple - apologies if my research was insufficient.
FYI I already can: Load a table, get ints and floats from it, and use these variables to change colors and sizes of elements, for example. I can also import and display an SVG file, and manipulate its properties depending on table date.
What I can’t do: display a specific svg file depending on the contents of a table. For example, if column three contains values of either “happy” or “sad”, it should be easy to display either a happy or frowny face svg file depending on the data. Should be extremely simple, but I can’t seem to figure it out.
Here is a simplified snippet of my code. In this example my goal is to draw a different kind of line (each has its own SVG file) depending on “relationship type” in the csv data file. The question area is marked with lots of commentary so you should be able to see what I intuitively want to do.
Many thanks in advance…
PShape Enemy;
PShape Friend;
PShape Stranger;
void setup(){
size (1000,1000);
//load in all the line shapes I want here, which I'll keep to 3 for now
Enemy= loadShape ("Enemy.svg");
Friend= loadShape ("Friend.svg");
Stranger= loadShape ("Stranger.svg");
}
void draw(){
background (#ffffff);
translate (width/2,height/2);
shapeMode(CENTER);
Table table =loadTable("Others.csv","header");
for (int i=0; i<table.getRowCount(); i++) {
TableRow row = table.getRow(i);
//Here I define some variables from my "Others" table, including the string "relationship type"
int rot = row.getInt("Interaction");
int imp = row.getInt("Importance");
int emo = row.getInt("Emotions");
String RelType = row.getString("Type");
pushMatrix();
rotate(radians(rot*22.5)); //Rotates depending on "rot" value, works fine.
//HERE IS WHERE MY QUESTION IS:
//THIS works fine:
shape(Stranger,0,-200);
// But the point is that I want different lines, depending on the Relationship Type in the table
// I've made the string RelType identical to the svg filename, so what I want to do is:
shape("RelType", 0, -200);
// or:
shape(RelType, 0,-200);
// or:
shape ([put the current value of the string "RelType" right here], 0,-200));
//or something like that, but none of these work. .
popMatrix();
}
}