fabianmoronzirfas
4/24/2014 - 1:42 PM

img.jpg

size(500, 400);
int step = 5;
int row = 1;
int num_of_points = 1;

strokeWeight(2);
int xdist = width / step;
int ydist;
int y = height/2;


// loop x
for (int x = 0; x < width; x=x+xdist) {
  ydist = height/(num_of_points +1);
  int tmp_num_of_points = num_of_points * 2;

//  loop all the points in that row
  for (int i = 0; i < num_of_points; i++) {

    y = ydist*(i + 1); // calc y
    point(x, y); // draw the point
    // temp values
    int temp_num_of_points =  num_of_points * 2;
    int temp_ydist =  height/(temp_num_of_points +1);
    // calc the next locations depending on the
    // actual location
    // there is still a small error
    PVector target1 = new PVector(x + xdist, y + temp_ydist/2);
    PVector target2 = new PVector(x + xdist, y - temp_ydist/2);
    line(x, y, target1.x, target1.y);
    line(x, y, target2.x, target2.y);
    
    println("this is y " + y + " for point number " + (i+1));
  }
  // increase the number of points times 2
  num_of_points*= 2;
  println("Number of points: " + num_of_points + " in row " +row);
  row++;
}
// end
//saveFrame("img.jpg");