import { DIRECTION } from '../../constant'; /** @ignore */ var PaddingCal = /** @class */ (function () { /** * 初始的 padding 数据 * @param top * @param right * @param bottom * @param left */ function PaddingCal(top, right, bottom, left) { if (top === void 0) { top = 0; } if (right === void 0) { right = 0; } if (bottom === void 0) { bottom = 0; } if (left === void 0) { left = 0; } this.top = top; this.right = right; this.bottom = bottom; this.left = left; } /** * 四周增加 padding * @param padding */ PaddingCal.prototype.shrink = function (padding) { var top = padding[0], right = padding[1], bottom = padding[2], left = padding[3]; this.top += top; this.right += right; this.bottom += bottom; this.left += left; return this; }; /** * 在某一个方向增加 padding * @param bbox * @param direction */ PaddingCal.prototype.inc = function (bbox, direction) { var width = bbox.width, height = bbox.height; switch (direction) { case DIRECTION.TOP: case DIRECTION.TOP_LEFT: case DIRECTION.TOP_RIGHT: this.top += height; break; case DIRECTION.RIGHT: case DIRECTION.RIGHT_TOP: case DIRECTION.RIGHT_BOTTOM: this.right += width; break; case DIRECTION.BOTTOM: case DIRECTION.BOTTOM_LEFT: case DIRECTION.BOTTOM_RIGHT: this.bottom += height; break; case DIRECTION.LEFT: case DIRECTION.LEFT_TOP: case DIRECTION.LEFT_BOTTOM: this.left += width; break; default: break; } return this; }; /** * 获得最终的 padding */ PaddingCal.prototype.getPadding = function () { return [this.top, this.right, this.bottom, this.left]; }; return PaddingCal; }()); export { PaddingCal }; //# sourceMappingURL=padding-cal.js.map