Drawing a polyline from txt String
in
Programming Questions
•
11 months ago
Hello,
I have a txt file with points' coordinates.
As far as I draw points, ellipses, rectangles everything is ok.
But now I want to draw a polyline. By polyline, I mean a shape (vertex1 connects vertex 2, vertex2 connects vertex3 .... vertex n-1 connects n) How do I have to write a script for this?
I pasted a part of my script below:
- String[] Greenline = loadStrings("Greenline.txt");
- if(i<Greenline.length){
- float[] GL = float(split(Greenline[i], "," ));
- float[] GL1 = float(split(Greenline[70], "," ));
- float[] GL2 = float(split(Greenline[71], "," ));
- beginShape();
- vertex(GL1[0],1000-GL1[1]);
- vertex(GL2[0],1000-GL2[1]);
- // HOW TO ACCESS ALL THE POINTS AT ONCE, WITHOU WRITING 100 POINTS?
- endShape();
- atLines[i].Greenline(GL[0],GL[1]);
- }
AND CLASS FOR IT:
- class AtLines {
- float size =1;
- AtLines() {
- }
- void Greenline(float x1, float y1) {
- fill(#F91157);
- ellipse(x1, 1000-y1, size, size);
- }
- }
1