1 | import { __read, __spreadArray } from "tslib";
|
2 | import { DIRECTION } from '../../constant';
|
3 |
|
4 | var PaddingCal = (function () {
|
5 | |
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | function PaddingCal(top, right, bottom, left) {
|
13 | if (top === void 0) { top = 0; }
|
14 | if (right === void 0) { right = 0; }
|
15 | if (bottom === void 0) { bottom = 0; }
|
16 | if (left === void 0) { left = 0; }
|
17 | this.top = top;
|
18 | this.right = right;
|
19 | this.bottom = bottom;
|
20 | this.left = left;
|
21 | }
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | PaddingCal.instance = function (top, right, bottom, left) {
|
30 | if (top === void 0) { top = 0; }
|
31 | if (right === void 0) { right = 0; }
|
32 | if (bottom === void 0) { bottom = 0; }
|
33 | if (left === void 0) { left = 0; }
|
34 | return new PaddingCal(top, right, bottom, left);
|
35 | };
|
36 | |
37 |
|
38 |
|
39 |
|
40 | PaddingCal.prototype.max = function (padding) {
|
41 | var _a = __read(padding, 4), top = _a[0], right = _a[1], bottom = _a[2], left = _a[3];
|
42 | this.top = Math.max(this.top, top);
|
43 | this.right = Math.max(this.right, right);
|
44 | this.bottom = Math.max(this.bottom, bottom);
|
45 | this.left = Math.max(this.left, left);
|
46 | return this;
|
47 | };
|
48 | |
49 |
|
50 |
|
51 |
|
52 | PaddingCal.prototype.shrink = function (padding) {
|
53 | var _a = __read(padding, 4), top = _a[0], right = _a[1], bottom = _a[2], left = _a[3];
|
54 | this.top += top;
|
55 | this.right += right;
|
56 | this.bottom += bottom;
|
57 | this.left += left;
|
58 | return this;
|
59 | };
|
60 | |
61 |
|
62 |
|
63 |
|
64 |
|
65 | PaddingCal.prototype.inc = function (bbox, direction) {
|
66 | var width = bbox.width, height = bbox.height;
|
67 | switch (direction) {
|
68 | case DIRECTION.TOP:
|
69 | case DIRECTION.TOP_LEFT:
|
70 | case DIRECTION.TOP_RIGHT:
|
71 | this.top += height;
|
72 | break;
|
73 | case DIRECTION.RIGHT:
|
74 | case DIRECTION.RIGHT_TOP:
|
75 | case DIRECTION.RIGHT_BOTTOM:
|
76 | this.right += width;
|
77 | break;
|
78 | case DIRECTION.BOTTOM:
|
79 | case DIRECTION.BOTTOM_LEFT:
|
80 | case DIRECTION.BOTTOM_RIGHT:
|
81 | this.bottom += height;
|
82 | break;
|
83 | case DIRECTION.LEFT:
|
84 | case DIRECTION.LEFT_TOP:
|
85 | case DIRECTION.LEFT_BOTTOM:
|
86 | this.left += width;
|
87 | break;
|
88 | default:
|
89 | break;
|
90 | }
|
91 | return this;
|
92 | };
|
93 | |
94 |
|
95 |
|
96 | PaddingCal.prototype.getPadding = function () {
|
97 | return [this.top, this.right, this.bottom, this.left];
|
98 | };
|
99 | |
100 |
|
101 |
|
102 | PaddingCal.prototype.clone = function () {
|
103 | return new (PaddingCal.bind.apply(PaddingCal, __spreadArray([void 0], __read(this.getPadding()), false)))();
|
104 | };
|
105 | return PaddingCal;
|
106 | }());
|
107 | export { PaddingCal };
|
108 |
|
\ | No newline at end of file |