We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I am trying to draw an animated random zig zag made up of small lines. I want to set the x1,y1 values of each line to the x2,y2 values of the previously drawn line so that each line joins up. Is there a way to do this?
I've attached an image to help illustrate this.
Answers
I think this will help you on the way:
Thanks, I am having trouble though as what I am trying to achieve is quite different to what your code produces although I am pretty sure I will need to use the PVector Array part but I can't work out how! The code I am using at the moment is below and I am trying to make it so that each line is a random zig zag rather than a straight line:
Here is one way you might do it, but the realistic solution needs an array or ArrayList as shown by @clankill3r
I've never used an array list or PVector before so am i right in thinking that I am trying to essentially replace the void mousePressed part with something that puts the x2 and y2 values of a line after it is drawn into the array list and then sets these values as the x1 and y1 values of the next line drawn? (I'm new to this sorry!)
To draw a line you need four points. So to draw a multipart line you use the end points from the previous line as the starting point of the next line.
Thanks for all your help, but I think i'll have to learn more before I can work this one out!