Search code examples
javascriptpaperjs

Removing last segment in paper.js (undo)


I've been trying to create an undo function that would remove the last segment from my path in paper.js. I'm having trouble because the function expects an index, but I can't seem to get one. I've tried:

    undo: function(){
        path.removeSegment(path.segments.lastsegment);
        path.removeSegment(path.segments.lastsegment.index);
        path.segments.lastsegment.remove;
    },

and more... None seem to work. Has anyone done this with paper function instead of making your own index? Thanks!


Solution

  • I found one way to do it. If anyone has a cleaner way, feel free to share.

    path.removeSegments(((path.segments).length)-1);