Store Values in an Array to draw a vertex

Hi, I am a newbie, learning programming since a few weeks and I am trying to use stored Values from pos[][] to draw with vertex a line between all the points in the diagramm. But until now I only got points. I can fill up the array but not write the newValue at the next Position in the array. I tried several ways but couldn´t find a solution. Thanks for your help! :)

//Variables //

int hour = 24; float [][] pos = new float [2][hour];

float xValue;

float a; float b; float oldA; float oldB;

boolean getInput = true; boolean grid = true;

//Setup

void setup() {

size(500, 500); smooth(); background(0); }

//Input void storeValues() {

for (int i  = pos[1].length-1; i>0; i--) {

  pos[0][i] = a;
  pos[1][i] = b;

  println(pos[1][i]);

} }

//Graphics

void draw() {

translate (50, 50); scale (0.8);

if (grid) { for (float i = 0; i <= width; i+=width/24) { stroke(255, 0, 0); strokeWeight(1); line(width-i, 0, width-i, height); fill(255, 0, 0); noStroke();

  strokeWeight(4);
  stroke(0, 255, 0);

  a = width-i;
  b = random(0, 500);

  beginShape();

  stroke(283, 128, 19);
  strokeWeight(6);

  vertex(a, b);
  endShape();

  if (getInput) {
    storeValues();

    oldA= a;
    oldB = b;

    println( "oldB", oldB, "B", b);
  }


  println("test");

  if (i >= width) {
    grid=false;
  }
}

}

/* Koordinatensystem */ stroke(255); noFill(); strokeWeight(3); line(0, height, width, height); line(0, height, 0, 0); strokeWeight(8); point(0, height); noStroke(); fill(255); triangle(0, -10, -10, 10, 10, 10); triangle(width+10, height, width-10, height-10, width-10, height+10); }

Tagged:
Sign In or Register to comment.