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