Tuesday, 25 November 2014

Lab 5 load table balloon

class Balloon {
  float x;
  float y;
  float r;

  Balloon(int x, int y, int r) {

    this.x = x;
    this.y = y;
    this.r = r;
  }
  void display() {

    line(this.x, this.y, this.x, this.y+this.r);
    ellipse(this.x, this.y, this.r, this.r);
  }
  void move_up() {
    this.y = this.y-3;
    if (this.y < 0) {
      this.y = height;
    }
  }
  void move_right() {
    this.x = this.x+1.5;
    if (this.x > width) {
      this.x = 0;
    }
  }
  void fill_c() {
    fill(this.x+this.y-445);
  }
}


Balloon[] b;
Table table;
void setup() {
  size(500, 500);
  table = loadTable("data/new.csv", "header");
  b = new Balloon[table.getRowCount()];
  int index = 0;
  for (TableRow row : table.rows ()) {
    int pos_x  = row.getInt("positionx");
    int pos_y  = row.getInt("positiony");
    int radius  = row.getInt("radius");
    b[index] = new Balloon(pos_x,pos_y,radius);
    index++;
  }
}

void draw() {
  background(255);
  for(int i = 0; i < b.length; i++){
   b[i].display();
  }
}

No comments:

Post a Comment