ice-render 1.0.4 → 1.0.6
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/LICENSE +0 -0
- package/README.md +229 -141
- package/dist/THIRD-PARTY-NOTICES.txt +32 -0
- package/dist/index.cjs +30 -0
- package/dist/index.mjs +30 -0
- package/dist/index.umd.js +6 -1
- package/dist/types/FrameManager.d.mts +26 -0
- package/dist/types/FrameManager.d.ts +26 -26
- package/dist/types/ICE.d.mts +369 -0
- package/dist/types/ICE.d.ts +369 -107
- package/dist/types/a11y/accessibility.d.mts +46 -0
- package/dist/types/a11y/accessibility.d.ts +46 -0
- package/dist/types/animation/AnimationManager.d.mts +96 -0
- package/dist/types/animation/AnimationManager.d.ts +96 -25
- package/dist/types/animation/Easing.d.mts +33 -0
- package/dist/types/animation/Easing.d.ts +33 -32
- package/dist/types/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
- package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -14
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -36
- package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
- package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -19
- package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
- package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -20
- package/dist/types/control-panel/AlignmentGuideManager.d.mts +92 -0
- package/dist/types/control-panel/AlignmentGuideManager.d.ts +92 -0
- package/dist/types/control-panel/ICEControlPanel.d.mts +37 -0
- package/dist/types/control-panel/ICEControlPanel.d.ts +37 -37
- package/dist/types/control-panel/ICEControlPanelManager.d.mts +25 -0
- package/dist/types/control-panel/ICEControlPanelManager.d.ts +25 -23
- package/dist/types/control-panel/link-controls/LineControlPanel.d.mts +39 -0
- package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -39
- package/dist/types/control-panel/transform-controls/ResizeControl.d.mts +38 -0
- package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +38 -38
- package/dist/types/control-panel/transform-controls/RotateControl.d.mts +12 -0
- package/dist/types/control-panel/transform-controls/RotateControl.d.ts +12 -12
- package/dist/types/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
- package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +83 -74
- package/dist/types/control-panel/transform-controls/constraints.d.mts +24 -0
- package/dist/types/control-panel/transform-controls/constraints.d.ts +24 -0
- package/dist/types/cross-platform/PolyfillPath2D.d.mts +31 -0
- package/dist/types/cross-platform/PolyfillPath2D.d.ts +31 -0
- package/dist/types/cross-platform/root.d.mts +7 -0
- package/dist/types/cross-platform/root.d.ts +7 -2
- package/dist/types/event/DOMEventDispatcher.d.mts +68 -0
- package/dist/types/event/DOMEventDispatcher.d.ts +68 -29
- package/dist/types/event/DOMEventInterceptor.d.mts +36 -0
- package/dist/types/event/DOMEventInterceptor.d.ts +36 -7
- package/dist/types/event/EventBus.d.mts +27 -0
- package/dist/types/event/EventBus.d.ts +27 -27
- package/dist/types/event/ICEEvent.d.mts +46 -0
- package/dist/types/event/ICEEvent.d.ts +46 -46
- package/dist/types/event/ICEEventTarget.d.mts +106 -0
- package/dist/types/event/ICEEventTarget.d.ts +106 -106
- package/dist/types/event/input-normalize.d.mts +75 -0
- package/dist/types/event/input-normalize.d.ts +75 -0
- package/dist/types/geometry/GeoLine.d.mts +24 -0
- package/dist/types/geometry/GeoLine.d.ts +24 -23
- package/dist/types/geometry/GeoPoint.d.mts +53 -0
- package/dist/types/geometry/GeoPoint.d.ts +53 -66
- package/dist/types/geometry/GeoUtil.d.mts +73 -0
- package/dist/types/geometry/GeoUtil.d.ts +73 -37
- package/dist/types/geometry/ICEBoundingBox.d.mts +81 -0
- package/dist/types/geometry/ICEBoundingBox.d.ts +81 -81
- package/dist/types/graphic/ICEComponent.d.mts +436 -0
- package/dist/types/graphic/ICEComponent.d.ts +436 -264
- package/dist/types/graphic/ICEDotPath.d.mts +99 -0
- package/dist/types/graphic/ICEDotPath.d.ts +99 -63
- package/dist/types/graphic/ICEImage.d.mts +17 -0
- package/dist/types/graphic/ICEImage.d.ts +17 -17
- package/dist/types/graphic/ICEPath.d.mts +39 -0
- package/dist/types/graphic/ICEPath.d.ts +39 -36
- package/dist/types/graphic/container/ICEGroup.d.mts +101 -0
- package/dist/types/graphic/container/ICEGroup.d.ts +101 -53
- package/dist/types/graphic/link/ICEBezier.d.mts +23 -0
- package/dist/types/graphic/link/ICEBezier.d.ts +23 -15
- package/dist/types/graphic/link/ICELinkHook.d.mts +52 -0
- package/dist/types/graphic/link/ICELinkHook.d.ts +52 -52
- package/dist/types/graphic/link/ICELinkSlot.d.mts +54 -0
- package/dist/types/graphic/link/ICELinkSlot.d.ts +54 -46
- package/dist/types/graphic/link/ICELinkSlotManager.d.mts +28 -0
- package/dist/types/graphic/link/ICELinkSlotManager.d.ts +28 -28
- package/dist/types/graphic/link/ICEPolyLine.d.mts +292 -0
- package/dist/types/graphic/link/ICEPolyLine.d.ts +292 -219
- package/dist/types/graphic/link/ICEVisioLink.d.mts +163 -0
- package/dist/types/graphic/link/ICEVisioLink.d.ts +163 -129
- package/dist/types/graphic/shape/ICECircle.d.mts +19 -0
- package/dist/types/graphic/shape/ICECircle.d.ts +19 -19
- package/dist/types/graphic/shape/ICEEllipse.d.mts +29 -0
- package/dist/types/graphic/shape/ICEEllipse.d.ts +29 -23
- package/dist/types/graphic/shape/ICEIsogon.d.mts +52 -0
- package/dist/types/graphic/shape/ICEIsogon.d.ts +52 -52
- package/dist/types/graphic/shape/ICERect.d.mts +10 -0
- package/dist/types/graphic/shape/ICERect.d.ts +10 -17
- package/dist/types/graphic/shape/ICERose.d.mts +41 -0
- package/dist/types/graphic/shape/ICERose.d.ts +41 -41
- package/dist/types/graphic/shape/ICEStar.d.mts +45 -0
- package/dist/types/graphic/shape/ICEStar.d.ts +45 -45
- package/dist/types/graphic/text/ICEText.d.mts +137 -0
- package/dist/types/graphic/text/ICEText.d.ts +137 -65
- package/dist/types/index.d.mts +55 -0
- package/dist/types/index.d.ts +55 -41
- package/dist/types/layout/ICEBorderLayout.d.mts +34 -0
- package/dist/types/layout/ICEBorderLayout.d.ts +34 -0
- package/dist/types/layout/ICEBoxLayout.d.mts +30 -0
- package/dist/types/layout/ICEBoxLayout.d.ts +30 -0
- package/dist/types/layout/ICECardLayout.d.mts +36 -0
- package/dist/types/layout/ICECardLayout.d.ts +36 -0
- package/dist/types/layout/ICEFlowLayout.d.mts +31 -0
- package/dist/types/layout/ICEFlowLayout.d.ts +31 -0
- package/dist/types/layout/ICEGridLayout.d.mts +33 -0
- package/dist/types/layout/ICEGridLayout.d.ts +33 -0
- package/dist/types/layout/ICELayeredLayout.d.mts +49 -0
- package/dist/types/layout/ICELayeredLayout.d.ts +49 -0
- package/dist/types/layout/ICELayoutManager.d.mts +33 -0
- package/dist/types/layout/ICELayoutManager.d.ts +33 -0
- package/dist/types/layout/ICEOverlayLayout.d.mts +25 -0
- package/dist/types/layout/ICEOverlayLayout.d.ts +25 -0
- package/dist/types/persistence/Deserializer.d.mts +43 -0
- package/dist/types/persistence/Deserializer.d.ts +43 -14
- package/dist/types/persistence/Serializer.d.mts +35 -0
- package/dist/types/persistence/Serializer.d.ts +35 -26
- package/dist/types/plugin/PluginHost.d.mts +86 -0
- package/dist/types/plugin/PluginHost.d.ts +86 -0
- package/dist/types/renderer/CanvasRenderer.d.mts +150 -0
- package/dist/types/renderer/CanvasRenderer.d.ts +150 -22
- package/dist/types/renderer/ObjectCache.d.mts +79 -0
- package/dist/types/renderer/ObjectCache.d.ts +79 -0
- package/dist/types/renderer/dirty-rect-util.d.mts +86 -0
- package/dist/types/renderer/dirty-rect-util.d.ts +86 -0
- package/dist/types/theme/ICETheme.d.mts +382 -0
- package/dist/types/theme/ICETheme.d.ts +382 -0
- package/dist/types/util/ImageCache.d.mts +19 -0
- package/dist/types/util/ImageCache.d.ts +19 -19
- package/dist/types/util/data-util.d.mts +43 -0
- package/dist/types/util/data-util.d.ts +43 -19
- package/dist/types/util/gl-matrix-skew.d.mts +14 -0
- package/dist/types/util/gl-matrix-skew.d.ts +14 -14
- package/dist/types/util/lang.d.mts +28 -0
- package/dist/types/util/lang.d.ts +28 -0
- package/dist/types/util/uuid.d.mts +1 -0
- package/dist/types/util/uuid.d.ts +1 -1
- package/package.json +118 -81
- package/dist/index.cjs.js +0 -25
- package/dist/index.js +0 -25
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import GeoPoint from './GeoPoint.mjs';
|
|
9
|
+
/**
|
|
10
|
+
* @class GeoLine
|
|
11
|
+
* A geometrically line, invisible, no dimension, just used for mathematical operations.
|
|
12
|
+
* This implementation is improved from http://diagramo.com/ .
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* 几何学意义上的直线,它不可见,没有宽度,用来进行数学运算。此实现从 diagramo 改进而来:http://diagramo.com/ 。
|
|
16
|
+
*
|
|
17
|
+
* @docauthor 大漠穷秋 <damoqiongqiu@126.com>
|
|
18
|
+
*/
|
|
19
|
+
export default class GeoLine {
|
|
20
|
+
startPoint: GeoPoint;
|
|
21
|
+
endPoint: GeoPoint;
|
|
22
|
+
constructor(startPoint: GeoPoint, endPoint: GeoPoint);
|
|
23
|
+
contains(x: number, y: number): boolean;
|
|
24
|
+
}
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
startPoint:
|
|
21
|
-
endPoint:
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
import GeoPoint from './GeoPoint';
|
|
9
|
+
/**
|
|
10
|
+
* @class GeoLine
|
|
11
|
+
* A geometrically line, invisible, no dimension, just used for mathematical operations.
|
|
12
|
+
* This implementation is improved from http://diagramo.com/ .
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* 几何学意义上的直线,它不可见,没有宽度,用来进行数学运算。此实现从 diagramo 改进而来:http://diagramo.com/ 。
|
|
16
|
+
*
|
|
17
|
+
* @docauthor 大漠穷秋 <damoqiongqiu@126.com>
|
|
18
|
+
*/
|
|
19
|
+
export default class GeoLine {
|
|
20
|
+
startPoint: GeoPoint;
|
|
21
|
+
endPoint: GeoPoint;
|
|
22
|
+
constructor(startPoint: GeoPoint, endPoint: GeoPoint);
|
|
23
|
+
contains(x: number, y: number): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @class GeoPoint
|
|
10
|
+
* A geometrically point, invisible, no dimension, just used for mathematical operations.
|
|
11
|
+
* This implementation is improved from http://diagramo.com/ .
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* 几何学意义上的点,它不可见,没有大小,用来进行数学运算。此实现从 diagramo 改进而来:http://diagramo.com/ 。
|
|
15
|
+
*
|
|
16
|
+
* @docauthor 大漠穷秋 <damoqiongqiu@126.com>
|
|
17
|
+
*/
|
|
18
|
+
export default class GeoPoint {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
/**
|
|
22
|
+
* @constructor GeoPoint
|
|
23
|
+
*/
|
|
24
|
+
constructor(x?: number, y?: number);
|
|
25
|
+
/**
|
|
26
|
+
* @method load
|
|
27
|
+
* Creates a {GeoPoint} out of JSON parsed object.
|
|
28
|
+
*
|
|
29
|
+
* 从 JSON 对象创建 {GeoPoint} 实例。
|
|
30
|
+
*/
|
|
31
|
+
static load(o: any): GeoPoint;
|
|
32
|
+
/**
|
|
33
|
+
* @method cloneArray
|
|
34
|
+
* Clones an array of points.
|
|
35
|
+
*
|
|
36
|
+
* 克隆一组点。
|
|
37
|
+
*/
|
|
38
|
+
static cloneArray(v: GeoPoint[]): GeoPoint[];
|
|
39
|
+
/**
|
|
40
|
+
* @method equals
|
|
41
|
+
* Tests if this point is equals to other point.
|
|
42
|
+
*
|
|
43
|
+
* 测试当前点是否与另一个点相等。
|
|
44
|
+
*/
|
|
45
|
+
equals(anotherPoint: GeoPoint): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* @method clone
|
|
48
|
+
* Clone current GeoPoint.
|
|
49
|
+
*
|
|
50
|
+
* 克隆当前点。
|
|
51
|
+
*/
|
|
52
|
+
clone(): GeoPoint;
|
|
53
|
+
}
|
|
@@ -1,66 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* @class GeoPoint
|
|
10
|
-
* A geometrically point, invisible, no dimension, just used for mathematical operations.
|
|
11
|
-
* This implementation is improved from http://diagramo.com/ .
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* 几何学意义上的点,它不可见,没有大小,用来进行数学运算。此实现从 diagramo 改进而来:http://diagramo.com/ 。
|
|
15
|
-
*
|
|
16
|
-
* @docauthor 大漠穷秋 <damoqiongqiu@126.com>
|
|
17
|
-
*/
|
|
18
|
-
export default class GeoPoint {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* 克隆一组点。
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
*
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* 测试当前点是否与另一个点相等。
|
|
55
|
-
* @param {GeoPoint} anotherPoint - the other point
|
|
56
|
-
*/
|
|
57
|
-
equals(anotherPoint: GeoPoint): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* @method clone
|
|
60
|
-
* Clone current GeoPoint.
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* 克隆当前点。
|
|
64
|
-
*/
|
|
65
|
-
clone(): GeoPoint;
|
|
66
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @class GeoPoint
|
|
10
|
+
* A geometrically point, invisible, no dimension, just used for mathematical operations.
|
|
11
|
+
* This implementation is improved from http://diagramo.com/ .
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* 几何学意义上的点,它不可见,没有大小,用来进行数学运算。此实现从 diagramo 改进而来:http://diagramo.com/ 。
|
|
15
|
+
*
|
|
16
|
+
* @docauthor 大漠穷秋 <damoqiongqiu@126.com>
|
|
17
|
+
*/
|
|
18
|
+
export default class GeoPoint {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
/**
|
|
22
|
+
* @constructor GeoPoint
|
|
23
|
+
*/
|
|
24
|
+
constructor(x?: number, y?: number);
|
|
25
|
+
/**
|
|
26
|
+
* @method load
|
|
27
|
+
* Creates a {GeoPoint} out of JSON parsed object.
|
|
28
|
+
*
|
|
29
|
+
* 从 JSON 对象创建 {GeoPoint} 实例。
|
|
30
|
+
*/
|
|
31
|
+
static load(o: any): GeoPoint;
|
|
32
|
+
/**
|
|
33
|
+
* @method cloneArray
|
|
34
|
+
* Clones an array of points.
|
|
35
|
+
*
|
|
36
|
+
* 克隆一组点。
|
|
37
|
+
*/
|
|
38
|
+
static cloneArray(v: GeoPoint[]): GeoPoint[];
|
|
39
|
+
/**
|
|
40
|
+
* @method equals
|
|
41
|
+
* Tests if this point is equals to other point.
|
|
42
|
+
*
|
|
43
|
+
* 测试当前点是否与另一个点相等。
|
|
44
|
+
*/
|
|
45
|
+
equals(anotherPoint: GeoPoint): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* @method clone
|
|
48
|
+
* Clone current GeoPoint.
|
|
49
|
+
*
|
|
50
|
+
* 克隆当前点。
|
|
51
|
+
*/
|
|
52
|
+
clone(): GeoPoint;
|
|
53
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default class GeoUtil {
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* 点是否在多边形内部(射线法)。
|
|
12
|
+
*
|
|
13
|
+
* 点集类图元(星形 / 正N边形 / 玫瑰)的精确命中判定用的就是它;上提为公共 API 后,
|
|
14
|
+
* 应用层做自己的命中/碰撞判定时不必再抄一遍。
|
|
15
|
+
*
|
|
16
|
+
* 边界约定:不做特殊判定,按射线法自身的**半开**约定处理 —— 落在边/顶点上的点结果取决于
|
|
17
|
+
* 该边与射线的相对方向(例如正方形左下角顶点会判为「在内」)。需要「边界算命中」的语义时,
|
|
18
|
+
* 调用方应另外用 `distanceToPolyline` 判一次距离。
|
|
19
|
+
*
|
|
20
|
+
* @param x 待判定点的 x(与 polygon 同一坐标系)
|
|
21
|
+
* @param y 待判定点的 y
|
|
22
|
+
* @param polygon 顶点数组 [[x,y], ...],按顺序首尾相连(自动闭合,无需重复首点)
|
|
23
|
+
*/
|
|
24
|
+
static pointInPolygon(x: number, y: number, polygon: Array<[number, number]>): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 点到**线段**的最短距离(注意不是到直线的距离:投影落在端点外时取端点距离)。
|
|
27
|
+
*/
|
|
28
|
+
static distanceToSegment(px: number, py: number, ax: number, ay: number, bx: number, by: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* 点到折线(多段线)的最短距离。
|
|
31
|
+
* 折线类图元的命中判定就是「距离 ≤ 阈值」,此前这段逻辑内联在图元里。
|
|
32
|
+
*/
|
|
33
|
+
static distanceToPolyline(points: Array<[number, number]>, px: number, py: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* 沿折线等距采样 `count + 1` 个点(含首尾)。
|
|
36
|
+
*
|
|
37
|
+
* 用途:把曲线/折线离散成均匀点集(例如贝塞尔采样后写回 `state.points` 供包围盒与命中使用),
|
|
38
|
+
* 或者做路径动画的关键点。零长度段会被跳过,不会产生 NaN。
|
|
39
|
+
*/
|
|
40
|
+
static samplePolyline(points: Array<[number, number]>, count: number): Array<[number, number]>;
|
|
41
|
+
/**
|
|
42
|
+
* 两条线段是否相交(含相触)。返回交点或 null。
|
|
43
|
+
* 用参数方程求解,平行/共线时返回 null(不做重叠区间的特殊处理)。
|
|
44
|
+
*/
|
|
45
|
+
static segmentIntersect(a1: [number, number], a2: [number, number], b1: [number, number], b2: [number, number]): [number, number] | null;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* 已知向量原点和向量坐标值,求向量相对于 X 轴正向的旋转角度。
|
|
49
|
+
*
|
|
50
|
+
* 两个点需要处于同一个坐标系中。
|
|
51
|
+
*
|
|
52
|
+
* rotateAngle 的数值范围限定在 [0,360] 度之间,闭区间。
|
|
53
|
+
*
|
|
54
|
+
* @param x
|
|
55
|
+
* @param y
|
|
56
|
+
* @param originX
|
|
57
|
+
* @param originY
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
static calcRotateAngle(x: any, y: any, originX: any, originY: any): number;
|
|
61
|
+
/**
|
|
62
|
+
* 从变换矩阵计算旋转角度。
|
|
63
|
+
* @param matrix
|
|
64
|
+
* @returns 角度
|
|
65
|
+
*/
|
|
66
|
+
static calcRotateAngleFromMatrix(matrix: any): number;
|
|
67
|
+
/**
|
|
68
|
+
* 从变换矩阵计算缩放参数。
|
|
69
|
+
* @param matrix
|
|
70
|
+
* @returns 缩放数组
|
|
71
|
+
*/
|
|
72
|
+
static calcScaleFromMatrix(matrix: any): Array<number>;
|
|
73
|
+
}
|
|
@@ -1,37 +1,73 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE file in the root directory of this source tree.
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
export default class GeoUtil {
|
|
9
|
-
constructor();
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @
|
|
23
|
-
*/
|
|
24
|
-
static
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default class GeoUtil {
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* 点是否在多边形内部(射线法)。
|
|
12
|
+
*
|
|
13
|
+
* 点集类图元(星形 / 正N边形 / 玫瑰)的精确命中判定用的就是它;上提为公共 API 后,
|
|
14
|
+
* 应用层做自己的命中/碰撞判定时不必再抄一遍。
|
|
15
|
+
*
|
|
16
|
+
* 边界约定:不做特殊判定,按射线法自身的**半开**约定处理 —— 落在边/顶点上的点结果取决于
|
|
17
|
+
* 该边与射线的相对方向(例如正方形左下角顶点会判为「在内」)。需要「边界算命中」的语义时,
|
|
18
|
+
* 调用方应另外用 `distanceToPolyline` 判一次距离。
|
|
19
|
+
*
|
|
20
|
+
* @param x 待判定点的 x(与 polygon 同一坐标系)
|
|
21
|
+
* @param y 待判定点的 y
|
|
22
|
+
* @param polygon 顶点数组 [[x,y], ...],按顺序首尾相连(自动闭合,无需重复首点)
|
|
23
|
+
*/
|
|
24
|
+
static pointInPolygon(x: number, y: number, polygon: Array<[number, number]>): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 点到**线段**的最短距离(注意不是到直线的距离:投影落在端点外时取端点距离)。
|
|
27
|
+
*/
|
|
28
|
+
static distanceToSegment(px: number, py: number, ax: number, ay: number, bx: number, by: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* 点到折线(多段线)的最短距离。
|
|
31
|
+
* 折线类图元的命中判定就是「距离 ≤ 阈值」,此前这段逻辑内联在图元里。
|
|
32
|
+
*/
|
|
33
|
+
static distanceToPolyline(points: Array<[number, number]>, px: number, py: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* 沿折线等距采样 `count + 1` 个点(含首尾)。
|
|
36
|
+
*
|
|
37
|
+
* 用途:把曲线/折线离散成均匀点集(例如贝塞尔采样后写回 `state.points` 供包围盒与命中使用),
|
|
38
|
+
* 或者做路径动画的关键点。零长度段会被跳过,不会产生 NaN。
|
|
39
|
+
*/
|
|
40
|
+
static samplePolyline(points: Array<[number, number]>, count: number): Array<[number, number]>;
|
|
41
|
+
/**
|
|
42
|
+
* 两条线段是否相交(含相触)。返回交点或 null。
|
|
43
|
+
* 用参数方程求解,平行/共线时返回 null(不做重叠区间的特殊处理)。
|
|
44
|
+
*/
|
|
45
|
+
static segmentIntersect(a1: [number, number], a2: [number, number], b1: [number, number], b2: [number, number]): [number, number] | null;
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* 已知向量原点和向量坐标值,求向量相对于 X 轴正向的旋转角度。
|
|
49
|
+
*
|
|
50
|
+
* 两个点需要处于同一个坐标系中。
|
|
51
|
+
*
|
|
52
|
+
* rotateAngle 的数值范围限定在 [0,360] 度之间,闭区间。
|
|
53
|
+
*
|
|
54
|
+
* @param x
|
|
55
|
+
* @param y
|
|
56
|
+
* @param originX
|
|
57
|
+
* @param originY
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
static calcRotateAngle(x: any, y: any, originX: any, originY: any): number;
|
|
61
|
+
/**
|
|
62
|
+
* 从变换矩阵计算旋转角度。
|
|
63
|
+
* @param matrix
|
|
64
|
+
* @returns 角度
|
|
65
|
+
*/
|
|
66
|
+
static calcRotateAngleFromMatrix(matrix: any): number;
|
|
67
|
+
/**
|
|
68
|
+
* 从变换矩阵计算缩放参数。
|
|
69
|
+
* @param matrix
|
|
70
|
+
* @returns 缩放数组
|
|
71
|
+
*/
|
|
72
|
+
static calcScaleFromMatrix(matrix: any): Array<number>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class ICEBoundingBox 用4点法描述的边界盒子。
|
|
3
|
+
*
|
|
4
|
+
* - 边界盒子一定是矩形。
|
|
5
|
+
* - 边界盒子总是绘制在全局坐标系中。
|
|
6
|
+
* - 边界盒子总是通过自身的坐标点进行变换,而不是变换 canvas.ctx 。
|
|
7
|
+
* - 边界盒子总是通过组件的参数计算出来的,直接修改边界盒子不影响组件本身的参数。
|
|
8
|
+
*
|
|
9
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
10
|
+
*/
|
|
11
|
+
declare class ICEBoundingBox {
|
|
12
|
+
tl: number[];
|
|
13
|
+
tr: number[];
|
|
14
|
+
bl: number[];
|
|
15
|
+
br: number[];
|
|
16
|
+
tc: number[];
|
|
17
|
+
rc: number[];
|
|
18
|
+
bc: number[];
|
|
19
|
+
lc: number[];
|
|
20
|
+
center: number[];
|
|
21
|
+
constructor(props?: Array<number>);
|
|
22
|
+
/**
|
|
23
|
+
* 从指定的 top/left/width/height 构建 ICEBoundingBox。
|
|
24
|
+
* @param left
|
|
25
|
+
* @param top
|
|
26
|
+
* @param width
|
|
27
|
+
* @param height
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
static fromDimension(left: any, top: any, width: any, height: any): ICEBoundingBox;
|
|
31
|
+
/**
|
|
32
|
+
* 判断指定的坐标点是否位于边界矩形内部,向右水平射线法。
|
|
33
|
+
* 这里参考了 fabricjs 的实现方式。
|
|
34
|
+
* @see http://fabricjs.com/
|
|
35
|
+
* @param point
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
containsPoint(point: any): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 获取边界盒子的边所构成的线段,由于边界盒子总是被定义成 4 边形,这里直接简化处理。
|
|
41
|
+
*/
|
|
42
|
+
private getBoundingLines;
|
|
43
|
+
/**
|
|
44
|
+
* 获取边界盒子 x,y 的最大和最小值
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
getMinAndMaxPoint(): any;
|
|
48
|
+
/**
|
|
49
|
+
* 另一个边界盒子是否完全位于当前盒子内部(按轴对齐包围盒判定)。
|
|
50
|
+
* @param box
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
containsBox(box: ICEBoundingBox): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 是否与另一个盒子存在相交的部分。
|
|
56
|
+
* @param box
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
isIntersect(box: ICEBoundingBox): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @param matrix
|
|
62
|
+
* @returns A new ICEBoundingBox instance.
|
|
63
|
+
*/
|
|
64
|
+
transform(matrix: any): ICEBoundingBox;
|
|
65
|
+
/**
|
|
66
|
+
* 计算两个盒子(按轴对齐包围盒)的并集,返回一个新的 ICEBoundingBox 实例。
|
|
67
|
+
* @param box
|
|
68
|
+
* @returns A new ICEBoundingBox instance.
|
|
69
|
+
*/
|
|
70
|
+
union(box: ICEBoundingBox): ICEBoundingBox;
|
|
71
|
+
get width(): number;
|
|
72
|
+
get height(): number;
|
|
73
|
+
get left(): number;
|
|
74
|
+
private set left(value);
|
|
75
|
+
get top(): number;
|
|
76
|
+
private set top(value);
|
|
77
|
+
get centerX(): number;
|
|
78
|
+
get centerY(): number;
|
|
79
|
+
get centerPoint(): number[];
|
|
80
|
+
}
|
|
81
|
+
export default ICEBoundingBox;
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @class ICEBoundingBox 用4点法描述的边界盒子。
|
|
3
|
-
*
|
|
4
|
-
* - 边界盒子一定是矩形。
|
|
5
|
-
* - 边界盒子总是绘制在全局坐标系中。
|
|
6
|
-
* - 边界盒子总是通过自身的坐标点进行变换,而不是变换 canvas.ctx 。
|
|
7
|
-
* - 边界盒子总是通过组件的参数计算出来的,直接修改边界盒子不影响组件本身的参数。
|
|
8
|
-
*
|
|
9
|
-
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
10
|
-
*/
|
|
11
|
-
declare class ICEBoundingBox {
|
|
12
|
-
tl: number[];
|
|
13
|
-
tr: number[];
|
|
14
|
-
bl: number[];
|
|
15
|
-
br: number[];
|
|
16
|
-
tc: number[];
|
|
17
|
-
rc: number[];
|
|
18
|
-
bc: number[];
|
|
19
|
-
lc: number[];
|
|
20
|
-
center: number[];
|
|
21
|
-
constructor(props?: Array<number>);
|
|
22
|
-
/**
|
|
23
|
-
* 从指定的 top/left/width/height 构建 ICEBoundingBox。
|
|
24
|
-
* @param left
|
|
25
|
-
* @param top
|
|
26
|
-
* @param width
|
|
27
|
-
* @param height
|
|
28
|
-
* @returns
|
|
29
|
-
*/
|
|
30
|
-
static fromDimension(left: any, top: any, width: any, height: any): ICEBoundingBox;
|
|
31
|
-
/**
|
|
32
|
-
* 判断指定的坐标点是否位于边界矩形内部,向右水平射线法。
|
|
33
|
-
* 这里参考了 fabricjs 的实现方式。
|
|
34
|
-
* @see http://fabricjs.com/
|
|
35
|
-
* @param point
|
|
36
|
-
* @returns
|
|
37
|
-
*/
|
|
38
|
-
containsPoint(point: any): boolean;
|
|
39
|
-
/**
|
|
40
|
-
* 获取边界盒子的边所构成的线段,由于边界盒子总是被定义成 4 边形,这里直接简化处理。
|
|
41
|
-
*/
|
|
42
|
-
private getBoundingLines;
|
|
43
|
-
/**
|
|
44
|
-
* 获取边界盒子 x,y 的最大和最小值
|
|
45
|
-
* @returns
|
|
46
|
-
*/
|
|
47
|
-
getMinAndMaxPoint(): any;
|
|
48
|
-
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
*
|
|
57
|
-
* @
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* @
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
* @param box
|
|
68
|
-
* @returns A new ICEBoundingBox instance.
|
|
69
|
-
*/
|
|
70
|
-
union(box: ICEBoundingBox): ICEBoundingBox;
|
|
71
|
-
get width(): number;
|
|
72
|
-
get height(): number;
|
|
73
|
-
get left(): number;
|
|
74
|
-
private set left(value);
|
|
75
|
-
get top(): number;
|
|
76
|
-
private set top(value);
|
|
77
|
-
get centerX(): number;
|
|
78
|
-
get centerY(): number;
|
|
79
|
-
get centerPoint(): number[];
|
|
80
|
-
}
|
|
81
|
-
export default ICEBoundingBox;
|
|
1
|
+
/**
|
|
2
|
+
* @class ICEBoundingBox 用4点法描述的边界盒子。
|
|
3
|
+
*
|
|
4
|
+
* - 边界盒子一定是矩形。
|
|
5
|
+
* - 边界盒子总是绘制在全局坐标系中。
|
|
6
|
+
* - 边界盒子总是通过自身的坐标点进行变换,而不是变换 canvas.ctx 。
|
|
7
|
+
* - 边界盒子总是通过组件的参数计算出来的,直接修改边界盒子不影响组件本身的参数。
|
|
8
|
+
*
|
|
9
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
10
|
+
*/
|
|
11
|
+
declare class ICEBoundingBox {
|
|
12
|
+
tl: number[];
|
|
13
|
+
tr: number[];
|
|
14
|
+
bl: number[];
|
|
15
|
+
br: number[];
|
|
16
|
+
tc: number[];
|
|
17
|
+
rc: number[];
|
|
18
|
+
bc: number[];
|
|
19
|
+
lc: number[];
|
|
20
|
+
center: number[];
|
|
21
|
+
constructor(props?: Array<number>);
|
|
22
|
+
/**
|
|
23
|
+
* 从指定的 top/left/width/height 构建 ICEBoundingBox。
|
|
24
|
+
* @param left
|
|
25
|
+
* @param top
|
|
26
|
+
* @param width
|
|
27
|
+
* @param height
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
static fromDimension(left: any, top: any, width: any, height: any): ICEBoundingBox;
|
|
31
|
+
/**
|
|
32
|
+
* 判断指定的坐标点是否位于边界矩形内部,向右水平射线法。
|
|
33
|
+
* 这里参考了 fabricjs 的实现方式。
|
|
34
|
+
* @see http://fabricjs.com/
|
|
35
|
+
* @param point
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
containsPoint(point: any): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 获取边界盒子的边所构成的线段,由于边界盒子总是被定义成 4 边形,这里直接简化处理。
|
|
41
|
+
*/
|
|
42
|
+
private getBoundingLines;
|
|
43
|
+
/**
|
|
44
|
+
* 获取边界盒子 x,y 的最大和最小值
|
|
45
|
+
* @returns
|
|
46
|
+
*/
|
|
47
|
+
getMinAndMaxPoint(): any;
|
|
48
|
+
/**
|
|
49
|
+
* 另一个边界盒子是否完全位于当前盒子内部(按轴对齐包围盒判定)。
|
|
50
|
+
* @param box
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
containsBox(box: ICEBoundingBox): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* 是否与另一个盒子存在相交的部分。
|
|
56
|
+
* @param box
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
isIntersect(box: ICEBoundingBox): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* @param matrix
|
|
62
|
+
* @returns A new ICEBoundingBox instance.
|
|
63
|
+
*/
|
|
64
|
+
transform(matrix: any): ICEBoundingBox;
|
|
65
|
+
/**
|
|
66
|
+
* 计算两个盒子(按轴对齐包围盒)的并集,返回一个新的 ICEBoundingBox 实例。
|
|
67
|
+
* @param box
|
|
68
|
+
* @returns A new ICEBoundingBox instance.
|
|
69
|
+
*/
|
|
70
|
+
union(box: ICEBoundingBox): ICEBoundingBox;
|
|
71
|
+
get width(): number;
|
|
72
|
+
get height(): number;
|
|
73
|
+
get left(): number;
|
|
74
|
+
private set left(value);
|
|
75
|
+
get top(): number;
|
|
76
|
+
private set top(value);
|
|
77
|
+
get centerX(): number;
|
|
78
|
+
get centerY(): number;
|
|
79
|
+
get centerPoint(): number[];
|
|
80
|
+
}
|
|
81
|
+
export default ICEBoundingBox;
|