not drawing enough lines (array), why?
in
Programming Questions
•
2 years ago
Hi there,
I would like to draw lines, which quantity is given in an array. But processing is drawing only and always 2 lines and not more.
Here is the code:
I would like to draw lines, which quantity is given in an array. But processing is drawing only and always 2 lines and not more.
Here is the code:
- int[][] daten = { {200,500,300,100},
{300, 400, 200, 350},
{600, 250, 300, 200},
{800, 300, 150, 50}
};
int anzahlachsen = daten[0].length; // zeigt an, wieviele Punkte/Achsen es gibt // how many lines(axis)
int anzahllinie = daten.length; // zeigt an, wieviele VerbindungsLinien es gib
int x;
Achse[] achsen = new Achse[anzahlachsen];
void setup () {
size(1000,1000);
for (int i = 0; i < achsen.length; i++) {
achsen[i] = new Achse(100+x,50,100+x,500);
x = 200;
}
}
void draw() {
for (int i = 0; i < achsen.length; i++) {
achsen[i].display();
}
}
- class Achse {
color c;
int x1;
int y1;
int x2;
int y2;
int einheit;
// Konstruktor
Achse(int xpos1, int ypos1, int xpos2, int ypos2) {
c = color (0);
x1 = xpos1;
y1 = ypos1;
x2 = xpos2;
y2 = ypos2;
einheit = 20;
}
void display (){
//Achse ist nur eine Linie
stroke(c);
line (x1, y1, x2, y2);
zeigeEinheiten ();
}
void zeigeEinheiten()
{
int y=y2;
while (y >= y1)
{
line (x2, y, x2+5, y);
y= y-einheit;
}
}
}
1