Getting a canvas-context’s last point’s coordinates

I want to create an arrowTo function with CanvasRenderingContext2D.prototype. To do that, I need to get the coordinates of the last point, e.g.

var ctx = someCanvas.getContext('2d');

//the coordinates of the last point are now (10,40)

//and now it's (50,50)


How can I retrieve them?


You’d have to keep track of them yourself. Or do the unthinkable and override moveTo/lineTo to keep track of the last coords via CanvasRenderingContext2D.prototype.