Reputation: 95
I'm trying to draw a continuous line in processing using previous lines drawn and generating a new line segment every frame.
I have an ArrayList
called lines and every time a new line is generatied, the x
and y
positions of the start and end of the line is added to the ArrayList
.
I then, in a display function loops through the ArrayList
and for every item in it draw a new line, however my code below draws a single smaller line (the one that's just been created) and nothing else.
My code for drawing the line looks like this:
for (int i = 0; i < t.lines.size()-1; i++) {
println(i);
line(lines.get(i)[0],lines.get(i)[1], lines.get(i)[2], lines.get(i)[3]);
}
and my code for makeing a new line adn adding the coordinates is this:
xi += 0.01;
x = xl;
xl = x + xi;
yl = y;
line[0] = x;
line[1] = y;
line[2] = xl;
line[3] = yl;
lines.add(line);`
As I said, I would like to be able to draew a continuous line with this and will be chaning y coordinates once i have ironed this problem out. Thanks for any help you can give me.
Upvotes: 0
Views: 72
Reputation: 26
You could easily solve your problem if you just take the "end coordinates" from the first line as the "start coordinates" of the second line and so on.
Upvotes: 0