We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › File Import (x,y) values to make drawing
Page Index Toggle Pages: 1
File Import (x,y) values to make drawing (Read 263 times)
File Import (x,y) values to make drawing
Apr 24th, 2008, 2:47pm
 
Hi,

I am very new at this and trying to input data from a txt file that has x,y values that i want to connect with lines. I dont quite understand the array syntax so i dont know what to put for the x1, y1, x2, y2 values in the line() function. here is the code i have so far:

void setup(){
 size(400, 400);
 background(0);
 stroke(255);
 strokeWeight(20);
}

void draw(){
String[]lines=loadStrings("3.txt");


for (int i=0; i<lines.length; i++){
 println(lines[i]);
 String[]pieces=split(lines[i],'\t');
 if (pieces.length==2){
   int x = int(pieces[0]);
   int y = int(pieces[1]);
   point(x,y);
   line(what goes here???)
   
}
}
}

any help would be wonderful!!! thanks!!!


Page Index Toggle Pages: 1