@tspro/ts-utils-lib 3.3.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/README.md +30 -30
- package/dist/index.d.ts +304 -113
- package/dist/index.es5.iife.js +1 -1
- package/dist/index.es5.polyfilled.iife.js +1 -1
- package/dist/index.js +250 -113
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +250 -113
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
## [3.4.0]- 2026-02-01
|
|
3
|
+
### Added
|
|
4
|
+
- More functions to Rect and AnchoredRect.
|
|
5
|
+
|
|
6
|
+
### Fixed
|
|
7
|
+
- AnchoredRect.toRect() returned wrong Rect.
|
|
8
|
+
|
|
9
|
+
## [3.3.1] - 2026-01-24
|
|
10
|
+
### Fixed
|
|
11
|
+
- README.md.
|
|
12
|
+
|
|
2
13
|
## [3.3.0] - 2026-01-12
|
|
3
|
-
|
|
14
|
+
### Changed
|
|
4
15
|
- Loosen some Utils.Dom function arguments from HTMLElement to Element.
|
|
5
16
|
- Utils.Dom.addClass() and removeClass() accept multiple class names using variadic arg.
|
|
6
17
|
|
package/README.md
CHANGED
|
@@ -4,55 +4,55 @@
|
|
|
4
4
|
A small collection of TypeScript functions, containers, modules, etc. used
|
|
5
5
|
in my personal projects.
|
|
6
6
|
|
|
7
|
-
I do not use much AI in my work but this is exception. Lot of stuff in this
|
|
8
|
-
lib is written by AI.
|
|
9
|
-
|
|
10
7
|
## Links
|
|
8
|
+
[Homepage](https://pahkasoft.com/ts-utils-lib) |
|
|
11
9
|
[Repository](https://github.com/pahkasoft/ts-utils-lib) |
|
|
12
|
-
[Package](https://www.npmjs.com/package/@tspro/ts-utils-lib)
|
|
13
|
-
[Homepage](https://pahkasoft.github.io/ts-utils-lib)
|
|
14
|
-
|
|
15
|
-
Homepage contains TS Docs/API Reference.
|
|
10
|
+
[Package](https://www.npmjs.com/package/@tspro/ts-utils-lib)
|
|
16
11
|
|
|
17
|
-
##
|
|
18
|
-
Version `3.0.0` changed `Device`.
|
|
12
|
+
## Quick Start
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
Use version `3.1.1` with correct `CallTracker` instead.
|
|
14
|
+
### Install
|
|
22
15
|
|
|
23
|
-
## Install
|
|
24
16
|
`npm install @tspro/ts-utils-lib`
|
|
25
17
|
|
|
26
|
-
|
|
27
|
-
```js
|
|
28
|
-
// Import
|
|
29
|
-
import { UniMap } from "@tspro/ts-utils-lib";
|
|
18
|
+
### Import
|
|
30
19
|
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
```ts
|
|
21
|
+
// Import required stuff.
|
|
22
|
+
import { UniMap, Utils } from "@tspro/ts-utils-lib";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Require
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
```ts
|
|
28
|
+
// Require required stuff.
|
|
29
|
+
const { UniMap, Utils } = require("@tspro/ts-utils-lib");
|
|
36
30
|
```
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
### Browser Script
|
|
33
|
+
|
|
39
34
|
- Available in version `2.1.0`.
|
|
40
35
|
- These bundles are transpiled with `ES5` target.
|
|
41
36
|
- With non-polyfilled versions you can use option to your own polyfilling choise.
|
|
42
37
|
|
|
43
38
|
```html
|
|
44
|
-
<!-- Load non-polyfilled or polyfilled bundles
|
|
45
|
-
<script src="https://unpkg.com/@tspro/ts-utils-lib@
|
|
46
|
-
<script src="https://unpkg.com/@tspro/ts-utils-lib@
|
|
39
|
+
<!-- Unpkg CDM: Load non-polyfilled or polyfilled bundles. -->
|
|
40
|
+
<script src="https://unpkg.com/@tspro/ts-utils-lib@3.4.0/dist/index.es5.iife.js"></script>
|
|
41
|
+
<script src="https://unpkg.com/@tspro/ts-utils-lib@3.4.0/dist/index.es5.polyfilled.iife.js"></script>
|
|
47
42
|
|
|
48
|
-
<!-- Load non-polyfilled or polyfilled bundles
|
|
49
|
-
<script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@
|
|
50
|
-
<script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@
|
|
43
|
+
<!-- jsDelivr CDN: Load non-polyfilled or polyfilled bundles. -->
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@3.4.0/dist/index.es5.iife.js"></script>
|
|
45
|
+
<script src="https://cdn.jsdelivr.net/npm/@tspro/ts-utils-lib@3.4.0/dist/index.es5.polyfilled.iife.js"></script>
|
|
51
46
|
|
|
52
|
-
<!-- JS example: -->
|
|
53
47
|
<script>
|
|
54
48
|
const { UniMap, Utils } = window.TsUtilsLib;
|
|
55
|
-
const map = new UniMap();
|
|
56
|
-
console.log(Utils.Str.stringify(map));
|
|
57
49
|
</script>
|
|
58
50
|
```
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const map = new UniMap<string, number>();
|
|
56
|
+
|
|
57
|
+
console.log(Utils.Str.stringify(map));
|
|
58
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -775,20 +775,79 @@ declare class Vec extends BaseContainer {
|
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
/**
|
|
778
|
-
*
|
|
779
|
-
*
|
|
778
|
+
* Mutable axis-aligned 2D rectangle defined by a top-left corner (`x`, `y`)
|
|
779
|
+
* and non-negative size (`width`, `height`).
|
|
780
|
+
*
|
|
781
|
+
* This class represents a basic geometric rectangle without an anchor.
|
|
782
|
+
* All operations assume a coordinate system where:
|
|
783
|
+
* - `left = x`
|
|
784
|
+
* - `top = y`
|
|
785
|
+
* - `right = x + width`
|
|
786
|
+
* - `bottom = y + height`
|
|
787
|
+
*
|
|
788
|
+
* Width and height are always non-negative. An error is thrown if violated.
|
|
780
789
|
*/
|
|
781
790
|
declare class Rect {
|
|
782
791
|
x: number;
|
|
783
792
|
y: number;
|
|
784
793
|
width: number;
|
|
785
794
|
height: number;
|
|
795
|
+
/**
|
|
796
|
+
* Create an empty rectangle at the origin.
|
|
797
|
+
*/
|
|
786
798
|
constructor();
|
|
799
|
+
/**
|
|
800
|
+
* Create a copy of another Rect.
|
|
801
|
+
*/
|
|
802
|
+
constructor(other: Rect);
|
|
803
|
+
/**
|
|
804
|
+
* Create a rectangle from a rect-like object.
|
|
805
|
+
*
|
|
806
|
+
* Accepts `{ left, top, width, height }`.
|
|
807
|
+
*/
|
|
808
|
+
constructor(other: {
|
|
809
|
+
left: number;
|
|
810
|
+
top: number;
|
|
811
|
+
width: number;
|
|
812
|
+
height: number;
|
|
813
|
+
});
|
|
814
|
+
/**
|
|
815
|
+
* Create a rectangle with size only.
|
|
816
|
+
* The rectangle is positioned at the origin.
|
|
817
|
+
*/
|
|
787
818
|
constructor(width: number, height: number);
|
|
819
|
+
/**
|
|
820
|
+
* Create a rectangle from position and size.
|
|
821
|
+
*
|
|
822
|
+
* @param x - Left coordinate
|
|
823
|
+
* @param y - Top coordinate
|
|
824
|
+
* @param width - Rectangle width (must be non-negative)
|
|
825
|
+
* @param height - Rectangle height (must be non-negative)
|
|
826
|
+
*/
|
|
788
827
|
constructor(x: number, y: number, width: number, height: number);
|
|
828
|
+
/**
|
|
829
|
+
* Reset this rectangle to the origin with zero size.
|
|
830
|
+
*/
|
|
789
831
|
set(): Rect;
|
|
832
|
+
/**
|
|
833
|
+
* Set rectangle size and reset position to the origin.
|
|
834
|
+
*
|
|
835
|
+
* @param width - Rectangle width (must be non-negative)
|
|
836
|
+
* @param height - Rectangle height (must be non-negative)
|
|
837
|
+
*/
|
|
790
838
|
set(width: number, height: number): Rect;
|
|
839
|
+
/**
|
|
840
|
+
* Set rectangle position and size.
|
|
841
|
+
*
|
|
842
|
+
* @param x - Left coordinate
|
|
843
|
+
* @param y - Top coordinate
|
|
844
|
+
* @param width - Rectangle width (must be non-negative)
|
|
845
|
+
* @param height - Rectangle height (must be non-negative)
|
|
846
|
+
*/
|
|
791
847
|
set(x: number, y: number, width: number, height: number): Rect;
|
|
848
|
+
/**
|
|
849
|
+
* Create the smallest rectangle enclosing two points.
|
|
850
|
+
*/
|
|
792
851
|
static fromPoints(p1: {
|
|
793
852
|
x: number;
|
|
794
853
|
y: number;
|
|
@@ -796,42 +855,173 @@ declare class Rect {
|
|
|
796
855
|
x: number;
|
|
797
856
|
y: number;
|
|
798
857
|
}): Rect;
|
|
858
|
+
/**
|
|
859
|
+
* Create a rectangle centered at the given point.
|
|
860
|
+
*
|
|
861
|
+
* @param cx - Center x-coordinate
|
|
862
|
+
* @param cy - Center y-coordinate
|
|
863
|
+
* @param width - Rectangle width
|
|
864
|
+
* @param height - Rectangle height
|
|
865
|
+
*/
|
|
799
866
|
static fromCenter(cx: number, cy: number, width: number, height: number): Rect;
|
|
867
|
+
/** Left edge coordinate. */
|
|
800
868
|
get left(): number;
|
|
869
|
+
/** Top edge coordinate. */
|
|
801
870
|
get top(): number;
|
|
871
|
+
/** Right edge coordinate. */
|
|
802
872
|
get right(): number;
|
|
873
|
+
/** Bottom edge coordinate. */
|
|
803
874
|
get bottom(): number;
|
|
875
|
+
/** Geometric center x-coordinate. */
|
|
804
876
|
get centerX(): number;
|
|
877
|
+
/** Geometric center y-coordinate. */
|
|
805
878
|
get centerY(): number;
|
|
879
|
+
/** Geometric center point. */
|
|
806
880
|
get center(): {
|
|
807
881
|
x: number;
|
|
808
882
|
y: number;
|
|
809
883
|
};
|
|
884
|
+
/** Rectangle area (`width * height`). */
|
|
810
885
|
get area(): number;
|
|
886
|
+
/**
|
|
887
|
+
* Whether this rectangle has zero or negative area.
|
|
888
|
+
* Note: width and height are guaranteed non-negative.
|
|
889
|
+
*/
|
|
811
890
|
get isEmpty(): boolean;
|
|
891
|
+
/**
|
|
892
|
+
* Test whether a point lies inside or on the edges of this rectangle.
|
|
893
|
+
*/
|
|
812
894
|
containsPoint(px: number, py: number): boolean;
|
|
895
|
+
/**
|
|
896
|
+
* Test whether another rectangle is fully contained within this rectangle.
|
|
897
|
+
*/
|
|
813
898
|
containsRect(other: Rect): boolean;
|
|
899
|
+
/**
|
|
900
|
+
* Test whether this rectangle intersects another rectangle.
|
|
901
|
+
*
|
|
902
|
+
* Edge-touching is considered an intersection.
|
|
903
|
+
*/
|
|
814
904
|
intersects(other: Rect): boolean;
|
|
905
|
+
/**
|
|
906
|
+
* Test whether this rectangle intersects another rectangle.
|
|
907
|
+
*
|
|
908
|
+
* Edge-touching is considered an intersection.
|
|
909
|
+
*/
|
|
910
|
+
intersects(other: {
|
|
911
|
+
left: number;
|
|
912
|
+
top: number;
|
|
913
|
+
width: number;
|
|
914
|
+
height: number;
|
|
915
|
+
}): boolean;
|
|
916
|
+
/**
|
|
917
|
+
* Compute the intersection of this rectangle with another rectangle.
|
|
918
|
+
*
|
|
919
|
+
* Returns an empty rectangle if there is no overlap.
|
|
920
|
+
*/
|
|
815
921
|
intersectionCopy(other: Rect): Rect;
|
|
922
|
+
/**
|
|
923
|
+
* Compute the intersection of this rectangle with another rectangle.
|
|
924
|
+
*
|
|
925
|
+
* Returns an empty rectangle if there is no overlap.
|
|
926
|
+
*/
|
|
927
|
+
intersectionCopy(other: {
|
|
928
|
+
left: number;
|
|
929
|
+
top: number;
|
|
930
|
+
width: number;
|
|
931
|
+
height: number;
|
|
932
|
+
}): Rect;
|
|
933
|
+
/**
|
|
934
|
+
* Compute the union of this rectangle with another rectangle.
|
|
935
|
+
*/
|
|
816
936
|
unionCopy(other: Rect): Rect;
|
|
937
|
+
/**
|
|
938
|
+
* Compute the union of this rectangle with another rectangle.
|
|
939
|
+
*/
|
|
940
|
+
unionCopy(other: {
|
|
941
|
+
left: number;
|
|
942
|
+
top: number;
|
|
943
|
+
width: number;
|
|
944
|
+
height: number;
|
|
945
|
+
}): Rect;
|
|
946
|
+
/**
|
|
947
|
+
* Create an inset (shrunken) copy of this rectangle.
|
|
948
|
+
*
|
|
949
|
+
* @param dx - Horizontal inset
|
|
950
|
+
* @param dy - Vertical inset
|
|
951
|
+
*/
|
|
817
952
|
insetCopy(dx: number, dy: number): Rect;
|
|
953
|
+
/**
|
|
954
|
+
* Create an inflated (expanded) copy of this rectangle.
|
|
955
|
+
*
|
|
956
|
+
* @param dx - Horizontal expansion
|
|
957
|
+
* @param dy - Vertical expansion
|
|
958
|
+
*/
|
|
818
959
|
inflateCopy(dx: number, dy: number): Rect;
|
|
960
|
+
/**
|
|
961
|
+
* Move this rectangle by the given offset.
|
|
962
|
+
* Modifies this instance.
|
|
963
|
+
*/
|
|
819
964
|
offsetInPlace(dx: number, dy: number): Rect;
|
|
965
|
+
/**
|
|
966
|
+
* Create a translated copy of this rectangle.
|
|
967
|
+
*/
|
|
820
968
|
offsetCopy(dx: number, dy: number): Rect;
|
|
969
|
+
/**
|
|
970
|
+
* Scale this rectangle around its geometric center.
|
|
971
|
+
* Modifies this instance.
|
|
972
|
+
*
|
|
973
|
+
* @param scaleX - Horizontal scale factor
|
|
974
|
+
* @param scaleY - Vertical scale factor (defaults to scaleX)
|
|
975
|
+
*/
|
|
821
976
|
scaleInPlace(scaleX: number, scaleY?: number): Rect;
|
|
977
|
+
/**
|
|
978
|
+
* Create a scaled copy of this rectangle.
|
|
979
|
+
* Scaling is performed around the geometric center.
|
|
980
|
+
*/
|
|
822
981
|
scaleCopy(scaleX: number, scaleY?: number): Rect;
|
|
982
|
+
/**
|
|
983
|
+
* Create a copy with all edges rounded to the nearest integer.
|
|
984
|
+
*/
|
|
823
985
|
roundCopy(): Rect;
|
|
986
|
+
/**
|
|
987
|
+
* Create a copy with all edges rounded down.
|
|
988
|
+
*/
|
|
824
989
|
floorCopy(): Rect;
|
|
990
|
+
/**
|
|
991
|
+
* Create a copy with all edges rounded up.
|
|
992
|
+
*/
|
|
825
993
|
ceilCopy(): Rect;
|
|
994
|
+
/**
|
|
995
|
+
* Expand this rectangle to include a point.
|
|
996
|
+
*/
|
|
826
997
|
expandCopy(px: number, py: number): Rect;
|
|
998
|
+
/**
|
|
999
|
+
* Test for exact equality with another rectangle.
|
|
1000
|
+
*/
|
|
827
1001
|
equals(other: Rect): boolean;
|
|
1002
|
+
/**
|
|
1003
|
+
* Create a deep copy of this rectangle.
|
|
1004
|
+
*/
|
|
828
1005
|
clone(): Rect;
|
|
829
|
-
|
|
1006
|
+
/**
|
|
1007
|
+
* Convert this rectangle to an AnchoredRect.
|
|
1008
|
+
* The anchor is placed at the geometric center.
|
|
1009
|
+
*/
|
|
830
1010
|
toAnchoredRect(): AnchoredRect;
|
|
1011
|
+
toString(): string;
|
|
831
1012
|
}
|
|
832
1013
|
|
|
833
1014
|
/**
|
|
834
|
-
*
|
|
1015
|
+
* Mutable axis-aligned rectangle with an explicit anchor point.
|
|
1016
|
+
*
|
|
1017
|
+
* The rectangle is defined by its edges (`left`, `top`, `right`, `bottom`)
|
|
1018
|
+
* and an independent anchor (`anchorX`, `anchorY`) that acts as a logical
|
|
1019
|
+
* pivot for scaling, sectioning, and layout operations.
|
|
1020
|
+
*
|
|
1021
|
+
* The anchor does not need to lie at the geometric center of the rectangle.
|
|
1022
|
+
*
|
|
1023
|
+
* All coordinates use the same coordinate space and orientation
|
|
1024
|
+
* (top ≤ bottom, left ≤ right).
|
|
835
1025
|
*/
|
|
836
1026
|
declare class AnchoredRect {
|
|
837
1027
|
left: number;
|
|
@@ -841,53 +1031,57 @@ declare class AnchoredRect {
|
|
|
841
1031
|
anchorY: number;
|
|
842
1032
|
bottom: number;
|
|
843
1033
|
/**
|
|
844
|
-
* Create rectangle
|
|
1034
|
+
* Create an empty rectangle at the origin.
|
|
1035
|
+
* All edges and anchor coordinates are set to zero.
|
|
845
1036
|
*/
|
|
846
1037
|
constructor();
|
|
847
1038
|
/**
|
|
848
|
-
* Create rectangle
|
|
849
|
-
*
|
|
1039
|
+
* Create a rectangle from `{ left, top, width, height }`.
|
|
1040
|
+
* The anchor is placed at the geometric center.
|
|
1041
|
+
*/
|
|
1042
|
+
constructor(other: {
|
|
1043
|
+
left: number;
|
|
1044
|
+
top: number;
|
|
1045
|
+
width: number;
|
|
1046
|
+
height: number;
|
|
1047
|
+
});
|
|
1048
|
+
/**
|
|
1049
|
+
* Create a deep copy of another AnchoredRect.
|
|
1050
|
+
*/
|
|
1051
|
+
constructor(other: AnchoredRect);
|
|
1052
|
+
/**
|
|
1053
|
+
* Create a rectangle from edge coordinates.
|
|
1054
|
+
* The anchor is placed at the geometric center.
|
|
850
1055
|
*
|
|
851
|
-
* @param left - Left
|
|
852
|
-
* @param right - Right
|
|
853
|
-
* @param top - Top
|
|
854
|
-
* @param bottom - Bottom
|
|
1056
|
+
* @param left - Left edge
|
|
1057
|
+
* @param right - Right edge
|
|
1058
|
+
* @param top - Top edge
|
|
1059
|
+
* @param bottom - Bottom edge
|
|
855
1060
|
*/
|
|
856
1061
|
constructor(left: number, right: number, top: number, bottom: number);
|
|
857
1062
|
/**
|
|
858
|
-
* Create rectangle with
|
|
1063
|
+
* Create a rectangle with explicit edge and anchor coordinates.
|
|
859
1064
|
*
|
|
860
|
-
* @param left - Left
|
|
861
|
-
* @param anchorX -
|
|
862
|
-
* @param right - Right
|
|
863
|
-
* @param top - Top
|
|
864
|
-
* @param anchorY -
|
|
865
|
-
* @param bottom - Bottom
|
|
1065
|
+
* @param left - Left edge
|
|
1066
|
+
* @param anchorX - Anchor x-coordinate
|
|
1067
|
+
* @param right - Right edge
|
|
1068
|
+
* @param top - Top edge
|
|
1069
|
+
* @param anchorY - Anchor y-coordinate
|
|
1070
|
+
* @param bottom - Bottom edge
|
|
866
1071
|
*/
|
|
867
1072
|
constructor(left: number, anchorX: number, right: number, top: number, anchorY: number, bottom: number);
|
|
868
1073
|
/**
|
|
869
|
-
*
|
|
1074
|
+
* Reset this rectangle to the origin.
|
|
1075
|
+
* All edges and anchor coordinates are set to zero.
|
|
870
1076
|
*/
|
|
871
1077
|
set(): AnchoredRect;
|
|
872
1078
|
/**
|
|
873
|
-
* Set rectangle
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
* @param left - Left coordinate.
|
|
877
|
-
* @param right - Right coordinate.
|
|
878
|
-
* @param top - Top coordinate.
|
|
879
|
-
* @param bottom - Bottom coordinate.
|
|
1079
|
+
* Set rectangle edges.
|
|
1080
|
+
* The anchor is repositioned to the geometric center.
|
|
880
1081
|
*/
|
|
881
1082
|
set(left: number, right: number, top: number, bottom: number): AnchoredRect;
|
|
882
1083
|
/**
|
|
883
|
-
* Set rectangle
|
|
884
|
-
*
|
|
885
|
-
* @param left - Left coordinate.
|
|
886
|
-
* @param anchorX - Center x-coordinate.
|
|
887
|
-
* @param right - Right coordinate.
|
|
888
|
-
* @param top - Top coordinate.
|
|
889
|
-
* @param anchorY - Center y-coordinate.
|
|
890
|
-
* @param bottom - Bottom coordinate.
|
|
1084
|
+
* Set rectangle edges and anchor explicitly.
|
|
891
1085
|
*/
|
|
892
1086
|
set(left: number, anchorX: number, right: number, top: number, anchorY: number, bottom: number): AnchoredRect;
|
|
893
1087
|
/**
|
|
@@ -920,130 +1114,126 @@ declare class AnchoredRect {
|
|
|
920
1114
|
* @returns - AnchoredRect.
|
|
921
1115
|
*/
|
|
922
1116
|
static createSections(leftw: number, rightw: number, toph: number, bottomh: number): AnchoredRect;
|
|
923
|
-
/**
|
|
924
|
-
* Get center x-coordinate.
|
|
925
|
-
*/
|
|
1117
|
+
/** Geometric center x-coordinate (ignores anchor). */
|
|
926
1118
|
get centerX(): number;
|
|
927
|
-
/**
|
|
928
|
-
* Get center ycoordinate.
|
|
929
|
-
*/
|
|
1119
|
+
/** Geometric center y-coordinate (ignores anchor). */
|
|
930
1120
|
get centerY(): number;
|
|
931
|
-
/**
|
|
932
|
-
* Width getter.
|
|
933
|
-
*/
|
|
1121
|
+
/** Rectangle width (`right - left`). */
|
|
934
1122
|
get width(): number;
|
|
935
|
-
/**
|
|
936
|
-
* Height getter.
|
|
937
|
-
*/
|
|
1123
|
+
/** Rectangle height (`bottom - top`). */
|
|
938
1124
|
get height(): number;
|
|
939
|
-
/**
|
|
940
|
-
* Left section width getter.
|
|
941
|
-
*/
|
|
1125
|
+
/** Distance from left edge to anchor. */
|
|
942
1126
|
get leftw(): number;
|
|
943
|
-
/**
|
|
944
|
-
* Right section width getter.
|
|
945
|
-
*/
|
|
1127
|
+
/** Distance from anchor to right edge. */
|
|
946
1128
|
get rightw(): number;
|
|
1129
|
+
/** Distance from top edge to anchor. */
|
|
1130
|
+
get toph(): number;
|
|
1131
|
+
/** Distance from anchor to bottom edge. */
|
|
1132
|
+
get bottomh(): number;
|
|
947
1133
|
/**
|
|
948
|
-
*
|
|
1134
|
+
* Test whether a point lies inside or on the edges of this rectangle.
|
|
949
1135
|
*/
|
|
950
|
-
|
|
1136
|
+
contains(x: number, y: number): boolean;
|
|
951
1137
|
/**
|
|
952
|
-
*
|
|
1138
|
+
* Create an inset (shrunken) copy of this rectangle.
|
|
1139
|
+
*
|
|
1140
|
+
* The rectangle edges are moved inward by the given amounts.
|
|
1141
|
+
* The anchor position is preserved.
|
|
1142
|
+
*
|
|
1143
|
+
* @param dx - Horizontal inset applied to left and right edges.
|
|
1144
|
+
* @param dy - Vertical inset applied to top and bottom edges.
|
|
1145
|
+
* Defaults to `dx`.
|
|
1146
|
+
* @returns A new AnchoredRect inset from all sides.
|
|
953
1147
|
*/
|
|
954
|
-
|
|
1148
|
+
insetCopy(dx: number, dy?: number): AnchoredRect;
|
|
955
1149
|
/**
|
|
956
|
-
*
|
|
1150
|
+
* Create an inflated (expanded) copy of this rectangle.
|
|
1151
|
+
*
|
|
1152
|
+
* The rectangle edges are moved outward by the given amounts.
|
|
1153
|
+
* The anchor position is preserved.
|
|
957
1154
|
*
|
|
958
|
-
* @param
|
|
959
|
-
* @param
|
|
960
|
-
*
|
|
1155
|
+
* @param dx - Horizontal expansion applied to left and right edges.
|
|
1156
|
+
* @param dy - Vertical expansion applied to top and bottom edges.
|
|
1157
|
+
* Defaults to `dx`.
|
|
1158
|
+
* @returns A new AnchoredRect expanded on all sides.
|
|
961
1159
|
*/
|
|
962
|
-
|
|
1160
|
+
inflateCopy(dx: number, dy?: number): AnchoredRect;
|
|
963
1161
|
/**
|
|
964
|
-
*
|
|
1162
|
+
* Test whether this rectangle intersects another rectangle.
|
|
965
1163
|
*
|
|
966
|
-
*
|
|
967
|
-
*
|
|
968
|
-
*
|
|
1164
|
+
* Edge-touching is considered an intersection.
|
|
1165
|
+
* Accepts either an AnchoredRect or a rect-like object
|
|
1166
|
+
* with `{ left, top, width, height }`.
|
|
1167
|
+
*/
|
|
1168
|
+
intersects(other: AnchoredRect): boolean;
|
|
1169
|
+
intersects(other: {
|
|
1170
|
+
left: number;
|
|
1171
|
+
top: number;
|
|
1172
|
+
width: number;
|
|
1173
|
+
height: number;
|
|
1174
|
+
}): boolean;
|
|
1175
|
+
/**
|
|
1176
|
+
* This method requires strict overlap (edge-touching does NOT count).
|
|
969
1177
|
*/
|
|
970
1178
|
static overlap(a: AnchoredRect, b: AnchoredRect): boolean;
|
|
971
1179
|
/**
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
* @param a - AnchoredRect a.
|
|
975
|
-
* @param b - AnchoredRect b.
|
|
976
|
-
* @returns - True/false.
|
|
1180
|
+
* This method requires strict (horizontal) overlap (edge-touching does NOT count).
|
|
977
1181
|
*/
|
|
978
1182
|
static overlapX(a: AnchoredRect, b: AnchoredRect): boolean;
|
|
979
1183
|
/**
|
|
980
|
-
*
|
|
981
|
-
* @param a - AnchoredRect a.
|
|
982
|
-
* @param b - AnchoredRect b.
|
|
983
|
-
* @returns - True/false.
|
|
1184
|
+
* Test if rects are equal.
|
|
984
1185
|
*/
|
|
985
1186
|
static equals(a: AnchoredRect | null | undefined, b: AnchoredRect | null | undefined): boolean;
|
|
986
1187
|
/**
|
|
987
|
-
*
|
|
988
|
-
* @param other - The other rect.
|
|
989
|
-
* @returns - True/false.
|
|
1188
|
+
* Test if this rect equals with given rect.
|
|
990
1189
|
*/
|
|
991
1190
|
equals(other: AnchoredRect): boolean;
|
|
992
1191
|
/**
|
|
993
|
-
*
|
|
994
|
-
*
|
|
995
|
-
* @param a - AnchoredRect a.
|
|
996
|
-
* @param b - AnchoredRect b.
|
|
997
|
-
* @returns - True/false.
|
|
1192
|
+
* Test if edges of given rects are equal, ignoring anchorX and anchorY.
|
|
998
1193
|
*/
|
|
999
1194
|
static equalsEdges(a: AnchoredRect | null | undefined, b: AnchoredRect | null | undefined): boolean;
|
|
1000
1195
|
/**
|
|
1001
|
-
*
|
|
1002
|
-
*
|
|
1003
|
-
* @param other - The other AnchoredRect.
|
|
1004
|
-
* @returns - True/false.
|
|
1196
|
+
* Test if edges of this equal with given Rect, ignoring anchorX and anchorY.
|
|
1005
1197
|
*/
|
|
1006
1198
|
equalsEdges(other: AnchoredRect): boolean;
|
|
1007
1199
|
/**
|
|
1008
|
-
*
|
|
1009
|
-
* @returns - Duplicate.
|
|
1200
|
+
* Create copy.
|
|
1010
1201
|
*/
|
|
1011
1202
|
clone(): AnchoredRect;
|
|
1012
1203
|
/**
|
|
1013
|
-
* Move this rect by (dx, dy).
|
|
1204
|
+
* Move this rect by (dx, dy).
|
|
1014
1205
|
*
|
|
1015
1206
|
* @param dx - Offset amount in x-direction.
|
|
1016
1207
|
* @param dy - Offset amount in y-direction.
|
|
1017
|
-
* @returns -
|
|
1208
|
+
* @returns - Modified this.
|
|
1018
1209
|
*/
|
|
1019
1210
|
offsetInPlace(dx: number, dy: number): AnchoredRect;
|
|
1020
1211
|
/**
|
|
1021
|
-
* Move this rect by (dx, dy).
|
|
1212
|
+
* Move this rect by (dx, dy).
|
|
1022
1213
|
*
|
|
1023
1214
|
* @param dx - Offset amount in x-direction.
|
|
1024
1215
|
* @param dy - Offset amount in y-direction.
|
|
1025
|
-
* @returns -
|
|
1216
|
+
* @returns - Copy with applied offset.
|
|
1026
1217
|
*/
|
|
1027
1218
|
offsetCopy(dx: number, dy: number): AnchoredRect;
|
|
1028
1219
|
/**
|
|
1029
|
-
* Expand this
|
|
1030
|
-
*
|
|
1031
|
-
* @param rect - AnchoredRect to expand this instance with.
|
|
1032
|
-
* @returns - This AnchoredRect instance.
|
|
1220
|
+
* Expand this rectangle to include another rectangle.
|
|
1221
|
+
* The anchor is preserved.
|
|
1033
1222
|
*/
|
|
1034
|
-
|
|
1223
|
+
unionInPlace(other: AnchoredRect): AnchoredRect;
|
|
1224
|
+
/** @deprecated - Use unionInPlace(). */
|
|
1225
|
+
expandInPlace(other: AnchoredRect): AnchoredRect;
|
|
1035
1226
|
/**
|
|
1036
|
-
*
|
|
1037
|
-
*
|
|
1038
|
-
* @
|
|
1039
|
-
* @returns - Expanded copy of this AnchoredRect.
|
|
1227
|
+
* Union this rect with given Rect.
|
|
1228
|
+
* @param other - Union with.
|
|
1229
|
+
* @returns - Modified copy.
|
|
1040
1230
|
*/
|
|
1041
|
-
|
|
1231
|
+
unionCopy(other: AnchoredRect): AnchoredRect;
|
|
1232
|
+
/** @deprecated - Use unionCopy(). */
|
|
1233
|
+
expandCopy(other: AnchoredRect): AnchoredRect;
|
|
1042
1234
|
/**
|
|
1043
|
-
* Clip this
|
|
1044
|
-
*
|
|
1045
|
-
* @param clipRect - AnchoredRect to clip this instance with.
|
|
1046
|
-
* @returns - This AnchoredRect instance.
|
|
1235
|
+
* Clip this rectangle to the bounds of another rectangle.
|
|
1236
|
+
* The anchor is clamped to remain inside the clipped region.
|
|
1047
1237
|
*/
|
|
1048
1238
|
clipInPlace(clipRect: AnchoredRect): AnchoredRect;
|
|
1049
1239
|
/**
|
|
@@ -1054,11 +1244,8 @@ declare class AnchoredRect {
|
|
|
1054
1244
|
*/
|
|
1055
1245
|
clipCopy(clipRect: AnchoredRect): AnchoredRect;
|
|
1056
1246
|
/**
|
|
1057
|
-
* Scale
|
|
1058
|
-
*
|
|
1059
|
-
* @param scaleX - Scale x-amount.
|
|
1060
|
-
* @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
|
|
1061
|
-
* @returns This AnchoredRect instance.
|
|
1247
|
+
* Scale this rectangle around its anchor point.
|
|
1248
|
+
* Edges are moved relative to the anchor.
|
|
1062
1249
|
*/
|
|
1063
1250
|
scaleInPlace(scaleX: number, scaleY?: number): AnchoredRect;
|
|
1064
1251
|
/**
|
|
@@ -1070,11 +1257,15 @@ declare class AnchoredRect {
|
|
|
1070
1257
|
*/
|
|
1071
1258
|
scaleCopy(scaleX: number, scaleY?: number): AnchoredRect;
|
|
1072
1259
|
/**
|
|
1073
|
-
*
|
|
1074
|
-
* @returns - This AnchoredRect instance.
|
|
1260
|
+
* Return this rect.
|
|
1075
1261
|
*/
|
|
1076
1262
|
getRect(): AnchoredRect;
|
|
1263
|
+
/**
|
|
1264
|
+
* Convert to a basic Rect using geometric edges.
|
|
1265
|
+
* Anchor information is discarded.
|
|
1266
|
+
*/
|
|
1077
1267
|
toRect(): Rect;
|
|
1268
|
+
/** String of this rect. */
|
|
1078
1269
|
toString(): string;
|
|
1079
1270
|
}
|
|
1080
1271
|
|