ice-render 0.0.6 → 0.0.9
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/dist/index.cjs.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/types/FrameManager.d.ts +24 -0
- package/dist/types/ICE.d.ts +86 -0
- package/dist/types/animation/AnimationManager.d.ts +25 -0
- package/dist/types/animation/Easing.d.ts +32 -0
- package/dist/types/consts/BIG_ZINDEX_NUMBER.d.ts +14 -0
- package/dist/types/consts/COMPONENT_TYPE_MAPPING.d.ts +37 -0
- package/dist/types/consts/ICE_EVENT_NAME_CONSTS.d.ts +20 -0
- package/dist/types/consts/MOUSE_EVENT_MAPPING_CONSTS.d.ts +13 -0
- package/dist/types/control-panel/DDManager.d.ts +24 -0
- package/dist/types/control-panel/ICEControlPanel.d.ts +30 -0
- package/dist/types/control-panel/ICEControlPanelManager.d.ts +24 -0
- package/dist/types/control-panel/link-controls/LineControlPanel.d.ts +39 -0
- package/dist/types/control-panel/transform-controls/ResizeControl.d.ts +34 -0
- package/dist/types/control-panel/transform-controls/RotateControl.d.ts +16 -0
- package/dist/types/control-panel/transform-controls/TransformControlPanel.d.ts +56 -0
- package/dist/types/cross-platform/root.d.ts +2 -0
- package/dist/types/event/DOMEventBridge.d.ts +27 -0
- package/dist/types/event/EventBus.d.ts +27 -0
- package/dist/types/event/ICEEvent.d.ts +46 -0
- package/dist/types/event/ICEEventTarget.d.ts +106 -0
- package/dist/types/event/KeyboardEventInterceptor.d.ts +0 -0
- package/dist/types/event/MouseEventInterceptor.d.ts +7 -0
- package/dist/types/event/TouchEventInterceptor.d.ts +0 -0
- package/dist/types/geometry/GeoLine.d.ts +23 -0
- package/dist/types/geometry/GeoPoint.d.ts +66 -0
- package/dist/types/geometry/GeoUtil.d.ts +25 -0
- package/dist/types/geometry/ICEBoundingBox.d.ts +81 -0
- package/dist/types/geometry/ICEMatrix.d.ts +22 -0
- package/dist/types/graphic/ICEComponent.d.ts +227 -0
- package/dist/types/graphic/ICEDotPath.d.ts +59 -0
- package/dist/types/graphic/ICEImage.d.ts +17 -0
- package/dist/types/graphic/ICEPath.d.ts +39 -0
- package/dist/types/graphic/container/ICEGroup.d.ts +34 -0
- package/dist/types/graphic/line/ICEBezier.d.ts +15 -0
- package/dist/types/graphic/line/ICEPolyLine.d.ts +189 -0
- package/dist/types/graphic/link/ICELinkHook.d.ts +43 -0
- package/dist/types/graphic/link/ICELinkSlot.d.ts +60 -0
- package/dist/types/graphic/link/ICELinkSlotManager.d.ts +24 -0
- package/dist/types/graphic/link/ICEVisioLink.d.ts +129 -0
- package/dist/types/graphic/shape/ICECircle.d.ts +19 -0
- package/dist/types/graphic/shape/ICEEllipse.d.ts +26 -0
- package/dist/types/graphic/shape/ICEIsogon.d.ts +51 -0
- package/dist/types/graphic/shape/ICERect.d.ts +17 -0
- package/dist/types/graphic/shape/ICERose.d.ts +38 -0
- package/dist/types/graphic/shape/ICEStar.d.ts +45 -0
- package/dist/types/graphic/text/ICEText.d.ts +42 -0
- package/dist/types/index.d.ts +41 -0
- package/dist/types/persistence/Deserializer.d.ts +13 -0
- package/dist/types/persistence/Serializer.d.ts +19 -0
- package/dist/types/renderer/CanvasRenderer.d.ts +24 -0
- package/dist/types/util/ImageCache.d.ts +17 -0
- package/dist/types/util/data-util.d.ts +19 -0
- package/dist/types/util/gl-matrix-skew.d.ts +14 -0
- package/dist/types/util/uuid.d.ts +1 -0
- package/package.json +3 -6
|
@@ -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
|
+
* 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;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 ICEMatrix {
|
|
9
|
+
constructor();
|
|
10
|
+
/**
|
|
11
|
+
* 从变换矩阵计算旋转角度。
|
|
12
|
+
* @param matrix
|
|
13
|
+
* @returns 角度
|
|
14
|
+
*/
|
|
15
|
+
static calcRotateAngleFromMatrix(matrix: any): number;
|
|
16
|
+
/**
|
|
17
|
+
* 从变换矩阵计算缩放参数。
|
|
18
|
+
* @param matrix
|
|
19
|
+
* @returns 缩放数组
|
|
20
|
+
*/
|
|
21
|
+
static calcScaleFromMatrix(matrix: any): Array<number>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
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 { mat2d } from 'gl-matrix';
|
|
9
|
+
import EventBus from '../event/EventBus';
|
|
10
|
+
import ICEEventTarget from '../event/ICEEventTarget';
|
|
11
|
+
import ICEBoundingBox from '../geometry/ICEBoundingBox';
|
|
12
|
+
import ICE from '../ICE';
|
|
13
|
+
/**
|
|
14
|
+
* @class ICEComponent
|
|
15
|
+
*
|
|
16
|
+
* 最顶级的抽象类,Canvas 内部所有可见的组件都是它的子类。
|
|
17
|
+
*
|
|
18
|
+
* @abstract
|
|
19
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
20
|
+
*/
|
|
21
|
+
declare abstract class ICEComponent extends ICEEventTarget {
|
|
22
|
+
ice: ICE;
|
|
23
|
+
root: any;
|
|
24
|
+
ctx: any;
|
|
25
|
+
evtBus: EventBus;
|
|
26
|
+
parentNode: any;
|
|
27
|
+
protected static instanceCounter: number;
|
|
28
|
+
protected __dirty: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @cfg
|
|
31
|
+
* {
|
|
32
|
+
* id: 'ICE_XXXXXXX', //UUID
|
|
33
|
+
* left: 0, //x 坐标相对于父组件的偏移量
|
|
34
|
+
* top: 0, //y 坐标相对于父组件的偏移量
|
|
35
|
+
* width: 0, //原始宽度,没有经过变换
|
|
36
|
+
* height: 0, //原始高度,没有经过变换
|
|
37
|
+
* style: {
|
|
38
|
+
* fillStyle: 'red',
|
|
39
|
+
* strokeStyle: 'blue',
|
|
40
|
+
* lineWidth: 1,
|
|
41
|
+
* },
|
|
42
|
+
* fill:true, //是否填充
|
|
43
|
+
* stroke:true, //是否描边
|
|
44
|
+
* animations: {}, //动画
|
|
45
|
+
* transform: { //组件自身的变换参数,不包含父组件
|
|
46
|
+
* translate: [0, 0], //平移,像素
|
|
47
|
+
* scale: [1, 1], //X轴缩放倍数,Y轴缩放倍数
|
|
48
|
+
* skew: [0, 0], //X轴扭曲角度,Y轴扭曲角度
|
|
49
|
+
* rotate: 0, //旋转角度
|
|
50
|
+
* },
|
|
51
|
+
* linearMatrix: [], //线性变换矩阵,不含平移,按照 gl-matrix 的格式定义
|
|
52
|
+
* composedMatrix: [], //复合变换矩阵,包含所有祖先节点的平移、原点移动、线性变换计算,composedMatrix 不会实时更新,如果需要获取当前最新的变换矩阵,需要调用 composeMatrix() 方法。按照 gl-matrix 的格式定义
|
|
53
|
+
* origin:'localCenter',
|
|
54
|
+
* localOrigin: [0,0], //相对于组件本地坐标系(组件内部的左上角为 [0,0] 点)计算的原点坐标
|
|
55
|
+
* absoluteOrigin: [0,0], //相对于全局坐标系(canvas 的左上角 [0,0] 点)计算的原点坐标
|
|
56
|
+
* zIndex: ICEComponent.instanceCounter++, //类似于 CSS 中的 zIndex
|
|
57
|
+
* display:true, //如果 display 为 false , Renderer 不会调用其 render 方法,对象在内存中存在,但是不会被渲染出来。如果 display 为 false ,所有子组件也不会被渲染出来。
|
|
58
|
+
* draggable:true, //是否可以拖动
|
|
59
|
+
* transformable:true, //是否可以进行变换:scale/rotate/skew ,以及 resize ,但是不控制拖动
|
|
60
|
+
* linkable:true, //组件是否可以用连接线连接起来,如果此状态为 true ,ICELinkSlotManager 在运行时会动态在组件上创建连接插槽 ICELinkSlot 的实例
|
|
61
|
+
* interactive: true, //是否可以进行用户交互操作,如果此参数为 false , draggable, transformable TODO:动画运行过程中不允许选中,不能进行交互???
|
|
62
|
+
* showMinBoundingBox:true, //是否显示最小包围盒,开发时打开,主要用于 debug
|
|
63
|
+
* showMaxBoundingBox:true, //是否显示最大包围盒,开发时打开,主要用于 debug
|
|
64
|
+
* }
|
|
65
|
+
* @param props
|
|
66
|
+
*/
|
|
67
|
+
props: any;
|
|
68
|
+
/**
|
|
69
|
+
* 在 ICE 引擎中,所有对象都可以启用动画效果,所以对象的 state 随时可能发生变化。
|
|
70
|
+
* props 与 state 之间的关系与行为模式借鉴自 React 框架,概念模型完全一致。
|
|
71
|
+
* @see https://reactjs.org/docs/components-and-props.html
|
|
72
|
+
*/
|
|
73
|
+
state: any;
|
|
74
|
+
constructor(props?: any);
|
|
75
|
+
/**
|
|
76
|
+
* 子类需要提供自己的实现。
|
|
77
|
+
*/
|
|
78
|
+
protected initEvents(): void;
|
|
79
|
+
/**
|
|
80
|
+
* !Important: 核心方法,FrameManager 会调度此方法进行实际的渲染操作。
|
|
81
|
+
* !Important: 这些方法调用有顺序
|
|
82
|
+
*/
|
|
83
|
+
render(): void;
|
|
84
|
+
protected applyStyleToCtx(): void;
|
|
85
|
+
/**
|
|
86
|
+
* 计算原始的宽高、位置,此时没有经过任何变换,也没有移动坐标原点。
|
|
87
|
+
* 此方法不能依赖原点位置和 transform 矩阵。
|
|
88
|
+
* 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
89
|
+
* @returns
|
|
90
|
+
*/
|
|
91
|
+
calcComponentParams(): {
|
|
92
|
+
width: any;
|
|
93
|
+
height: any;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* 计算本地原点坐标,相对于组件本地坐标系。
|
|
97
|
+
* 此方法依赖于 width/height ,需要先计算组件的尺寸,然后才能调用此方法。
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
protected calcLocalOrigin(): number[];
|
|
101
|
+
/**
|
|
102
|
+
* 根据原点位置描述计算原点坐标值。
|
|
103
|
+
* 移动坐标原点后,组件内部所有的坐标点数值、边界盒子的坐标,都会受到影响。
|
|
104
|
+
* 计算出的原点数值已经包含了所有父层的移位和变换。
|
|
105
|
+
* @method calcAbsoluteOrigin
|
|
106
|
+
*/
|
|
107
|
+
calcAbsoluteOrigin(): number[];
|
|
108
|
+
/**
|
|
109
|
+
* 计算线性变换矩阵,此矩阵不包含平移操作。
|
|
110
|
+
* 线性变换顺序:旋转->错切->缩放
|
|
111
|
+
* 由于矩阵变换有顺序,这里采用符合自然理解的顺序进行。
|
|
112
|
+
* @method calcLinearMatrix
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
protected calcLinearMatrix(): mat2d;
|
|
116
|
+
/**
|
|
117
|
+
* 复合所有祖先节点的线性变换矩阵,获得相对于全局 canvas 对象的变换矩阵。
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
protected calcAbsoluteLinearMatrix(): mat2d;
|
|
121
|
+
/**
|
|
122
|
+
* 仿射变换由2步完成:
|
|
123
|
+
* - ctx 平移到指定的原点。
|
|
124
|
+
* - ctx 进行线性变换。
|
|
125
|
+
*
|
|
126
|
+
* Canvas 绘图过程中的仿射变换动作与线性代数中的规则有差异:
|
|
127
|
+
* - Canvas 的 Y 坐标轴方向是向下的。
|
|
128
|
+
* - Canvas 在做仿射变换时,变换的是 ctx 本身,而不是组件对象,相当于画布本身是具有弹性的可变形对象。
|
|
129
|
+
*
|
|
130
|
+
* @method composeMatrix
|
|
131
|
+
* @returns
|
|
132
|
+
*/
|
|
133
|
+
protected composeMatrix(): mat2d;
|
|
134
|
+
/**
|
|
135
|
+
* 把变换矩阵应用到 this.ctx 上
|
|
136
|
+
*/
|
|
137
|
+
protected applyTransformToCtx(): void;
|
|
138
|
+
/**
|
|
139
|
+
* 所有子类都应该提供具体的实现。
|
|
140
|
+
* @method doRender
|
|
141
|
+
*/
|
|
142
|
+
protected doRender(): void;
|
|
143
|
+
/**
|
|
144
|
+
* 获取组件的最小包围盒,此盒子的变换矩阵与组件自身完全相同。
|
|
145
|
+
* 此方法需要在 render() 之后调用,组件没有渲染时无法计算最小包围盒。
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
getMinBoundingBox(refresh?: boolean): ICEBoundingBox;
|
|
149
|
+
/**
|
|
150
|
+
* 获取组件的最大包围盒:
|
|
151
|
+
* - 盒子保持水平和竖直,不旋转、不错切。
|
|
152
|
+
* - 盒子的4边在全局坐标 X/Y 轴上的投影范围与组件完全一致。
|
|
153
|
+
* @returns
|
|
154
|
+
*/
|
|
155
|
+
getMaxBoundingBox(refresh?: boolean): ICEBoundingBox;
|
|
156
|
+
/**
|
|
157
|
+
* setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
|
|
158
|
+
* @param newState
|
|
159
|
+
*/
|
|
160
|
+
setState(newState: any): void;
|
|
161
|
+
set dirty(flag: boolean);
|
|
162
|
+
get dirty(): boolean;
|
|
163
|
+
/**
|
|
164
|
+
* 相对于父组件的坐标系和原点。
|
|
165
|
+
* @param left
|
|
166
|
+
* @param top
|
|
167
|
+
* @param evt
|
|
168
|
+
*/
|
|
169
|
+
setPosition(left: number, top: number, evt?: any): void;
|
|
170
|
+
/**
|
|
171
|
+
* 在全局空间(canvas)中移动指定的位移。
|
|
172
|
+
* 注意:此方法用于直接设置组件在全局空间中的位移,而不是相对于其它坐标系。
|
|
173
|
+
* @param tx
|
|
174
|
+
* @param ty
|
|
175
|
+
* @param evt
|
|
176
|
+
*/
|
|
177
|
+
moveGlobalPosition(tx: number, ty: number, evt?: any): void;
|
|
178
|
+
/**
|
|
179
|
+
* 直接设置在全局空间 (canvas) 中的位置。
|
|
180
|
+
* 注意:此方法用于直接设置组件在全局空间中的位置,而不是相对于其它坐标系。
|
|
181
|
+
* @param left
|
|
182
|
+
* @param top
|
|
183
|
+
* @param evt
|
|
184
|
+
*/
|
|
185
|
+
setGlobalPosition(left: number, top: number, evt?: any): void;
|
|
186
|
+
/**
|
|
187
|
+
* 在全局空间(canvas)中旋转指定的角度。
|
|
188
|
+
* 注意:此方法用于直接设置组件在全局空间中的旋转角,而不是相对于其它坐标系。
|
|
189
|
+
* @param rotateAngle
|
|
190
|
+
*/
|
|
191
|
+
setGlobalRotate(rotateAngle: any): void;
|
|
192
|
+
/**
|
|
193
|
+
* 组件局部坐标系中的点转换成全局空间(canvas)中的点,包含移动原点的操作。
|
|
194
|
+
* @param localX
|
|
195
|
+
* @param localY
|
|
196
|
+
* @returns
|
|
197
|
+
*/
|
|
198
|
+
localToGlobal(localX: number, localY: number): number[];
|
|
199
|
+
/**
|
|
200
|
+
* 全局空间(canvas)中的点转换成组件局部坐标系中的点,包含移动原点的操作。
|
|
201
|
+
* @param globalX
|
|
202
|
+
* @param globalY
|
|
203
|
+
* @returns
|
|
204
|
+
*/
|
|
205
|
+
globalToLocal(globalX: number, globalY: number): number[];
|
|
206
|
+
/**
|
|
207
|
+
* 根据变换矩阵计算组件在全局空间(canvas)中的旋转角度。
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
getRotateAngle(): number;
|
|
211
|
+
getLocalLeftTop(): {
|
|
212
|
+
left: number;
|
|
213
|
+
top: number;
|
|
214
|
+
width: number;
|
|
215
|
+
height: number;
|
|
216
|
+
};
|
|
217
|
+
containsPoint(x: number, y: number): boolean;
|
|
218
|
+
/**
|
|
219
|
+
* @method destory
|
|
220
|
+
* 销毁组件
|
|
221
|
+
* - FIXME:立即停止组件上的所有动画效果
|
|
222
|
+
* - 需要清理绑定的事件
|
|
223
|
+
* - 带有子节点的组件需要先销毁子节点,然后再销毁自身。
|
|
224
|
+
*/
|
|
225
|
+
destory(): void;
|
|
226
|
+
}
|
|
227
|
+
export default ICEComponent;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import ICEPath from './ICEPath';
|
|
2
|
+
/**
|
|
3
|
+
* @class ICEDotPath
|
|
4
|
+
*
|
|
5
|
+
* 基于一系列点进行绘制的路径。
|
|
6
|
+
*
|
|
7
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
8
|
+
*/
|
|
9
|
+
export default abstract class ICEDotPath extends ICEPath {
|
|
10
|
+
/**
|
|
11
|
+
* @cfg
|
|
12
|
+
* {
|
|
13
|
+
* dots: [], //点状路径的点集
|
|
14
|
+
* closePath:true, //是否闭合
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* @param props
|
|
18
|
+
*/
|
|
19
|
+
constructor(props: any);
|
|
20
|
+
/**
|
|
21
|
+
* 计算原始的宽高、位置,此时没有经过任何变换,也没有移动坐标原点。
|
|
22
|
+
* 由于点状路径可能是不规则的形状,所以宽高需要手动计算,特殊形状的子类需要覆盖此方法提供自己的实现。
|
|
23
|
+
* 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
24
|
+
* @overwrite
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
calcComponentParams(): {
|
|
28
|
+
width: any;
|
|
29
|
+
height: any;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* 点状路径在重新计算本地原点坐标之后,需要移动内部所有点的位置。
|
|
33
|
+
* @overwrite
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
protected calcLocalOrigin(): number[];
|
|
37
|
+
/**
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
protected createPathObject(): Path2D;
|
|
41
|
+
/**
|
|
42
|
+
* 计算路径上的关键点:
|
|
43
|
+
* - 默认的坐标原点是 (0,0) 位置。
|
|
44
|
+
* - 这些点没有经过 transform 矩阵变换。
|
|
45
|
+
* this.calcComponentParams() 会依赖此方法,在计算尺寸时还没有确定原点坐标,所以 calcDots() 方法内部不能依赖原点坐标,只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
protected calcDots(): any;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* 计算4个顶点:
|
|
52
|
+
* - 相对于组件本地的坐标系,原点位于左上角,没有经过矩阵变换。
|
|
53
|
+
* - 返回值用于计算组件的原始 width/height 。
|
|
54
|
+
*
|
|
55
|
+
* @returns
|
|
56
|
+
*/
|
|
57
|
+
protected calc4VertexPoints(): any[][];
|
|
58
|
+
protected getTransformedDots(): any[];
|
|
59
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
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 ICEComponent from './ICEComponent';
|
|
9
|
+
/**
|
|
10
|
+
* @class ICEImage
|
|
11
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
12
|
+
*/
|
|
13
|
+
declare class ICEImage extends ICEComponent {
|
|
14
|
+
constructor(props?: any);
|
|
15
|
+
protected doRender(): void;
|
|
16
|
+
}
|
|
17
|
+
export default ICEImage;
|
|
@@ -0,0 +1,39 @@
|
|
|
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 ICEComponent from './ICEComponent';
|
|
9
|
+
/**
|
|
10
|
+
* @class ICEPath
|
|
11
|
+
*
|
|
12
|
+
* 路径
|
|
13
|
+
*
|
|
14
|
+
* @abstract
|
|
15
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
16
|
+
*/
|
|
17
|
+
declare abstract class ICEPath extends ICEComponent {
|
|
18
|
+
path2D: Path2D;
|
|
19
|
+
/**
|
|
20
|
+
* @cfg
|
|
21
|
+
* {
|
|
22
|
+
* dots:[] //可选参数,路径上的点。
|
|
23
|
+
* }
|
|
24
|
+
* @param props
|
|
25
|
+
*/
|
|
26
|
+
constructor(props?: any);
|
|
27
|
+
/**
|
|
28
|
+
* @method doRender
|
|
29
|
+
* @overwrite
|
|
30
|
+
*/
|
|
31
|
+
protected doRender(): void;
|
|
32
|
+
/**
|
|
33
|
+
* @method createPathObject
|
|
34
|
+
* 创建 Path2D 对象,子类需要提供具体实现,此方法仅创建对象实例,不会立即绘制到画布上,绘制过程由 Renderer 进行调度。
|
|
35
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Path2D/Path2D
|
|
36
|
+
*/
|
|
37
|
+
protected abstract createPathObject(): Path2D;
|
|
38
|
+
}
|
|
39
|
+
export default ICEPath;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ICEComponent from '../ICEComponent';
|
|
2
|
+
import ICERect from '../shape/ICERect';
|
|
3
|
+
/**
|
|
4
|
+
* @class ICEGroup
|
|
5
|
+
*
|
|
6
|
+
* 容器型组件
|
|
7
|
+
*
|
|
8
|
+
* ICEGroup 可以包含自身,利用此组件可以构造出树形的对象结构。
|
|
9
|
+
*
|
|
10
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
11
|
+
*/
|
|
12
|
+
declare class ICEGroup extends ICERect {
|
|
13
|
+
parentNode: any;
|
|
14
|
+
childNodes: any[];
|
|
15
|
+
constructor(props: any);
|
|
16
|
+
/**
|
|
17
|
+
* !注意:在调用 ICEGroup.addChild() 方法时, ICEGroup 自身可能还没有被添加到 ICE 实例中去。所以此时 child.root, child.ctx, child.evtBus 都可能为空。
|
|
18
|
+
* @param child
|
|
19
|
+
*/
|
|
20
|
+
addChild(child: ICEComponent): void;
|
|
21
|
+
addChildren(arr: Array<ICEComponent>): void;
|
|
22
|
+
removeChild(child: ICEComponent): void;
|
|
23
|
+
removeChildren(arr: Array<ICEComponent>): void;
|
|
24
|
+
/**
|
|
25
|
+
* @overwrite
|
|
26
|
+
* @method destory
|
|
27
|
+
* 销毁组件
|
|
28
|
+
* - FIXME:立即停止组件上的所有动画效果
|
|
29
|
+
* - 需要清理绑定的事件
|
|
30
|
+
* - 带有子节点的组件需要先销毁子节点,然后再销毁自身。
|
|
31
|
+
*/
|
|
32
|
+
destory(): void;
|
|
33
|
+
}
|
|
34
|
+
export default ICEGroup;
|
|
@@ -0,0 +1,15 @@
|
|
|
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 ICEBezier 贝塞尔曲线
|
|
10
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
11
|
+
*/
|
|
12
|
+
declare class ICEBezier {
|
|
13
|
+
constructor(props?: any);
|
|
14
|
+
}
|
|
15
|
+
export default ICEBezier;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import ICEEvent from '../../event/ICEEvent';
|
|
2
|
+
import ICEBoundingBox from '../../geometry/ICEBoundingBox';
|
|
3
|
+
import ICEComponent from '../ICEComponent';
|
|
4
|
+
import ICEDotPath from '../ICEDotPath';
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @class ICEPolyLine
|
|
8
|
+
*
|
|
9
|
+
* 折线
|
|
10
|
+
*
|
|
11
|
+
* 基本特征:
|
|
12
|
+
*
|
|
13
|
+
* - ICEPolyLine 由多个点构成,如果折线上的所有点共线,则折线在外观上退化成直线。
|
|
14
|
+
* - ICEPolyLine 上至少存在 2 个点,否则无法画线。如果点数恰好为 2 ,折线退化成一条直线。
|
|
15
|
+
* - ICEPolyLine 以及所有子类不能进行 transform 操作。
|
|
16
|
+
* - ICEPolyLine 以及所有子类的 left/top 总是被设置为 startPoint 。
|
|
17
|
+
* - ICEPolyLine 以及所有子类的原点都在 startPoint 上,而不在几何中心点。
|
|
18
|
+
*
|
|
19
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
20
|
+
*/
|
|
21
|
+
declare class ICEPolyLine extends ICEDotPath {
|
|
22
|
+
/**
|
|
23
|
+
* {
|
|
24
|
+
* start:{componnet:ICEComponent,position:'T'},
|
|
25
|
+
* end:{component:ICEComponent,position:'B'}
|
|
26
|
+
* }
|
|
27
|
+
*/
|
|
28
|
+
protected links: any;
|
|
29
|
+
/**
|
|
30
|
+
* @cfg
|
|
31
|
+
* {
|
|
32
|
+
* lineType: 'solid', //solid, dashed
|
|
33
|
+
* lineWidth:2,
|
|
34
|
+
* arrowPosition: 'none', //none, start, end ,both
|
|
35
|
+
* arrowLength: 15, //箭头长度
|
|
36
|
+
* arrowAngel: 30, //箭头角度
|
|
37
|
+
* closePath:false, //连线默认不闭合路径
|
|
38
|
+
* points:[], //点的坐标
|
|
39
|
+
* links:{start:{id,position},end:{id,position}} //如果传递了连接关系参数,则在渲染器完成一轮渲染之后,自动建立连接关系。
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* @param props
|
|
43
|
+
*/
|
|
44
|
+
constructor(props?: any);
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* 整理并校验构造参数。
|
|
48
|
+
*
|
|
49
|
+
* @static
|
|
50
|
+
* @param props
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
static arrangeParam(props: any): any;
|
|
54
|
+
/**
|
|
55
|
+
* @overwrite
|
|
56
|
+
*/
|
|
57
|
+
protected initEvents(): void;
|
|
58
|
+
protected afterAddHandler(evt?: ICEEvent): void;
|
|
59
|
+
protected makeConnection(): void;
|
|
60
|
+
setLink(terminal: string, component: ICEComponent, position: string): void;
|
|
61
|
+
removeLink(terminal: string, component: ICEComponent, position: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* @method
|
|
64
|
+
* 连接的组件位置发生移动之后,重新计算连接线的起点和终点。
|
|
65
|
+
*/
|
|
66
|
+
private followComponent;
|
|
67
|
+
/**
|
|
68
|
+
* ICEPolyLine 有自己的特殊处理,它的原点永远在 (0,0) 位置,而不在几何中点。
|
|
69
|
+
* @overwrite
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
protected calcLocalOrigin(): number[];
|
|
73
|
+
/**
|
|
74
|
+
* @method calcDots
|
|
75
|
+
* ICEPolyLine 有自己特殊的计算方式:
|
|
76
|
+
* - 原点总是放在 startPoint 的位置。
|
|
77
|
+
* - 数值相对于组件本地坐标系进行计算。
|
|
78
|
+
* @overwrite
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
protected calcDots(): any;
|
|
82
|
+
/**
|
|
83
|
+
* @method calcArrowPoints
|
|
84
|
+
* 计算箭头坐标
|
|
85
|
+
*/
|
|
86
|
+
protected calcArrowPoints(): void;
|
|
87
|
+
protected doCalcArrowPoints(twoPoints: any): number[][];
|
|
88
|
+
/**
|
|
89
|
+
* @method addDot 增加一个点
|
|
90
|
+
*
|
|
91
|
+
* 动态向线条上增加一个点。
|
|
92
|
+
*
|
|
93
|
+
* @param point
|
|
94
|
+
* @param index
|
|
95
|
+
*/
|
|
96
|
+
addDot(point: [number, number], index: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* @method rmDot 删除一个点
|
|
99
|
+
*
|
|
100
|
+
* 从线条上删掉一个点,如果线条上的点数已经小于等于 2 ,则什么都不做。
|
|
101
|
+
*
|
|
102
|
+
* @param index
|
|
103
|
+
*/
|
|
104
|
+
rmDot(index: number): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* @method calcComponentParams
|
|
107
|
+
*
|
|
108
|
+
* - 计算原始的宽高、位置,此时没有经过任何变换,也没有移动坐标原点。
|
|
109
|
+
* - 由于点状路径可能是不规则的形状,所以宽高需要手动计算,特殊形状的子类需要覆盖此方法提供自己的实现。
|
|
110
|
+
* - 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
111
|
+
*
|
|
112
|
+
* @overwrite
|
|
113
|
+
* @returns {ComponentParams}
|
|
114
|
+
*/
|
|
115
|
+
calcComponentParams(): {
|
|
116
|
+
width: any;
|
|
117
|
+
height: any;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* @method isDotsOnSameLine 是否所有点都在同一条直线上
|
|
121
|
+
*
|
|
122
|
+
* 进行共线判断,如果所有点都在同一条直线上,那么边界盒子的整体高度就等于线条的粗细。
|
|
123
|
+
*
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
private isDotsOnSameLine;
|
|
127
|
+
/**
|
|
128
|
+
* @method calc4VertexPoints 计算4个顶点
|
|
129
|
+
*
|
|
130
|
+
* - 相对于组件本地的坐标系,原点位于左上角,没有经过矩阵变换。
|
|
131
|
+
* - 返回值用于计算组件的原始 width/height 。
|
|
132
|
+
*
|
|
133
|
+
* @returns {Array}
|
|
134
|
+
*/
|
|
135
|
+
protected calc4VertexPoints(): any[][];
|
|
136
|
+
/**
|
|
137
|
+
* @method splitEndpointsTo4Points 将线条的起点和终点分成4个点,用于计算组件的原始 width/height
|
|
138
|
+
*
|
|
139
|
+
* 把直线的2个端点分裂成4个点,把线条的粗细参数(lineWidth)当成高度看待,方便计算最小包围盒。
|
|
140
|
+
*
|
|
141
|
+
* @returns
|
|
142
|
+
*/
|
|
143
|
+
protected splitEndpointsTo4Points(): number[][];
|
|
144
|
+
/**
|
|
145
|
+
* @method getMinBoundingBox 获取最小包围盒
|
|
146
|
+
*
|
|
147
|
+
* 此盒子的变换矩阵与组件自身的变换矩阵完全相同。
|
|
148
|
+
*
|
|
149
|
+
* @returns
|
|
150
|
+
*/
|
|
151
|
+
getMinBoundingBox(): ICEBoundingBox;
|
|
152
|
+
/**
|
|
153
|
+
* @method setState 更新组件状态
|
|
154
|
+
* setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
|
|
155
|
+
*
|
|
156
|
+
* ICEPolyLine 有自己特殊的处理方法:
|
|
157
|
+
*
|
|
158
|
+
* - ICEPolyLine 的 width/height 属性总是计算出来的,不能直接修改,不接受 width/height 配置项。
|
|
159
|
+
* - ICEPolyLine ICEPolyLine 不能进行 transform 操作,不接受 transform 配置项。
|
|
160
|
+
* - ICEPolyLine 可以直接修改 points 。
|
|
161
|
+
* - ICEPolyLine 的 left/top 数值可以直接修改,修改 left/top 时,会重新计算起点和终点坐标,保证 left/top 与 startPoint 始终保持在同一个点上。
|
|
162
|
+
*
|
|
163
|
+
* @overwrite
|
|
164
|
+
* @param newState 新的状态
|
|
165
|
+
*/
|
|
166
|
+
setState(newState: any): void;
|
|
167
|
+
/**
|
|
168
|
+
* @method getRotateAngle 获取组件的旋转角度
|
|
169
|
+
* @returns {number}
|
|
170
|
+
*/
|
|
171
|
+
getRotateAngle(): number;
|
|
172
|
+
/**
|
|
173
|
+
* @method containsPoint 判断点是否在线上
|
|
174
|
+
*
|
|
175
|
+
* 计算方法:如果给点的坐标点到线段两端的距离之和等于线段长度,则表示点位于线段上,允许一定的误差范围,用 delta 参数进行调节。
|
|
176
|
+
* 算法来源:http://www.jeffreythompson.org/collision-detection/line-point.php
|
|
177
|
+
*
|
|
178
|
+
* @param x
|
|
179
|
+
* @param y
|
|
180
|
+
* @returns {boolean}
|
|
181
|
+
*/
|
|
182
|
+
containsPoint(x: number, y: number): boolean;
|
|
183
|
+
/**
|
|
184
|
+
* @method getLines 获取线段数组
|
|
185
|
+
* @returns {Array<any>}
|
|
186
|
+
*/
|
|
187
|
+
private getLines;
|
|
188
|
+
}
|
|
189
|
+
export default ICEPolyLine;
|