We are about to switch to a new forum software. Until then we have removed the registration on this forum.
So I have a text file with 2 numbers on every line, which is the x coordinate and y coordinate of a point. I have trouble reading the text file and using all the coordinates to draw my shape. help plz!!!
Here is how the text file looks like:
320.859 283.133
313.715 287.457
310.332 295.332
302.996 300.285
296.805 307.137
292.359 297.824
286.586 304.398
.........(with 700 more lines)
And my code:
void setup() {
size(400, 400);
background(0);
stroke(255);
strokeJoin(ROUND);
strokeWeight(2);
String[] dots = loadStrings("design.txt");
beginShape();
for (int i = 0; i < dots.length; i+= 1) {
vertex(float(dots[i]), float(dots[i]));
}
endShape(CLOSE);
}
Answers
https://forum.Processing.org/two/discussion/20185/how-to-read-from-a-text-file-to-arraylist-of-pvectors#Item_4
Change the content of your for loop for this next (Please notice it is untested code):
See the reference for documentation of split().
Kf