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.
Files changed (145) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +229 -141
  3. package/dist/THIRD-PARTY-NOTICES.txt +32 -0
  4. package/dist/index.cjs +30 -0
  5. package/dist/index.mjs +30 -0
  6. package/dist/index.umd.js +6 -1
  7. package/dist/types/FrameManager.d.mts +26 -0
  8. package/dist/types/FrameManager.d.ts +26 -26
  9. package/dist/types/ICE.d.mts +369 -0
  10. package/dist/types/ICE.d.ts +369 -107
  11. package/dist/types/a11y/accessibility.d.mts +46 -0
  12. package/dist/types/a11y/accessibility.d.ts +46 -0
  13. package/dist/types/animation/AnimationManager.d.mts +96 -0
  14. package/dist/types/animation/AnimationManager.d.ts +96 -25
  15. package/dist/types/animation/Easing.d.mts +33 -0
  16. package/dist/types/animation/Easing.d.ts +33 -32
  17. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.mts +14 -0
  18. package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -14
  19. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.mts +45 -0
  20. package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +45 -36
  21. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.mts +37 -0
  22. package/dist/types/consts/DOM_EVENT_MAPPING_CONSTS.d.ts +37 -19
  23. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.mts +27 -0
  24. package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +27 -20
  25. package/dist/types/control-panel/AlignmentGuideManager.d.mts +92 -0
  26. package/dist/types/control-panel/AlignmentGuideManager.d.ts +92 -0
  27. package/dist/types/control-panel/ICEControlPanel.d.mts +37 -0
  28. package/dist/types/control-panel/ICEControlPanel.d.ts +37 -37
  29. package/dist/types/control-panel/ICEControlPanelManager.d.mts +25 -0
  30. package/dist/types/control-panel/ICEControlPanelManager.d.ts +25 -23
  31. package/dist/types/control-panel/link-controls/LineControlPanel.d.mts +39 -0
  32. package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -39
  33. package/dist/types/control-panel/transform-controls/ResizeControl.d.mts +38 -0
  34. package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +38 -38
  35. package/dist/types/control-panel/transform-controls/RotateControl.d.mts +12 -0
  36. package/dist/types/control-panel/transform-controls/RotateControl.d.ts +12 -12
  37. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.mts +83 -0
  38. package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +83 -74
  39. package/dist/types/control-panel/transform-controls/constraints.d.mts +24 -0
  40. package/dist/types/control-panel/transform-controls/constraints.d.ts +24 -0
  41. package/dist/types/cross-platform/PolyfillPath2D.d.mts +31 -0
  42. package/dist/types/cross-platform/PolyfillPath2D.d.ts +31 -0
  43. package/dist/types/cross-platform/root.d.mts +7 -0
  44. package/dist/types/cross-platform/root.d.ts +7 -2
  45. package/dist/types/event/DOMEventDispatcher.d.mts +68 -0
  46. package/dist/types/event/DOMEventDispatcher.d.ts +68 -29
  47. package/dist/types/event/DOMEventInterceptor.d.mts +36 -0
  48. package/dist/types/event/DOMEventInterceptor.d.ts +36 -7
  49. package/dist/types/event/EventBus.d.mts +27 -0
  50. package/dist/types/event/EventBus.d.ts +27 -27
  51. package/dist/types/event/ICEEvent.d.mts +46 -0
  52. package/dist/types/event/ICEEvent.d.ts +46 -46
  53. package/dist/types/event/ICEEventTarget.d.mts +106 -0
  54. package/dist/types/event/ICEEventTarget.d.ts +106 -106
  55. package/dist/types/event/input-normalize.d.mts +75 -0
  56. package/dist/types/event/input-normalize.d.ts +75 -0
  57. package/dist/types/geometry/GeoLine.d.mts +24 -0
  58. package/dist/types/geometry/GeoLine.d.ts +24 -23
  59. package/dist/types/geometry/GeoPoint.d.mts +53 -0
  60. package/dist/types/geometry/GeoPoint.d.ts +53 -66
  61. package/dist/types/geometry/GeoUtil.d.mts +73 -0
  62. package/dist/types/geometry/GeoUtil.d.ts +73 -37
  63. package/dist/types/geometry/ICEBoundingBox.d.mts +81 -0
  64. package/dist/types/geometry/ICEBoundingBox.d.ts +81 -81
  65. package/dist/types/graphic/ICEComponent.d.mts +436 -0
  66. package/dist/types/graphic/ICEComponent.d.ts +436 -264
  67. package/dist/types/graphic/ICEDotPath.d.mts +99 -0
  68. package/dist/types/graphic/ICEDotPath.d.ts +99 -63
  69. package/dist/types/graphic/ICEImage.d.mts +17 -0
  70. package/dist/types/graphic/ICEImage.d.ts +17 -17
  71. package/dist/types/graphic/ICEPath.d.mts +39 -0
  72. package/dist/types/graphic/ICEPath.d.ts +39 -36
  73. package/dist/types/graphic/container/ICEGroup.d.mts +101 -0
  74. package/dist/types/graphic/container/ICEGroup.d.ts +101 -53
  75. package/dist/types/graphic/link/ICEBezier.d.mts +23 -0
  76. package/dist/types/graphic/link/ICEBezier.d.ts +23 -15
  77. package/dist/types/graphic/link/ICELinkHook.d.mts +52 -0
  78. package/dist/types/graphic/link/ICELinkHook.d.ts +52 -52
  79. package/dist/types/graphic/link/ICELinkSlot.d.mts +54 -0
  80. package/dist/types/graphic/link/ICELinkSlot.d.ts +54 -46
  81. package/dist/types/graphic/link/ICELinkSlotManager.d.mts +28 -0
  82. package/dist/types/graphic/link/ICELinkSlotManager.d.ts +28 -28
  83. package/dist/types/graphic/link/ICEPolyLine.d.mts +292 -0
  84. package/dist/types/graphic/link/ICEPolyLine.d.ts +292 -219
  85. package/dist/types/graphic/link/ICEVisioLink.d.mts +163 -0
  86. package/dist/types/graphic/link/ICEVisioLink.d.ts +163 -129
  87. package/dist/types/graphic/shape/ICECircle.d.mts +19 -0
  88. package/dist/types/graphic/shape/ICECircle.d.ts +19 -19
  89. package/dist/types/graphic/shape/ICEEllipse.d.mts +29 -0
  90. package/dist/types/graphic/shape/ICEEllipse.d.ts +29 -23
  91. package/dist/types/graphic/shape/ICEIsogon.d.mts +52 -0
  92. package/dist/types/graphic/shape/ICEIsogon.d.ts +52 -52
  93. package/dist/types/graphic/shape/ICERect.d.mts +10 -0
  94. package/dist/types/graphic/shape/ICERect.d.ts +10 -17
  95. package/dist/types/graphic/shape/ICERose.d.mts +41 -0
  96. package/dist/types/graphic/shape/ICERose.d.ts +41 -41
  97. package/dist/types/graphic/shape/ICEStar.d.mts +45 -0
  98. package/dist/types/graphic/shape/ICEStar.d.ts +45 -45
  99. package/dist/types/graphic/text/ICEText.d.mts +137 -0
  100. package/dist/types/graphic/text/ICEText.d.ts +137 -65
  101. package/dist/types/index.d.mts +55 -0
  102. package/dist/types/index.d.ts +55 -41
  103. package/dist/types/layout/ICEBorderLayout.d.mts +34 -0
  104. package/dist/types/layout/ICEBorderLayout.d.ts +34 -0
  105. package/dist/types/layout/ICEBoxLayout.d.mts +30 -0
  106. package/dist/types/layout/ICEBoxLayout.d.ts +30 -0
  107. package/dist/types/layout/ICECardLayout.d.mts +36 -0
  108. package/dist/types/layout/ICECardLayout.d.ts +36 -0
  109. package/dist/types/layout/ICEFlowLayout.d.mts +31 -0
  110. package/dist/types/layout/ICEFlowLayout.d.ts +31 -0
  111. package/dist/types/layout/ICEGridLayout.d.mts +33 -0
  112. package/dist/types/layout/ICEGridLayout.d.ts +33 -0
  113. package/dist/types/layout/ICELayeredLayout.d.mts +49 -0
  114. package/dist/types/layout/ICELayeredLayout.d.ts +49 -0
  115. package/dist/types/layout/ICELayoutManager.d.mts +33 -0
  116. package/dist/types/layout/ICELayoutManager.d.ts +33 -0
  117. package/dist/types/layout/ICEOverlayLayout.d.mts +25 -0
  118. package/dist/types/layout/ICEOverlayLayout.d.ts +25 -0
  119. package/dist/types/persistence/Deserializer.d.mts +43 -0
  120. package/dist/types/persistence/Deserializer.d.ts +43 -14
  121. package/dist/types/persistence/Serializer.d.mts +35 -0
  122. package/dist/types/persistence/Serializer.d.ts +35 -26
  123. package/dist/types/plugin/PluginHost.d.mts +86 -0
  124. package/dist/types/plugin/PluginHost.d.ts +86 -0
  125. package/dist/types/renderer/CanvasRenderer.d.mts +150 -0
  126. package/dist/types/renderer/CanvasRenderer.d.ts +150 -22
  127. package/dist/types/renderer/ObjectCache.d.mts +79 -0
  128. package/dist/types/renderer/ObjectCache.d.ts +79 -0
  129. package/dist/types/renderer/dirty-rect-util.d.mts +86 -0
  130. package/dist/types/renderer/dirty-rect-util.d.ts +86 -0
  131. package/dist/types/theme/ICETheme.d.mts +382 -0
  132. package/dist/types/theme/ICETheme.d.ts +382 -0
  133. package/dist/types/util/ImageCache.d.mts +19 -0
  134. package/dist/types/util/ImageCache.d.ts +19 -19
  135. package/dist/types/util/data-util.d.mts +43 -0
  136. package/dist/types/util/data-util.d.ts +43 -19
  137. package/dist/types/util/gl-matrix-skew.d.mts +14 -0
  138. package/dist/types/util/gl-matrix-skew.d.ts +14 -14
  139. package/dist/types/util/lang.d.mts +28 -0
  140. package/dist/types/util/lang.d.ts +28 -0
  141. package/dist/types/util/uuid.d.mts +1 -0
  142. package/dist/types/util/uuid.d.ts +1 -1
  143. package/package.json +118 -81
  144. package/dist/index.cjs.js +0 -25
  145. 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
- * @class GeoLine
10
- * A geometrically line, 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 GeoLine {
19
- constructor(startPoint: any, endPoint: any);
20
- startPoint: any;
21
- endPoint: any;
22
- contains(x: any, y: any): boolean;
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
- * @method load
22
- * Creates a {GeoPoint} out of JSON parsed object.
23
- *
24
- *
25
- * 从 JSON 对象创建 {GeoPoint} 实例。
26
- * @param {Object} o the JSON parsed object
27
- * @return {GeoPoint} a newly constructed GeoPoint
28
- */
29
- static load(o: any): GeoPoint;
30
- /**
31
- *
32
- * @method cloneArray
33
- * Clones an array of points.
34
- *
35
- *
36
- * 克隆一组点。
37
- * @param {Array} v - the array of {GeoPoint}s
38
- * @return an {Array} of {GeoPoint}s
39
- */
40
- static cloneArray(v: any[]): any[];
41
- /**
42
- * @constructor GeoPoint
43
- * @param {*} x
44
- * @param {*} y
45
- */
46
- constructor(x?: any, y?: any);
47
- x: any;
48
- y: any;
49
- /**
50
- * @method equals
51
- * Tests if this point is equals to other point.
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
- * 已知向量原点和向量坐标值,求向量相对于 X 轴正向的旋转角度。
13
- *
14
- * 两个点需要处于同一个坐标系中。
15
- *
16
- * rotateAngle 的数值范围限定在 [0,360] 度之间,闭区间。
17
- *
18
- * @param x
19
- * @param y
20
- * @param originX
21
- * @param originY
22
- * @returns
23
- */
24
- static calcRotateAngle(x: any, y: any, originX: any, originY: any): number;
25
- /**
26
- * 从变换矩阵计算旋转角度。
27
- * @param matrix
28
- * @returns 角度
29
- */
30
- static calcRotateAngleFromMatrix(matrix: any): number;
31
- /**
32
- * 从变换矩阵计算缩放参数。
33
- * @param matrix
34
- * @returns 缩放数组
35
- */
36
- static calcScaleFromMatrix(matrix: any): Array<number>;
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
- * FIXME:需要实现
50
- * 另一个边界盒子是否完全位于当前盒子内部。
51
- * @param box
52
- * @returns
53
- */
54
- containsBox(box: ICEBoundingBox): boolean;
55
- /**
56
- * 是否与另一个盒子存在相交的部分。
57
- * @param box
58
- * @returns
59
- */
60
- isIntersect(box: ICEBoundingBox): boolean;
61
- /**
62
- * @param matrix
63
- * @returns A new ICEBoundingBox instance.
64
- */
65
- transform(matrix: any): ICEBoundingBox;
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;