ice-render 0.0.8 → 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 -10030
- package/dist/index.js +1 -9993
- package/dist/index.umd.js +1 -10036
- 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 +2 -5
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class ICEEventTarget
|
|
3
|
+
*
|
|
4
|
+
* - canvas 标签内部没有事件机制,模仿 W3C 定义的 EventTaregt 接口,为 Canvas 内部的组件添加事件机制。
|
|
5
|
+
* - ICE 内部的大部分组件都是 ICEEventTarget 的子类。
|
|
6
|
+
* - 部分 API 名称模仿 jQuery ,方便使用者调用。
|
|
7
|
+
*
|
|
8
|
+
* TODO:需要完整模拟 W3C 和 jQuery 提供的事件接口,在 API 名称和调用逻辑上保持完全一致。
|
|
9
|
+
*
|
|
10
|
+
* listeners 的结构:
|
|
11
|
+
* {
|
|
12
|
+
* "click":[
|
|
13
|
+
* {
|
|
14
|
+
* callback:fn1,
|
|
15
|
+
* scope:window
|
|
16
|
+
* },
|
|
17
|
+
* {
|
|
18
|
+
* callback:fn2,
|
|
19
|
+
* scope:component-1
|
|
20
|
+
* }
|
|
21
|
+
* ],
|
|
22
|
+
* "mousemove":[
|
|
23
|
+
* {
|
|
24
|
+
* callback:fn1,
|
|
25
|
+
* scope:window
|
|
26
|
+
* },
|
|
27
|
+
* {
|
|
28
|
+
* callback:fn2,
|
|
29
|
+
* scope:component-1
|
|
30
|
+
* }
|
|
31
|
+
* ]
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* @abstract
|
|
35
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
36
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
|
|
37
|
+
*/
|
|
38
|
+
declare abstract class ICEEventTarget {
|
|
39
|
+
protected listeners: any;
|
|
40
|
+
protected suspendedEventNames: any;
|
|
41
|
+
constructor();
|
|
42
|
+
/**
|
|
43
|
+
* @method on
|
|
44
|
+
* 添加事件监听
|
|
45
|
+
* @param eventName
|
|
46
|
+
* @param fn
|
|
47
|
+
* @param scope
|
|
48
|
+
*/
|
|
49
|
+
on(eventName: string, fn: Function, scope?: any): void;
|
|
50
|
+
/**
|
|
51
|
+
* @method off
|
|
52
|
+
* 删除事件监听
|
|
53
|
+
* @param eventName
|
|
54
|
+
* @param fn
|
|
55
|
+
* @param scope
|
|
56
|
+
* @returns
|
|
57
|
+
*/
|
|
58
|
+
off(eventName: string, fn: Function, scope?: any): void;
|
|
59
|
+
/**
|
|
60
|
+
* @method once
|
|
61
|
+
* 一次性事件,触发一次就自动删除自己。
|
|
62
|
+
* @param eventName
|
|
63
|
+
* @param fn
|
|
64
|
+
*/
|
|
65
|
+
once(eventName: string, fn: Function, scope?: any): void;
|
|
66
|
+
/**
|
|
67
|
+
* @method dispatchEvent
|
|
68
|
+
*
|
|
69
|
+
* 触发事件。
|
|
70
|
+
*
|
|
71
|
+
* 所有事件都会被转换成 ICEEvent 实例。
|
|
72
|
+
*
|
|
73
|
+
* @param eventName
|
|
74
|
+
* @param originalEvent
|
|
75
|
+
* @param param
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
trigger(eventName: string, originalEvent?: any, param?: {}): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* @method suspend
|
|
81
|
+
* 挂起事件。
|
|
82
|
+
* @param eventName
|
|
83
|
+
*/
|
|
84
|
+
suspend(eventName: string): void;
|
|
85
|
+
/**
|
|
86
|
+
* @method resume
|
|
87
|
+
* 恢复事件。
|
|
88
|
+
* @param eventName
|
|
89
|
+
*/
|
|
90
|
+
resume(eventName: string): void;
|
|
91
|
+
/**
|
|
92
|
+
* @method purgeEvents
|
|
93
|
+
* 清除所有事件。
|
|
94
|
+
*/
|
|
95
|
+
purgeEvents(): void;
|
|
96
|
+
/**
|
|
97
|
+
* @method hasListener
|
|
98
|
+
* 查询是否带有某个事件监听器。
|
|
99
|
+
* @param eventName
|
|
100
|
+
* @param fn
|
|
101
|
+
* @param scope
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
hasListener(eventName: string, fn: Function, scope?: any): boolean;
|
|
105
|
+
}
|
|
106
|
+
export default ICEEventTarget;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,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
|
+
/**
|
|
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
|
+
}
|
|
@@ -0,0 +1,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
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @method load
|
|
22
|
+
* Creates a {GeoPoint} out of JSON parsed object.
|
|
23
|
+
*
|
|
24
|
+
*
|
|
25
|
+
* 从 JSON 对象创建 {GeoPoint} 实例。
|
|
26
|
+
* @param {JSONObject} o the JSON parsed object
|
|
27
|
+
* @return {GeoPoint} a newly constructed GeoPoint
|
|
28
|
+
*/
|
|
29
|
+
static load(o: JSONObject): 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
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
}
|
|
@@ -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;
|