Animation points from array
in
Programming Questions
•
8 months ago
Hi!
I have a question about animating points from an array.
Somehow I can't figure out how to make this work.
Please see below an excerpt from my code.
I have a csv file with the data. It's is parsed in the class placesIveBeenV (see code at the bottom).
In setup() the csv is loaded and in draw() the dots + lines are drawn.
But how can I animate these dots + connecting lines?
I tried a couple of different things but nothing works.
Any help is greatly appreciated!
Thanks!
-
void setup() {size(580, 800);smooth();noStroke();
// VINString[] NYlocationsV = loadStrings("openpaths.csv");locationsV = new placesIveBeenV[NYlocationsV.length];for (int i = 0; i < NYlocationsV.length; i++) {locationsV[i] = new placesIveBeenV(NYlocationsV[i]);}}
void draw() {if (savePDF) {beginRecord(PDF, "NYmap"+y+"."+M+"."+d+"-"+hr+"."+m+"."+sec+".pdf");}background(245, 245, 245);
// DRAWING VINfor (int i = 5; i < locationsV.length -1; i++) {noStroke();fill(vin);ellipse(locationsV[i].x, locationsV[i].y, dotSize, dotSize); // DOTSstroke(vin);strokeWeight(routeLine);line(locationsV[i].x, locationsV[i].y, locationsV[i+1].x, locationsV[i+1].y);}}
//and the class:
class placesIveBeenV {float x, y;float X, Y, Z;String lat; // yString lon; // x
placesIveBeenV(String s) {int pos = s.indexOf(',');lat = s.substring(0, pos);// LATs = s.substring(pos+1);pos = s.indexOf(',');lon = s.substring(0, pos);// LONs = s.substring(pos+1);pos = s.indexOf(',');String al = s.substring(0, pos);// ALTString date = s.substring(pos+1);// DATE
X = float(lon);Y = float(lat);Z = int(al);
x = map(X, -73.891000, -74.035000, width,0);// MIN, MAX, MAX, MINy = map(Y, 40.660000, 40.810000, height,0); // MIN, MAX, MAX, MIN}}
1