drawing lines with two dimensional array?! it that possible
Answered
- Need more info
- Answered
- Working on it
in
Programming Questions
•
2 years ago
Hi,
I've got another new problem.
I would like to draw some separated lines, which data are given. I thought of an two dimensional array?! E.g.
int[][] daten = { {200,500,300,100}, // the data for line 1, the first coordinatex for the vertex is given, you can see it in the code beneath
{300, 400, 200, 350}, // data for line 2,
{600, 250, 300, 200}, // data line 3
{800, 300, 150, 50} // data line 4
};
As you can see beneath the code, the xCoordinate should be in all lines the same.The lines should be drawn one after the other. And it should be extendable.
At the moment it's only possible to draw one line. Don't know how I can handle it with more data and lines. Do you have an idea?
And this is how ist should looks like (user 1 is the first line, user 2, the second, ...only these should be drawn at the moment) :
Any help would be appreciated. Thanks!
I've got another new problem.
I would like to draw some separated lines, which data are given. I thought of an two dimensional array?! E.g.
int[][] daten = { {200,500,300,100}, // the data for line 1, the first coordinatex for the vertex is given, you can see it in the code beneath
{300, 400, 200, 350}, // data for line 2,
{600, 250, 300, 200}, // data line 3
{800, 300, 150, 50} // data line 4
};
As you can see beneath the code, the xCoordinate should be in all lines the same.The lines should be drawn one after the other. And it should be extendable.
At the moment it's only possible to draw one line. Don't know how I can handle it with more data and lines. Do you have an idea?
- int[] daten = {200, 300, 300, 100};
void setup() {
size(1000, 1000);
for (int i=0; i<daten.length; i++)
println (daten[i]);
}
void draw() {
beginShape();
noFill();
smooth();
stroke(0, 0, 255);
int x=100;
for (int i=0; i< daten.length; i++)
{
vertex(x, daten[i]);
x= x+200;
;
}
endShape();
}
And this is how ist should looks like (user 1 is the first line, user 2, the second, ...only these should be drawn at the moment) :
Any help would be appreciated. Thanks!
1