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,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class FrameManager
|
|
3
|
+
*
|
|
4
|
+
* 帧频控制器,全局单例,请勿创建多个实例。
|
|
5
|
+
* 在同一个 window/global 中,只有一个 FrameManager ,也就是说 FrameManager 是跨 ICE 实例共享的。
|
|
6
|
+
* FrameManager 只负责把 window/global 上的 requestAnimationFrame 回调函数转换成 ICE_EVENT_NAME_CONSTS.ICE_FRAME_EVENT 事件,然后在所有事件总线上进行触发。
|
|
7
|
+
* FrameManager 只触发事件,不进行渲染,渲染操作由对应的 Render 完成。
|
|
8
|
+
*
|
|
9
|
+
* @singleton
|
|
10
|
+
* @see ICE
|
|
11
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
12
|
+
*/
|
|
13
|
+
declare const FrameManager: {
|
|
14
|
+
evtBuses: any[];
|
|
15
|
+
stopped: boolean;
|
|
16
|
+
frameCallback: () => void;
|
|
17
|
+
start: () => void;
|
|
18
|
+
stop: () => void;
|
|
19
|
+
pause: () => void;
|
|
20
|
+
resume: () => void;
|
|
21
|
+
regitserEvtBus: (evtBus: any) => void;
|
|
22
|
+
delEvtBus: (evtBus: any) => void;
|
|
23
|
+
};
|
|
24
|
+
export default FrameManager;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import AnimationManager from './animation/AnimationManager';
|
|
2
|
+
import DDManager from './control-panel/DDManager';
|
|
3
|
+
import ICEControlPanelManager from './control-panel/ICEControlPanelManager';
|
|
4
|
+
import DOMEventBridge from './event/DOMEventBridge';
|
|
5
|
+
import EventBus from './event/EventBus';
|
|
6
|
+
import ICEComponent from './graphic/ICEComponent';
|
|
7
|
+
import ICELinkSlotManager from './graphic/link/ICELinkSlotManager';
|
|
8
|
+
import Deserializer from './persistence/Deserializer';
|
|
9
|
+
import Serializer from './persistence/Serializer';
|
|
10
|
+
import ImageCache from './util/ImageCache';
|
|
11
|
+
/**
|
|
12
|
+
* @class ICE
|
|
13
|
+
*
|
|
14
|
+
* ICE: Interactive Canvas Engine , 交互式 canvas 渲染引擎。
|
|
15
|
+
*
|
|
16
|
+
* - ICE 是整个引擎的主入口类。
|
|
17
|
+
* - 同一个 <canvas> 标签上只能初始化一个 ICE 实例。
|
|
18
|
+
*
|
|
19
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
20
|
+
*/
|
|
21
|
+
declare class ICE {
|
|
22
|
+
childNodes: any[];
|
|
23
|
+
toolNodes: any[];
|
|
24
|
+
evtBus: EventBus;
|
|
25
|
+
root: any;
|
|
26
|
+
canvasEl: any;
|
|
27
|
+
ctx: any;
|
|
28
|
+
canvasWidth: number;
|
|
29
|
+
canvasHeight: number;
|
|
30
|
+
canvasBoundingClientRect: any;
|
|
31
|
+
selectionList: Array<any>;
|
|
32
|
+
renderer: any;
|
|
33
|
+
animationManager: AnimationManager;
|
|
34
|
+
eventBridge: DOMEventBridge;
|
|
35
|
+
ddManager: DDManager;
|
|
36
|
+
controlPanelManager: ICEControlPanelManager;
|
|
37
|
+
linkSlotManager: ICELinkSlotManager;
|
|
38
|
+
serializer: Serializer;
|
|
39
|
+
deserializer: Deserializer;
|
|
40
|
+
imageCache: ImageCache;
|
|
41
|
+
private __dirty;
|
|
42
|
+
constructor();
|
|
43
|
+
/**
|
|
44
|
+
* @param ctx DOM id or CanvasContext
|
|
45
|
+
*/
|
|
46
|
+
init(ctx: any): this;
|
|
47
|
+
/**
|
|
48
|
+
* @method addChild
|
|
49
|
+
* 添加交互工具组件。
|
|
50
|
+
* 工具组件不触发事件,不产生动画效果。
|
|
51
|
+
* @param {ICEComponent} tool
|
|
52
|
+
*/
|
|
53
|
+
addTool(tool: ICEComponent): void;
|
|
54
|
+
/**
|
|
55
|
+
* @methos removeTool
|
|
56
|
+
* 删除交互工具组件。
|
|
57
|
+
* 工具组件不触发事件,不产生动画效果。
|
|
58
|
+
* @param tool
|
|
59
|
+
*/
|
|
60
|
+
removeTool(tool: ICEComponent): void;
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* 调用 ICE.addChild() 方法,会直接把对象画在 canvas 上。
|
|
64
|
+
* 如果需要在容器中画组件,参见 @see ICEGroup.addChild() 方法
|
|
65
|
+
*
|
|
66
|
+
* @param component
|
|
67
|
+
*/
|
|
68
|
+
addChild(component: any, markDirty?: boolean): void;
|
|
69
|
+
addChildren(arr: Array<ICEComponent>): void;
|
|
70
|
+
removeChild(component: ICEComponent, markDirty?: boolean): void;
|
|
71
|
+
removeChildren(arr: Array<ICEComponent>): void;
|
|
72
|
+
clearAll(): void;
|
|
73
|
+
findComponent(id: string): any;
|
|
74
|
+
protected _lastUpdateTime: number;
|
|
75
|
+
set dirty(flag: boolean);
|
|
76
|
+
get dirty(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* 把对象序列化成 JSON 字符串:
|
|
79
|
+
* - 容器型组件需要负责子节点的序列化操作
|
|
80
|
+
* - 如果组件不需要序列化,需要返回 null
|
|
81
|
+
* @returns JSONObject
|
|
82
|
+
*/
|
|
83
|
+
toJSON(): string;
|
|
84
|
+
fromJSON(jsonStr: string): void;
|
|
85
|
+
}
|
|
86
|
+
export default ICE;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ICEComponent from '../graphic/ICEComponent';
|
|
2
|
+
import ICE from '../ICE';
|
|
3
|
+
/**
|
|
4
|
+
* @class AnimationManager
|
|
5
|
+
*
|
|
6
|
+
* 动画管理器
|
|
7
|
+
*
|
|
8
|
+
* - 全局单例,一个 ICE 实例上只能有一个 AnimationManager 的实例。
|
|
9
|
+
*
|
|
10
|
+
* @singleton
|
|
11
|
+
* @see ICE
|
|
12
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
13
|
+
*/
|
|
14
|
+
declare class AnimationManager {
|
|
15
|
+
private animationMap;
|
|
16
|
+
private ice;
|
|
17
|
+
constructor(ice: ICE);
|
|
18
|
+
start(): this;
|
|
19
|
+
stop(): this;
|
|
20
|
+
private frameEventHandler;
|
|
21
|
+
private tween;
|
|
22
|
+
add(component: ICEComponent): void;
|
|
23
|
+
remove(el: any): void;
|
|
24
|
+
}
|
|
25
|
+
export default AnimationManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
* 来源:https://github.com/AndrewRayCode/easing-utils/blob/master/src/easing.js
|
|
10
|
+
* 一组缓动工具函数
|
|
11
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
12
|
+
*/
|
|
13
|
+
declare const Easing: {
|
|
14
|
+
/**
|
|
15
|
+
* 线性变化
|
|
16
|
+
* @param from 起始值
|
|
17
|
+
* @param to 终止值
|
|
18
|
+
* @param duration 持续时间,ms
|
|
19
|
+
* @param startTime 动画开始时间
|
|
20
|
+
*/
|
|
21
|
+
linear: (from: number, to: number, duration: number, startTime: number) => number;
|
|
22
|
+
easeInQuad: (from: number, to: number, duration: number, startTime: number) => number;
|
|
23
|
+
easeOutQuad: (from: number, to: number, duration: number, startTime: number) => number;
|
|
24
|
+
easeInOutQuad: (from: number, to: number, duration: number, startTime: number) => number;
|
|
25
|
+
easeInQuart: (from: number, to: number, duration: number, startTime: number) => number;
|
|
26
|
+
easeOutQuart: (from: number, to: number, duration: number, startTime: number) => number;
|
|
27
|
+
easeInOutQuart: (from: number, to: number, duration: number, startTime: number) => number;
|
|
28
|
+
easeInCubic: (from: number, to: number, duration: number, startTime: number) => number;
|
|
29
|
+
easeOutCubic: (from: number, to: number, duration: number, startTime: number) => number;
|
|
30
|
+
easeInOutCubic: (from: number, to: number, duration: number, startTime: number) => number;
|
|
31
|
+
};
|
|
32
|
+
export default Easing;
|
|
@@ -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;
|