如果我在以下代码片段中执行测试函数:
function pointInside( r, p ) {
var result =
( p.x >= r.location.x - r.size.width * 0.5 ) &&
( p.x <= r.location.x + r.size.width * 0.5 ) &&
( p.y >= r.location.y - r.size.height * 0.5 ) &&
( p.y <= r.location.y + r.size.height * 0.5 )
;
return result;
}
function test() {
var rect = {};
rect["location"] = { x:6, y:5 };
rect["size"] = { width:10, height:8 };
var p = { x:10, y:8 };
var …Run Code Online (Sandbox Code Playgroud)