-1
我希望用户能够使用线或线连接一组点。连接完成时,点,和已连接,否则如果播放器连接错误,则屏幕显示错误的连接。使用线/线连接两个元素mannualy
我希望用户能够使用线或线连接一组点。连接完成时,点,和已连接,否则如果播放器连接错误,则屏幕显示错误的连接。使用线/线连接两个元素mannualy
我可以给一些指针开始。
线描
在节点的选择,你可以画线和其他节点上掉落。继续捕获节点ID,如果列表中有1,2,6表示其正确或错误
function drawLine(x, y) {
ctx.beginPath();
ctx.moveTo(startX, startY);
ctx.lineTo(x, y);
ctx.closePath();
ctx.stroke();
ctx.restore();
}
canvas.onmousedown = function (e) {
ctx.save();
e.preventDefault();
e.stopPropagation();
startX = parseInt(e.clientX - offsetX);
startY = parseInt(e.clientY - offsetY);
isDown = true;
}
canvas.onmousemove = function (e) {
if (!isDown) {
return;
}
e.preventDefault();
e.stopPropagation();
mouseX = parseInt(e.clientX - offsetX);
mouseY = parseInt(e.clientY - offsetY);
drawLine(mouseX, mouseY);
}
canvas.onmouseup = function (e) {
if (!isDown) {
return;
}
e.preventDefault();
e.stopPropagation();
isDown = false;
}
向我们展示您迄今为止所做的以及您卡在哪里。 –
我是一个初学者,但我可以给你一个像想要设计我的flash例子。 http://vem-iitg.vlabs.ac.in/Magnetic_Field_Behaviour_in_single_coil(experiment1).html像这样我也想在两点之间划一条线。 –
对于Javascript,您必须使用(html5)画布。看看:[lineTo](https://www.w3schools.com/jsref/canvas_lineto.asp)。 –