@antv/g2
Version:
the Grammar of Graphics in Javascript
48 lines • 1.19 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isOverlap = exports.isOverflow = exports.isInBounds = exports.parseAABB = void 0;
function parseAABB(min2) {
const { min, max } = min2;
return [
[min[0], min[1]],
[max[0], max[1]],
];
}
exports.parseAABB = parseAABB;
/**
* Whether the `point` in `bounds`.
* @param point
* @param bounds
*/
function isInBounds(point, bounds) {
const [x, y] = point;
const [min, max] = bounds;
return x >= min[0] && x <= max[0] && y >= min[1] && y <= max[1];
}
exports.isInBounds = isInBounds;
/**
* Whether `b1` is overflow from `b2`.
* @param b1
* @param b2
*/
function isOverflow(b1, b2) {
const [min, max] = b1;
return !(isInBounds(min, b2) && isInBounds(max, b2));
}
exports.isOverflow = isOverflow;
/**
* Whether `b1` is overlap with `b2`.
* @param b1
* @param b2
* @returns
*/
function isOverlap(b1, b2) {
const [min1, max1] = b1;
const [min2, max2] = b2;
return (min1[0] < max2[0] &&
max1[0] > min2[0] &&
min1[1] < max2[1] &&
max1[1] > min2[1]);
}
exports.isOverlap = isOverlap;
//# sourceMappingURL=bounds.js.map
;