获取画布上下文的最后一个点的坐标 [英] Getting a canvas-context's last point's coordinates

查看:109
本文介绍了获取画布上下文的最后一个点的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用CanvasRenderingContext2D.prototype创建一个arrowTo函数。要做到这一点,我需要得到最后一点的坐标。例如

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');

ctx.moveTo(10,40);
//the coordinates of the last point are now (10,40)

ctx.lineTo(50,50);
//and now it's (50,50)

//...

如何检索它们?

推荐答案

或者做不可想象的并覆盖moveTo / lineTo以通过 CanvasRenderingContext2D.prototype 跟踪最后的协调。

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.

这篇关于获取画布上下文的最后一个点的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆