请指导我正确的方向。
这是jsfiddle
在示例中,我可以在任意两点之间绘制线条,但只允许用户在控制点之间绘制。
drawLine = function drawLine() {
canvas.on("mouse:down", function (e) {
console.log("mousedown");
getMouse(e);
function getMouse(e) {
startX = (e.e.clientX - 50);
startY = (e.e.clientY);
}
});
canvas.on("mouse:up", function (e) {
console.log("mouseup");
getMouse(e);
function getMouse(e) {
endX = (e.e.clientX - 50);
endY = (e.e.clientY);
}
var line = makeLine([startX, startY, endX, endY]);
//var line = makeLine([ 150, 225, 450, 225 ]);
canvas.add(line);
});