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,14 @@
|
|
|
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
|
+
* zIndex 最大值,这里使用一千万是安全的,在一张画布上渲染一千万个图形的可能性很小
|
|
10
|
+
* zIndex 用来控制组件在画布中的堆叠次序
|
|
11
|
+
* @see ICEComponent.state.zIndex
|
|
12
|
+
*/
|
|
13
|
+
declare const bigZIndexNum: number;
|
|
14
|
+
export default bigZIndexNum;
|
|
@@ -0,0 +1,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
|
+
import ICEGroup from '../graphic/container/ICEGroup';
|
|
9
|
+
import ICEImage from '../graphic/ICEImage';
|
|
10
|
+
import ICEPolyLine from '../graphic/line/ICEPolyLine';
|
|
11
|
+
import ICEVisioLink from '../graphic/link/ICEVisioLink';
|
|
12
|
+
import ICECircle from '../graphic/shape/ICECircle';
|
|
13
|
+
import ICEEllipse from '../graphic/shape/ICEEllipse';
|
|
14
|
+
import ICEIsogon from '../graphic/shape/ICEIsogon';
|
|
15
|
+
import ICERect from '../graphic/shape/ICERect';
|
|
16
|
+
import ICEStar from '../graphic/shape/ICEStar';
|
|
17
|
+
import ICEText from '../graphic/text/ICEText';
|
|
18
|
+
/**
|
|
19
|
+
* 组件名称和构造函数引用之间的映射关系,把序列化之后的 JSON 字符串重新解析成图形时需要用到此映射关系。
|
|
20
|
+
*
|
|
21
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
22
|
+
*
|
|
23
|
+
* FIXME:需要扩展一个注册方法,让外部使用方把自己扩展的组件注册进来,否则无法序列化和反解析。
|
|
24
|
+
*/
|
|
25
|
+
declare const componentTypeMap: {
|
|
26
|
+
ICERect: typeof ICERect;
|
|
27
|
+
ICECircle: typeof ICECircle;
|
|
28
|
+
ICEEllipse: typeof ICEEllipse;
|
|
29
|
+
ICEStar: typeof ICEStar;
|
|
30
|
+
ICEIsogon: typeof ICEIsogon;
|
|
31
|
+
ICEText: typeof ICEText;
|
|
32
|
+
ICEImage: typeof ICEImage;
|
|
33
|
+
ICEGroup: typeof ICEGroup;
|
|
34
|
+
ICEVisioLink: typeof ICEVisioLink;
|
|
35
|
+
ICEPolyLine: typeof ICEPolyLine;
|
|
36
|
+
};
|
|
37
|
+
export default componentTypeMap;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default ICE_EVENT_NAME_CONSTS;
|
|
2
|
+
declare namespace ICE_EVENT_NAME_CONSTS {
|
|
3
|
+
const ICE_FRAME_EVENT: string;
|
|
4
|
+
const BEFORE_RENDER: string;
|
|
5
|
+
const AFTER_RENDER: string;
|
|
6
|
+
const BEFORE_ADD: string;
|
|
7
|
+
const AFTER_ADD: string;
|
|
8
|
+
const BEFORE_REMOVE: string;
|
|
9
|
+
const AFTER_REMOVE: string;
|
|
10
|
+
const ROUND_FINISH: string;
|
|
11
|
+
const HOOK_MOUSEDOWN: string;
|
|
12
|
+
const HOOK_MOUSEMOVE: string;
|
|
13
|
+
const HOOK_MOUSEUP: string;
|
|
14
|
+
const BEFORE_RESIZE: string;
|
|
15
|
+
const AFTER_RESIZE: string;
|
|
16
|
+
const BEFORE_ROTATE: string;
|
|
17
|
+
const AFTER_ROTATE: string;
|
|
18
|
+
const BEFORE_MOVE: string;
|
|
19
|
+
const AFTER_MOVE: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default mouseEvents;
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2022 大漠穷秋.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 原生 DOM 事件与 ICE 内部转发事件之间的对应关系
|
|
11
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
12
|
+
*/
|
|
13
|
+
declare const mouseEvents: string[][];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ICE from '../ICE';
|
|
2
|
+
/**
|
|
3
|
+
* @class DDManager
|
|
4
|
+
*
|
|
5
|
+
* 拖拽管理器
|
|
6
|
+
*
|
|
7
|
+
* - ICE Render 中所有组件的拖动都由 DDManager 管理。
|
|
8
|
+
* - 拖拽管理器是纯逻辑组件,没有外观。
|
|
9
|
+
* - DDManager 只负责拖拽和移动位置,不进行其它操作。
|
|
10
|
+
* - 全局单例,一个 ICE 实例上只能有一个 DDManager 实例。
|
|
11
|
+
*
|
|
12
|
+
* @see ICE
|
|
13
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
14
|
+
*/
|
|
15
|
+
export default class DDManager {
|
|
16
|
+
private ice;
|
|
17
|
+
private currentObj;
|
|
18
|
+
constructor(ice: ICE);
|
|
19
|
+
start(): this;
|
|
20
|
+
stop(): this;
|
|
21
|
+
private mouseDownHandler;
|
|
22
|
+
private mouseMoveHandler;
|
|
23
|
+
private mouseUpHandler;
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 ICEGroup from '../graphic/container/ICEGroup';
|
|
9
|
+
import ICEComponent from '../graphic/ICEComponent';
|
|
10
|
+
/**
|
|
11
|
+
* @class ICEControlPanel
|
|
12
|
+
*
|
|
13
|
+
* 控制面板
|
|
14
|
+
*
|
|
15
|
+
* FIXME:所有 ControlPanel 类型的组件都需要处理组件的 REMOVE 事件,当组件被删除时,清理关联关系。
|
|
16
|
+
*
|
|
17
|
+
* - ICEControlPanel 本身总是直接画在 canvas 上,不是任何组件的孩子。
|
|
18
|
+
*
|
|
19
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
20
|
+
*/
|
|
21
|
+
export default abstract class ICEControlPanel extends ICEGroup {
|
|
22
|
+
protected _targetComponent: ICEComponent;
|
|
23
|
+
constructor(props: any);
|
|
24
|
+
protected abstract initControls(): void;
|
|
25
|
+
protected abstract setControlPositions(): void;
|
|
26
|
+
protected doRender(): void;
|
|
27
|
+
moveGlobalPosition(tx: number, ty: number, evt?: any): void;
|
|
28
|
+
abstract enable(): any;
|
|
29
|
+
abstract disable(): any;
|
|
30
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ICE from '../ICE';
|
|
2
|
+
/**
|
|
3
|
+
* @class ICEControlPanelManager
|
|
4
|
+
*
|
|
5
|
+
* 控制面板管理器
|
|
6
|
+
*
|
|
7
|
+
* - ICEControlPanelManager 负责管理所有类型的控制面板(ControlPanel)。
|
|
8
|
+
* - ICEControlPanelManager 是全局单例的,一个 ICE 实例上只能有一个实例。
|
|
9
|
+
* - ICEControlPanelManager 只需要设置 targetComponent 即可,拖拽移位操作由 DDManager 完成。
|
|
10
|
+
* - ICEControlPanelManager 是纯逻辑组件,没有外观。
|
|
11
|
+
*
|
|
12
|
+
* @see ICE
|
|
13
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
14
|
+
*/
|
|
15
|
+
declare class ICEControlPanelManager {
|
|
16
|
+
private ice;
|
|
17
|
+
private transformControlPanel;
|
|
18
|
+
private lineControlPanel;
|
|
19
|
+
constructor(ice: ICE);
|
|
20
|
+
start(): this;
|
|
21
|
+
stop(): this;
|
|
22
|
+
private mouseDownHandler;
|
|
23
|
+
}
|
|
24
|
+
export default ICEControlPanelManager;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ICEComponent from '../../graphic/ICEComponent';
|
|
2
|
+
import ICEControlPanel from '../ICEControlPanel';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @class LineControlPanel
|
|
6
|
+
*
|
|
7
|
+
* 线条变换控制面板
|
|
8
|
+
*
|
|
9
|
+
* LineControlPanel 只作为空的逻辑容器存在,控制面板内部的操作手柄需要全屏幕自由移动位置,手柄位置不固定,对 LineControlPanel 本身的参数完全没有影响。
|
|
10
|
+
*
|
|
11
|
+
* LineControlPanel 功能:
|
|
12
|
+
*
|
|
13
|
+
* - 移动线条的位置
|
|
14
|
+
* - 调整线条起点和终点的位置
|
|
15
|
+
* - 将线条连接到其它组件上
|
|
16
|
+
*
|
|
17
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
18
|
+
*/
|
|
19
|
+
export default class LineControlPanel extends ICEControlPanel {
|
|
20
|
+
private controlSize;
|
|
21
|
+
private startControl;
|
|
22
|
+
private endControl;
|
|
23
|
+
constructor(props: any);
|
|
24
|
+
protected initControls(): void;
|
|
25
|
+
protected initEvents(): void;
|
|
26
|
+
enable(): void;
|
|
27
|
+
disable(): void;
|
|
28
|
+
/**
|
|
29
|
+
* 设置所有手柄在父组件中的位置,相对于父组件的本地坐标系。
|
|
30
|
+
* LineControlPanel 不强制操作手柄的位置,操作手柄可以自由移动。
|
|
31
|
+
*/
|
|
32
|
+
protected setControlPositions(): void;
|
|
33
|
+
private resizeEvtHandler;
|
|
34
|
+
protected updatePosition(): void;
|
|
35
|
+
set targetComponent(component: ICEComponent);
|
|
36
|
+
get targetComponent(): ICEComponent;
|
|
37
|
+
showHooks(): void;
|
|
38
|
+
hideHooks(): void;
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import ICERect from '../../graphic/shape/ICERect';
|
|
2
|
+
/**
|
|
3
|
+
* @class ResizeControl 调整尺寸的操作手柄
|
|
4
|
+
*
|
|
5
|
+
* - 调整尺寸的操作手柄不能独立存在,只能依附在某个宿主对象上。
|
|
6
|
+
* - 此手柄只能调整尺寸,不能实现翻转
|
|
7
|
+
*
|
|
8
|
+
* TODO: 补全 props 配置项
|
|
9
|
+
* {
|
|
10
|
+
* direction: 改变的方向,共有3个可选的值: x/y/both
|
|
11
|
+
* position: 手柄在变换矩形4个边上的位置,共有8个:lt/t/rt/r/rb/b/lb/l
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export default class ResizeControl extends ICERect {
|
|
15
|
+
constructor(props: any);
|
|
16
|
+
protected initEvents(): void;
|
|
17
|
+
/**
|
|
18
|
+
* 围绕几何中心点调整宽高。
|
|
19
|
+
* @param evt
|
|
20
|
+
*/
|
|
21
|
+
private resizeEvtHandler;
|
|
22
|
+
/**
|
|
23
|
+
* @overwrite
|
|
24
|
+
* ResizeControl 不能自由移动自己的位置,自能在X轴、Y轴,以及矩形的2条对角线上移动位置。
|
|
25
|
+
*
|
|
26
|
+
* 在全局空间(canvas)中移动指定的位移。
|
|
27
|
+
* 注意:此方法用于直接设置组件在全局空间中的位移,而不是相对于其它坐标系。
|
|
28
|
+
*
|
|
29
|
+
* @param tx
|
|
30
|
+
* @param ty
|
|
31
|
+
* @param evt
|
|
32
|
+
*/
|
|
33
|
+
moveGlobalPosition(tx: number, ty: number, evt?: any): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ICECircle from '../../graphic/shape/ICECircle';
|
|
2
|
+
/**
|
|
3
|
+
* @class RotateControl 旋转操作手柄
|
|
4
|
+
*
|
|
5
|
+
* - 旋转手柄不能独立存在,只能依附在某个宿主对象上。
|
|
6
|
+
* - 此手柄仅用来修改组件的旋转角度。
|
|
7
|
+
*
|
|
8
|
+
* TODO: 补全 props 配置项
|
|
9
|
+
* {
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
export default class RotateControl extends ICECircle {
|
|
13
|
+
constructor(props: any);
|
|
14
|
+
protected initEvents(): void;
|
|
15
|
+
private rotateEvtHandler;
|
|
16
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import ICEComponent from '../../graphic/ICEComponent';
|
|
2
|
+
import ICEControlPanel from '../ICEControlPanel';
|
|
3
|
+
/**
|
|
4
|
+
* @class TransformControlPanel
|
|
5
|
+
*
|
|
6
|
+
* 变换控制面板
|
|
7
|
+
*
|
|
8
|
+
* - TransformControlPanel 本身总是直接画在 canvas 上,不是任何组件的孩子。
|
|
9
|
+
* - TransformControlPanel 是全局单例,在任意时刻,不可能同时出现多个 TransformControlPanel 的实例,因为在图形化的用户交互模式下,用户无法同时操控多个控制面板。
|
|
10
|
+
*
|
|
11
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
12
|
+
*/
|
|
13
|
+
export default class TransformControlPanel extends ICEControlPanel {
|
|
14
|
+
private rotateControlInstance;
|
|
15
|
+
private rotateControlSize;
|
|
16
|
+
private rotateControlffsetY;
|
|
17
|
+
private resizeControlInstanceCache;
|
|
18
|
+
private resizeControlSize;
|
|
19
|
+
constructor(props: any);
|
|
20
|
+
/**
|
|
21
|
+
* @method initControls
|
|
22
|
+
* 添加尺寸和旋转变换手柄,初始化时添加在内部的[0,0]位置,此方法只创建对象实例,不执行渲染操作。
|
|
23
|
+
* 创建 8 个 ResizeControl
|
|
24
|
+
* 计算手柄位于父组件的哪一个象限中,有以下取值:
|
|
25
|
+
* - 1: 第1象限;
|
|
26
|
+
* - 2: 第2象限;
|
|
27
|
+
* - 3: 第3象限;
|
|
28
|
+
* - 4: 第4象限;
|
|
29
|
+
* - 5: 位于X轴上方,y值为负,不属于任何象限;
|
|
30
|
+
* - 6: 位于X轴下方,y值为正,不属于任何象限;
|
|
31
|
+
* - 7: 位于Y轴左侧,x值为负,不属于任何象限;
|
|
32
|
+
* - 8: 位于Y轴右侧,x值为正,不属于任何象限;
|
|
33
|
+
* 默认创建顺序,从左上角开始顺时针:tl:2/t:5/tr:1/r:8/rb:4/b:6/lb:3/l:7
|
|
34
|
+
* 第1和第3象限可以交换位置
|
|
35
|
+
* 第2和第4象限可以交换位置
|
|
36
|
+
* X 轴正负可以交换位置
|
|
37
|
+
* Y 轴正负可以交换位置
|
|
38
|
+
* TODO:添加斜切手柄?
|
|
39
|
+
*/
|
|
40
|
+
protected initControls(): void;
|
|
41
|
+
protected initEvents(): void;
|
|
42
|
+
enable(): void;
|
|
43
|
+
disable(): void;
|
|
44
|
+
protected setControlPositions(): void;
|
|
45
|
+
private rotateEvtHandler;
|
|
46
|
+
private resizeEvtHandler;
|
|
47
|
+
protected updatePanel(): void;
|
|
48
|
+
set targetComponent(component: ICEComponent);
|
|
49
|
+
get targetComponent(): ICEComponent;
|
|
50
|
+
/**
|
|
51
|
+
* 交换两个 Control 的象限
|
|
52
|
+
* @param control
|
|
53
|
+
* @param quadrant
|
|
54
|
+
*/
|
|
55
|
+
toggleControlQuadrant(control: any, quadrant: number): void;
|
|
56
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import ICE from '../ICE';
|
|
2
|
+
/**
|
|
3
|
+
* @class DOMEventBridge
|
|
4
|
+
*
|
|
5
|
+
* 事件桥接器,把原生 DOM 事件转发给 canvas 内部的组件。
|
|
6
|
+
*
|
|
7
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
8
|
+
*/
|
|
9
|
+
declare class DOMEventBridge {
|
|
10
|
+
private selectionCandidates;
|
|
11
|
+
private ice;
|
|
12
|
+
private _stopped;
|
|
13
|
+
constructor(ice: ICE);
|
|
14
|
+
start(): this;
|
|
15
|
+
set stopped(flag: boolean);
|
|
16
|
+
get stopped(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* @method findTargetComponent
|
|
19
|
+
*
|
|
20
|
+
* 找到被点击的对象,用代码触发 click 事件。
|
|
21
|
+
* 在点击状态下,每次只能点击一个对象,当前不支持 DOM 冒泡特性。
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
private findTargetComponent;
|
|
26
|
+
}
|
|
27
|
+
export default DOMEventBridge;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 ICEEventTarget from './ICEEventTarget';
|
|
9
|
+
/**
|
|
10
|
+
* @class EventBus
|
|
11
|
+
* @singleton
|
|
12
|
+
*
|
|
13
|
+
* EventBus 事件总线。
|
|
14
|
+
*
|
|
15
|
+
* - canvas 标签内部没有事件机制,ICE 借助于 EventBus 把原生 DOM 事件转发到 canvas 内部(mouse/keyboard/touch),在转发过程中可能会把原生 DOM 事件转换成 ICEEvent 。
|
|
16
|
+
* - EventBus 是 ICEEventTarget 的实现类。
|
|
17
|
+
* - EventBus 是全局单例,同一个 ICE 实例上只能有一个事件总线的实例。
|
|
18
|
+
* - ICE 内部几乎所有机制都依赖事件总线来实现。
|
|
19
|
+
* - requestAnimationFrame 会利用事件总线触发 FRAME 事件。
|
|
20
|
+
*
|
|
21
|
+
* @see ICEEventTaregt
|
|
22
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
23
|
+
*/
|
|
24
|
+
declare class EventBus extends ICEEventTarget {
|
|
25
|
+
constructor(props?: any);
|
|
26
|
+
}
|
|
27
|
+
export default EventBus;
|
|
@@ -0,0 +1,46 @@
|
|
|
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 ICEEvent
|
|
10
|
+
*
|
|
11
|
+
* - 在 ICE 中,所有事件都会被转化成 ICEEvent 进行处理。
|
|
12
|
+
* - ICEEvent 用来模拟 W3C 定义的 Event 接口,ICE 自定义的事件也使用此实现,事件对象上能获取到的属性不同。
|
|
13
|
+
* - 从原始 DOM 事件转发出来的 ICEEvent 实例包含 Event 接口上所定义的所有属性,ICE 内部代码创建的 ICEEvent 实例上只包含很少的自定义属性。
|
|
14
|
+
* - 如果事件是从原始 DOM 事件包装而来,那么ICEEvent 实例的 originalEvent 属性是原始 DOM 事件对象,否则 originalEvent 属性为 null。
|
|
15
|
+
*
|
|
16
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event
|
|
17
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
18
|
+
*/
|
|
19
|
+
declare class ICEEvent implements Event {
|
|
20
|
+
originalEvent: any;
|
|
21
|
+
param: any;
|
|
22
|
+
constructor(evt?: any, data?: any);
|
|
23
|
+
bubbles: boolean;
|
|
24
|
+
cancelBubble: boolean;
|
|
25
|
+
cancelable: boolean;
|
|
26
|
+
composed: boolean;
|
|
27
|
+
currentTarget: EventTarget;
|
|
28
|
+
defaultPrevented: boolean;
|
|
29
|
+
eventPhase: number;
|
|
30
|
+
isTrusted: boolean;
|
|
31
|
+
returnValue: boolean;
|
|
32
|
+
srcElement: EventTarget;
|
|
33
|
+
target: EventTarget;
|
|
34
|
+
timeStamp: number;
|
|
35
|
+
type: string;
|
|
36
|
+
composedPath(): EventTarget[];
|
|
37
|
+
initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
|
|
38
|
+
preventDefault(): void;
|
|
39
|
+
stopImmediatePropagation(): void;
|
|
40
|
+
stopPropagation(): void;
|
|
41
|
+
AT_TARGET: number;
|
|
42
|
+
BUBBLING_PHASE: number;
|
|
43
|
+
CAPTURING_PHASE: number;
|
|
44
|
+
NONE: number;
|
|
45
|
+
}
|
|
46
|
+
export default ICEEvent;
|
|
@@ -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
|
+
}
|