Advertisement
xeromino

import2

Jan 14th, 2016
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String[] cities;
  2. Table table;
  3. TableRow row;
  4. int frms = 60, rows;
  5. float start[][], end[][];
  6. float l;
  7.  
  8. void setup() {
  9.   size(540, 270);
  10.   background(0);
  11.   fill(255, 100);
  12.   noStroke();
  13.   table = loadTable("cities.csv", "header");
  14.   rows = table.getRowCount();
  15.   start = new float[rows][2];
  16.   end = new float[rows][2];
  17.   for (int i=0; i<rows; i++) {
  18.     row = table.getRow(i);
  19.     float lat = row.getFloat("lat");
  20.     float lng = row.getFloat("lng");
  21.     float x = map(lng, -180, 180, 0, width);
  22.     float y = map(lat, 90, -90, 0, height);
  23.     end[i][0] = x;
  24.     end[i][1] = y;
  25.     start[i][0] = int(random(width/2));
  26.     start[i][1] = int(random(height/2));
  27.   }
  28. }
  29.  
  30. void draw() {
  31.   background(0);
  32.   translate(-270, -200);
  33.   scale(4.5);
  34.   for (int i=0; i<rows; i++) {
  35.     float x = lerp(start[i][0], end[i][0], l);
  36.     float y = lerp(start[i][1], end[i][1], l);
  37.     float sz = .25;
  38.     ellipse(x, y, sz, sz);
  39.   }
  40.   if (l<1) l = map(frameCount,1,frms,0,1);
  41.   //if (frameCount<=frms+30) saveFrame("image-###.gif");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement