Putting floats into array from text file
in
Programming Questions
•
2 years ago
Im importing a txt file into processing to draw shapes to the screen. I am drawing ellipses based off the file and want to connect them with a line.
I think the final code for it is line(xPos[i-1], yPos[i-1], xPos, yPos);
But this doesn't work because I dont have arrays set up for the xPos and yPos. I am creating floats by running through the text file with:
//in void setup
lines = loadStrings("test.txt");
data= new Data[lines.length];
for (int i=0; i<lines.length; i++) {
String[] value = split(lines[i],",");
float ellipseSize = float(value[8]);
float xPos = float(value[9]);
float yPos = float(value[10]);
data[i]= new Data (ellipseSize, xPos,yPos); //I have a Data class connected to this. The ellipses are being draw fine just no luck with a line.
}
So what am I missing? I know its only a few lines of code but Im having trouble. Im trying to have the same look as the header graphic on this forum.
Thanks
1
