Change offset of vector

Hi! I want to create something like a wartptime:

I already have an array of vectors wich start from the center of the image and spread outwards:

Also everytime you click, the oouter vectors change randomly.

Now I want that instead that the line starts at the center (which is where the starting vector is) that it starts somewhere further away from the center, but along that vector.

something like this:

As you can see they are the same lines but their start point is offseted through the line direction.

Any idea how to acomplish this ?



  • that second image isn't showing up.

    you might need to upload it rather than linking to dropbox.

  • Done! Sorry :)

  • make the start point 1/10th of the end point?

    line(window.innerWidth / 2 + vecsArray[i].x / 10, window.innerHeight / 2 + vecsArray[i].y / 10, vecsArray[i].x, vecsArray[i].y);

    would be easier (imo) if you translated the whole scene by innerwidth / 2, innerheight / 2 at the beginning, that way your origin would be in the middle of the screen...

  • Thanks for the help! but is not 100% what i want. Right now the points in the center are being moved away from the center and thus actually changing he initial shape... is there a way to kind of slide the beginning of the line along the vector? thx! :)

Sign In or Register to comment.