开发者

Find current point on path for HTML Canvas context?

If I have an HTML Canvas context and do:

ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(20,30);
ctx.closePath();
ctx.stroke();

...a line is drawn between 10,10 and 20,30. Suppose I have this:

ctx.beginPath();
ctx.moveTo(10,10);
myFunction(ctx);
开发者_StackOverflow

Is there any way for myFunction() to find out that the path 'cursor' is currently at 10,10?


As far as I know there's no direct way to access arguments passed to various ctx methods (ie. moveTo in this case). You can wrap the Context API into a class of its own to do this, however. See [1] and [2] for reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜