0
我想用JavaScript测试画布形状是否已创建。使用画布确定形状创建
例如:我创建了一圈:
context.beginPath();
context.fillStyle = this.color;
context.arc(this.x, this.y, this.radius, 0, 2 * Math.PI, false);
context.fill();
context.stroke();
context.closePath();
在这一瞬间圈假设要创建。 我想测试一下这样的:
context.isPointInPath(this.x+1,this.y+1) == true;
但我不觉得这是非常优雅。 任何人有更好的主意?
你的意思是使用isPointInPath检查? – mrbadnews 2013-03-06 12:48:42
是的,'isPointInPath'。也许'(r + 1,r + 1)'而不是'(r + 0.1,r + 0.1)'会更好,也许整数对像素更好 – kidwon 2013-03-06 13:24:55