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