1
美好的一天大家,检测对象完全在另一个对象内
我想知道是否有一种方法来检测织物对象是否完全在另一个对象内?
我在看文档object.intersectsWithObject(object2)
,但不幸的是,只要对象完全在object2中,函数就不会返回true,而是返回false。
有其他人有这个问题吗?我根本不知道该怎么做。 我已经在fabric.js中搜索了函数。有人可以帮忙吗?
intersectsWithObject: function(other) {
// extracts coords
function getCoords(oCoords) {
return {
tl: new fabric.Point(oCoords.tl.x, oCoords.tl.y),
tr: new fabric.Point(oCoords.tr.x, oCoords.tr.y),
bl: new fabric.Point(oCoords.bl.x, oCoords.bl.y),
br: new fabric.Point(oCoords.br.x, oCoords.br.y)
};
}
var thisCoords = getCoords(this.oCoords),
otherCoords = getCoords(other.oCoords),
intersection = fabric.Intersection.intersectPolygonPolygon(
[thisCoords.tl, thisCoords.tr, thisCoords.br, thisCoords.bl],
[otherCoords.tl, otherCoords.tr, otherCoords.br, otherCoords.bl]
);
return intersection.status === 'Intersection';
}
如果你想知道,如果一个下贱完全是另一个对象,你应该使用isContainedWithinObject内谢谢你已经为你的帮助 塞巴斯蒂安
谢谢!我正在寻找'内部'和'内部'的每一种组合,但没有检查'内部'。谢谢,抱歉!虽然可以帮助别人。 – Sebastian