如果我有一个HTML Canvas上下文并执行:
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(20,30);
ctx.closePath();
ctx.stroke();
Run Code Online (Sandbox Code Playgroud)
......在10,10和20,30之间画一条线.假设我有这个:
ctx.beginPath();
ctx.moveTo(10,10);
myFunction(ctx);
Run Code Online (Sandbox Code Playgroud)
有没有办法myFunction()找出路径'光标'当前在10,10?
在使用HTML5画布时,如何保存javascript变量/数组的特定路径,然后对其进行操作?这是我到目前为止所做的事情:
ctx.beginPath();
ctx.moveTo(lastX,lastY);
ctx.lineTo(x,y);
ctx.lineWidth = s*2;
ctx.stroke();
ctx.closePath();
Run Code Online (Sandbox Code Playgroud)
现在,我需要的是能够有时将此路径存储在数组中.然后,我需要能够返回并稍后更改数组中所有路径的颜色.(显然,我也不知道该怎么做.)