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,45 @@
|
|
|
1
|
+
import ICEDotPath from '../ICEDotPath';
|
|
2
|
+
/**
|
|
3
|
+
* @class ICEStar
|
|
4
|
+
*
|
|
5
|
+
* 正 N 角星
|
|
6
|
+
*
|
|
7
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
8
|
+
*/
|
|
9
|
+
declare class ICEStar extends ICEDotPath {
|
|
10
|
+
constructor(props?: any);
|
|
11
|
+
/**
|
|
12
|
+
* @overwrite
|
|
13
|
+
* @method calcDots
|
|
14
|
+
*
|
|
15
|
+
* 计算路径上的关键点:
|
|
16
|
+
* - 默认的坐标原点是 (0,0) 位置。
|
|
17
|
+
* - 这些点没有经过 transform 矩阵变换。
|
|
18
|
+
*
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
protected calcDots(): any;
|
|
22
|
+
/**
|
|
23
|
+
* @overwrite
|
|
24
|
+
* @method calcComponentParams
|
|
25
|
+
* 计算原始的宽高、位置,此时没有经过任何变换,也没有移动坐标原点。
|
|
26
|
+
* 由于点状路径可能是不规则的形状,所以宽高需要手动计算,特殊形状的子类需要覆盖此方法提供自己的实现。
|
|
27
|
+
* 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
28
|
+
* @returns
|
|
29
|
+
*/
|
|
30
|
+
calcComponentParams(): {
|
|
31
|
+
width: any;
|
|
32
|
+
height: any;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* @overwrite
|
|
36
|
+
* @method setState
|
|
37
|
+
* setState 仅仅修改参数,不会立即导致重新渲染,需要等待 FrameManager 调度,最小延迟时间约为 1/60=16.67 ms 。
|
|
38
|
+
*
|
|
39
|
+
* - 如果 setState 时指定了 radius 参数,则 width 会被重新计算,如果指定了 radius 参数则 height 会被重新计算。
|
|
40
|
+
* - 如果 setState 时仅仅指定 width 参数,则 radius 会被重新计算,如果仅仅指定了 height 参数,则 radius 会被重新计算。
|
|
41
|
+
* @param newState
|
|
42
|
+
*/
|
|
43
|
+
setState(newState: any): void;
|
|
44
|
+
}
|
|
45
|
+
export default ICEStar;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import ICEComponent from '../ICEComponent';
|
|
2
|
+
/**
|
|
3
|
+
* TODO:draw text along Path2D
|
|
4
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
5
|
+
*/
|
|
6
|
+
declare class ICEText extends ICEComponent {
|
|
7
|
+
/**
|
|
8
|
+
* @cfg
|
|
9
|
+
* {
|
|
10
|
+
* text:'文本内容',
|
|
11
|
+
* left:0,
|
|
12
|
+
* top:0,
|
|
13
|
+
* style:{
|
|
14
|
+
* fontSize:48,
|
|
15
|
+
* fontFamily:'Arial',
|
|
16
|
+
* fontWeight:24,
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* @param props
|
|
20
|
+
*/
|
|
21
|
+
constructor(props?: any);
|
|
22
|
+
protected initEvents(): void;
|
|
23
|
+
/**
|
|
24
|
+
* @method measureText
|
|
25
|
+
*
|
|
26
|
+
* - Canvas 中没有提供原生的计算文本高度的有效方法,文本宽高的计算需要使用特殊的方法,这里使用的方法来自 https://longviewcoder.com/2021/02/11/html5-canvas-text-line-height-measurement/
|
|
27
|
+
* - 计算原始的宽高、位置,此时没有经过任何变换,也没有移动坐标原点。
|
|
28
|
+
* - 在计算组件的原始尺寸时还没有确定原点坐标,所以只能基于组件本地坐标系的左上角 (0,0) 点进行计算。
|
|
29
|
+
*
|
|
30
|
+
* FIXME:某些运行时环境可能不支持动态插入 HTML 标签,以上测量文本宽高的方法可能存在兼容性问题。
|
|
31
|
+
* FIXME:对文本位置的控制需要更精细的计算方法。
|
|
32
|
+
*/
|
|
33
|
+
private measureText;
|
|
34
|
+
/**
|
|
35
|
+
* @method doRender
|
|
36
|
+
* @overwrite
|
|
37
|
+
* 文本是基于 baseline 绘制的,文本是从 y 坐标向屏幕上方绘制的,48 是文本高度,这里需要补偿文本高度。
|
|
38
|
+
* 同时把移动坐标轴原点的偏移量计算进去。
|
|
39
|
+
*/
|
|
40
|
+
protected doRender(): void;
|
|
41
|
+
}
|
|
42
|
+
export default ICEText;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 as AnimationManager } from './animation/AnimationManager';
|
|
9
|
+
export { default as ICEControlPanel } from './control-panel/ICEControlPanel';
|
|
10
|
+
export { default as ICEControlPanelManager } from './control-panel/ICEControlPanelManager';
|
|
11
|
+
export { default as LineControlPanel } from './control-panel/link-controls/LineControlPanel';
|
|
12
|
+
export { default as ResizeControl } from './control-panel/transform-controls/ResizeControl';
|
|
13
|
+
export { default as RotateControl } from './control-panel/transform-controls/RotateControl';
|
|
14
|
+
export { default as TransformControlPanel } from './control-panel/transform-controls/TransformControlPanel';
|
|
15
|
+
export { default as DOMEventBridge } from './event/DOMEventBridge';
|
|
16
|
+
export { default as EventBus } from './event/EventBus';
|
|
17
|
+
export { default as ICEEventTarget } from './event/ICEEventTarget';
|
|
18
|
+
export { default as GeoLine } from './geometry/GeoLine';
|
|
19
|
+
export { default as GeoPoint } from './geometry/GeoPoint';
|
|
20
|
+
export { default as GeoUtil } from './geometry/GeoUtil';
|
|
21
|
+
export { default as ICEBoundingBox } from './geometry/ICEBoundingBox';
|
|
22
|
+
export { default as ICEMatrix } from './geometry/ICEMatrix';
|
|
23
|
+
export { default as ICEGroup } from './graphic/container/ICEGroup';
|
|
24
|
+
export { default as ICEComponent } from './graphic/ICEComponent';
|
|
25
|
+
export { default as ICEDotPath } from './graphic/ICEDotPath';
|
|
26
|
+
export { default as ICEImage } from './graphic/ICEImage';
|
|
27
|
+
export { default as ICEPath } from './graphic/ICEPath';
|
|
28
|
+
export { default as ICEBezier } from './graphic/line/ICEBezier';
|
|
29
|
+
export { default as ICEPolyLine } from './graphic/line/ICEPolyLine';
|
|
30
|
+
export { default as ICELinkHook } from './graphic/link/ICELinkHook';
|
|
31
|
+
export { default as ICELinkSlot } from './graphic/link/ICELinkSlot';
|
|
32
|
+
export { default as ICEVisioLink } from './graphic/link/ICEVisioLink';
|
|
33
|
+
export { default as ICECircle } from './graphic/shape/ICECircle';
|
|
34
|
+
export { default as ICEEllipse } from './graphic/shape/ICEEllipse';
|
|
35
|
+
export { default as ICEIsogon } from './graphic/shape/ICEIsogon';
|
|
36
|
+
export { default as ICERect } from './graphic/shape/ICERect';
|
|
37
|
+
export { default as ICERose } from './graphic/shape/ICERose';
|
|
38
|
+
export { default as ICEStar } from './graphic/shape/ICEStar';
|
|
39
|
+
export { default as ICEText } from './graphic/text/ICEText';
|
|
40
|
+
export { default as ICE } from './ICE';
|
|
41
|
+
export { default as CanvasRenderer } from './renderer/CanvasRenderer';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class Serializer
|
|
3
|
+
*
|
|
4
|
+
* 把图形序列化成 JSON 字符串。
|
|
5
|
+
*
|
|
6
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
7
|
+
*/
|
|
8
|
+
export default class Serializer {
|
|
9
|
+
private ice;
|
|
10
|
+
constructor(ice: any);
|
|
11
|
+
/**
|
|
12
|
+
* 把对象序列化成 JSON 字符串:
|
|
13
|
+
* - 容器型组件需要负责子节点的序列化操作
|
|
14
|
+
* - 如果组件不需要序列化,需要返回 null
|
|
15
|
+
* @returns JSONObject
|
|
16
|
+
*/
|
|
17
|
+
toJSON(): string;
|
|
18
|
+
private encodeRecursively;
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import ICEEventTarget from '../event/ICEEventTarget';
|
|
2
|
+
import ICE from '../ICE';
|
|
3
|
+
/**
|
|
4
|
+
* @class CanvasRenderer
|
|
5
|
+
*
|
|
6
|
+
* Canvas 渲染器
|
|
7
|
+
*
|
|
8
|
+
* - 一个 ICE 实例上,只能有一个渲染器实例。
|
|
9
|
+
*
|
|
10
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
11
|
+
*/
|
|
12
|
+
declare class CanvasRenderer extends ICEEventTarget {
|
|
13
|
+
private ice;
|
|
14
|
+
private stopped;
|
|
15
|
+
private componentQueue;
|
|
16
|
+
private toolsQueue;
|
|
17
|
+
constructor(ice: ICE);
|
|
18
|
+
start(): this;
|
|
19
|
+
stop(): this;
|
|
20
|
+
private frameEvtHandler;
|
|
21
|
+
private refreshQueue;
|
|
22
|
+
private doRender;
|
|
23
|
+
}
|
|
24
|
+
export default CanvasRenderer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ICE from '../ICE';
|
|
2
|
+
/**
|
|
3
|
+
* @class ImageCache
|
|
4
|
+
* 图片缓存类
|
|
5
|
+
* @author 大漠穷秋<damoqiongqiu@126.com>
|
|
6
|
+
*/
|
|
7
|
+
export default class ImageCache {
|
|
8
|
+
private ice;
|
|
9
|
+
static readonly CACHE_SIZE = 100;
|
|
10
|
+
imageCache: Map<any, any>;
|
|
11
|
+
constructor(ice: ICE);
|
|
12
|
+
setImage(url: string): {
|
|
13
|
+
loaded: boolean;
|
|
14
|
+
image: any;
|
|
15
|
+
};
|
|
16
|
+
private loaded;
|
|
17
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按照指定的路径获取 Object 上的值
|
|
3
|
+
* @param {*} object
|
|
4
|
+
* @param {*} path
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export function getVal(object: any, path: any): any;
|
|
8
|
+
/**
|
|
9
|
+
* @method flattenTree
|
|
10
|
+
*
|
|
11
|
+
* 把 tree 形结构拉平成数组结构。
|
|
12
|
+
*
|
|
13
|
+
* @param result
|
|
14
|
+
* @param childNodes
|
|
15
|
+
* @param level
|
|
16
|
+
* @param pid
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export function flattenTree(result?: any[], childNodes?: any[], level?: number, pid?: any): any[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* !gl-matrix 的当前版本中没有提供 skew 函数,需要手动合 https://github.com/toji/gl-matrix/pull/293
|
|
3
|
+
* @see https://github.com/talltyler/gl-matrix/commit/7c408d649073f6240f4694041ceb2af5f5284658
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Skew (shear) a mat2d by the given angle
|
|
7
|
+
*
|
|
8
|
+
* @param {mat2d} out the receiving matrix
|
|
9
|
+
* @param {mat2d} a the matrix to skew
|
|
10
|
+
* @param {Number} rad the angle to skew the matrix by
|
|
11
|
+
* @param {Number} rad the angle to skew the matrix by
|
|
12
|
+
* @returns {mat2d} out
|
|
13
|
+
*/
|
|
14
|
+
export function skew(out: mat2d, a: mat2d, radX: any, radY: any): mat2d;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function uuid(): any;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "大漠穷秋",
|
|
3
3
|
"name": "ice-render",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.9",
|
|
5
5
|
"description": "A canvas engine for interactive graphics.",
|
|
6
6
|
"repository": "https://gitee.com/ice-render/ice-render",
|
|
7
7
|
"browser": "dist/index.umd.js",
|
|
@@ -9,10 +9,7 @@
|
|
|
9
9
|
"module": "dist/index.js",
|
|
10
10
|
"types": "dist/types/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
|
-
"dist
|
|
13
|
-
"dist/*.map",
|
|
14
|
-
"dist/**/*.js",
|
|
15
|
-
"dist/**/*.map"
|
|
12
|
+
"dist/**/*"
|
|
16
13
|
],
|
|
17
14
|
"scripts": {
|
|
18
15
|
"start": "rollup -c -w --environment NODE_ENV:development",
|