| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.isVertical = exports.isHorizontal = exports.createTempText = exports.getLocalBBox = exports.getShapeSpace = void 0;
- var tslib_1 = require("tslib");
- var selection_1 = require("./selection");
- /**
- * 获得图形的x、y、width、height
- */
- function getShapeSpace(shape) {
- var bounds = shape && shape.getRenderBounds();
- if (!bounds)
- return {
- width: 0,
- height: 0,
- };
- var max = bounds.getMax();
- var min = bounds.getMin();
- return {
- width: max[0] - min[0],
- height: max[1] - min[1],
- };
- }
- exports.getShapeSpace = getShapeSpace;
- function getLocalBBox(shape) {
- var _a = shape.getLocalBounds(), min = _a.min, max = _a.max;
- var _b = tslib_1.__read([min, max], 2), _c = tslib_1.__read(_b[0], 2), x1 = _c[0], y1 = _c[1], _d = tslib_1.__read(_b[1], 2), x2 = _d[0], y2 = _d[1];
- return { x: x1, y: y1, width: x2 - x1, height: y2 - y1, left: x1, bottom: y2, top: y1, right: x2 };
- }
- exports.getLocalBBox = getLocalBBox;
- function createTempText(group, attrs) {
- var textNode = (0, selection_1.select)(group).append('text').node();
- textNode.attr(tslib_1.__assign(tslib_1.__assign({}, attrs), { visibility: 'hidden' }));
- return textNode;
- }
- exports.createTempText = createTempText;
- function isHorizontal(p1, p2) {
- var _a = tslib_1.__read(p1, 2), x1 = _a[0], y1 = _a[1];
- var _b = tslib_1.__read(p2, 2), x2 = _b[0], y2 = _b[1];
- return x1 !== x2 && y1 === y2;
- }
- exports.isHorizontal = isHorizontal;
- function isVertical(p1, p2) {
- var _a = tslib_1.__read(p1, 2), x1 = _a[0], y1 = _a[1];
- var _b = tslib_1.__read(p2, 2), x2 = _b[0], y2 = _b[1];
- return x1 === x2 && y1 !== y2;
- }
- exports.isVertical = isVertical;
- //# sourceMappingURL=shape.js.map
|