我需要一些帮助。 我正在尝试为度量工具创建配额行,但我做不到。我尝试了很多方法,什么也没做。
尽我所能执行我的代码。你能帮我吗?
var LEFT = 0; var RIGHT = 2;
document.addEventListener('contextmenu',event => event.preventDefault());
window.onload = function(){
var canvas = document.getElementById('canvas');
paper.setup(canvas);
var path, myPath, x, y;
var draw = false;
function drawLine(point) {
path = new paper.Path();
path.selected = true;
path.selectedColor = '#F6B343';
path.strokeColor = '#F6B343';
path.strokeWidth = 0.75;
path.moveTo(point);
path.lineTo(point);
draw = true;
}
function quotas(x, y) {
myPath = new paper.Path();
myPath.strokeColor = 'black';
myPath.selected = true;
myPath.add(new paper.Point(x, y));
myPath.add(new paper.Point(10, y));
myPath.rotation = 90;
}
var tool = new paper.Tool();
tool.onMouseDown = function(event) {
if (event.event.button == LEFT) {
if (!draw) {
drawLine(event.point);
quotas(event.point.x, event.point.y);
} else {
draw = false;
}
}
if (event.event.button == RIGHT) {
path.selected = !path.selected;
}
}
tool.onMouseMove = function(event) {
if (draw) {
path.lastSegment.point = event.point;
}
}
}