StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
StackGenVis/frontend/node_modules/@interactjs/utils/rect.js

78 lines
1.8 KiB

4 years ago
import { closest, getElementRect, parentNode } from "./domUtils.js";
import extend from "./extend.js";
import * as is from "./is.js";
export function getStringOptionResult(value, target, element) {
if (value === 'parent') {
return parentNode(element);
}
if (value === 'self') {
return target.getRect(element);
}
return closest(element, value);
}
export function resolveRectLike(value, target, element, functionArgs) {
let returnValue = value;
if (is.string(returnValue)) {
returnValue = getStringOptionResult(returnValue, target, element);
} else if (is.func(returnValue)) {
returnValue = returnValue(...functionArgs);
}
if (is.element(returnValue)) {
returnValue = getElementRect(returnValue);
}
return returnValue;
}
export function rectToXY(rect) {
return rect && {
x: 'x' in rect ? rect.x : rect.left,
y: 'y' in rect ? rect.y : rect.top
};
}
export function xywhToTlbr(rect) {
if (rect && !('left' in rect && 'top' in rect)) {
rect = extend({}, rect);
rect.left = rect.x || 0;
rect.top = rect.y || 0;
rect.right = rect.right || rect.left + rect.width;
rect.bottom = rect.bottom || rect.top + rect.height;
}
return rect;
}
export function tlbrToXywh(rect) {
if (rect && !('x' in rect && 'y' in rect)) {
rect = extend({}, rect);
rect.x = rect.left || 0;
rect.y = rect.top || 0;
rect.width = rect.width || rect.right || 0 - rect.x;
rect.height = rect.height || rect.bottom || 0 - rect.y;
}
return rect;
}
export function addEdges(edges, rect, delta) {
if (edges.left) {
rect.left += delta.x;
}
if (edges.right) {
rect.right += delta.x;
}
if (edges.top) {
rect.top += delta.y;
}
if (edges.bottom) {
rect.bottom += delta.y;
}
rect.width = rect.right - rect.left;
rect.height = rect.bottom - rect.top;
}
//# sourceMappingURL=rect.js.map