forked from jchomaz/Vulture
Tracking de l'application VApp (IHM du jeu)
This commit is contained in:
57
VApp/node_modules/vuetify/lib/components/VOverlay/util/point.mjs
generated
vendored
Normal file
57
VApp/node_modules/vuetify/lib/components/VOverlay/util/point.mjs
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
// Types
|
||||
|
||||
/** Convert a point in local space to viewport space */
|
||||
export function elementToViewport(point, offset) {
|
||||
return {
|
||||
x: point.x + offset.x,
|
||||
y: point.y + offset.y
|
||||
};
|
||||
}
|
||||
|
||||
/** Convert a point in viewport space to local space */
|
||||
export function viewportToElement(point, offset) {
|
||||
return {
|
||||
x: point.x - offset.x,
|
||||
y: point.y - offset.y
|
||||
};
|
||||
}
|
||||
|
||||
/** Get the difference between two points */
|
||||
export function getOffset(a, b) {
|
||||
return {
|
||||
x: a.x - b.x,
|
||||
y: a.y - b.y
|
||||
};
|
||||
}
|
||||
|
||||
/** Convert an anchor object to a point in local space */
|
||||
export function anchorToPoint(anchor, box) {
|
||||
if (anchor.side === 'top' || anchor.side === 'bottom') {
|
||||
const {
|
||||
side,
|
||||
align
|
||||
} = anchor;
|
||||
const x = align === 'left' ? 0 : align === 'center' ? box.width / 2 : align === 'right' ? box.width : align;
|
||||
const y = side === 'top' ? 0 : side === 'bottom' ? box.height : side;
|
||||
return elementToViewport({
|
||||
x,
|
||||
y
|
||||
}, box);
|
||||
} else if (anchor.side === 'left' || anchor.side === 'right') {
|
||||
const {
|
||||
side,
|
||||
align
|
||||
} = anchor;
|
||||
const x = side === 'left' ? 0 : side === 'right' ? box.width : side;
|
||||
const y = align === 'top' ? 0 : align === 'center' ? box.height / 2 : align === 'bottom' ? box.height : align;
|
||||
return elementToViewport({
|
||||
x,
|
||||
y
|
||||
}, box);
|
||||
}
|
||||
return elementToViewport({
|
||||
x: box.width / 2,
|
||||
y: box.height / 2
|
||||
}, box);
|
||||
}
|
||||
//# sourceMappingURL=point.mjs.map
|
||||
Reference in New Issue
Block a user