drawing a lightning! how to?

so for example i have this:

no problem using lineto.
but, what if i want to do this ?

i´m simply not sure about the maths here. anyone could guide me?
i always have source and target coordinates but how would i go about "dividing" this
line into lets say 8 [img]lineto[/img]´s with slight random variations but still point to the target?
anybody could help me? would be much appreciated
thanks!!

no problem using lineto.
but, what if i want to do this ?

i´m simply not sure about the maths here. anyone could guide me?
i always have source and target coordinates but how would i go about "dividing" this
line into lets say 8 [img]lineto[/img]´s with slight random variations but still point to the target?

anybody could help me? would be much appreciated
