【发布时间】:2012-08-27 02:00:07
【问题描述】:
一个例子here。
var context=document.getElementById("canvas").getContext("2d");
//Red Box
context.beginPath();
context.fillStyle="Red";
context.rect(10,10,50,50);
context.fill();
//Pink circle
context.beginPath();
context.lineWidth="3";
context.fillStyle="Pink";
context.arc(250,250,50,0,Math.PI*2,false);
context.fill();
context.stroke();
context.font="1.2em Verdana";
context.fillStyle="Black";
context.fillText(context.isPointInPath(35,35),35,35);
context.fillText(context.isPointInPath(250,250),250,250);
如果您在没有 beginPath 的情况下编写,则检测到所有对象。 如何识别画布上的对象或省略 beginPath?
【问题讨论】:
-
+1 是一个简单、优雅且适当精简的测试用例来解释您的问题。
标签: javascript html canvas