@netless/appliance-plugin 1.0.0-beta.0

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.
Files changed (128) hide show
  1. package/README.md +138 -0
  2. package/cdn/appliance-plugin.js +1 -0
  3. package/cdn/appliance-plugin.mjs +8639 -0
  4. package/cdn/style.css +1 -0
  5. package/dist/appliance-plugin.js +1 -0
  6. package/dist/appliance-plugin.mjs +8639 -0
  7. package/dist/collector/base.d.ts +20 -0
  8. package/dist/collector/collector.d.ts +53 -0
  9. package/dist/collector/const.d.ts +3 -0
  10. package/dist/collector/enum.d.ts +13 -0
  11. package/dist/collector/eventCollector.d.ts +29 -0
  12. package/dist/collector/index.d.ts +4 -0
  13. package/dist/collector/types.d.ts +70 -0
  14. package/dist/collector/utils/color.d.ts +31 -0
  15. package/dist/collector/utils/index.d.ts +5 -0
  16. package/dist/component/textEditor/index.d.ts +2 -0
  17. package/dist/component/textEditor/manager.d.ts +120 -0
  18. package/dist/component/textEditor/types.d.ts +50 -0
  19. package/dist/component/textEditor/utils.d.ts +3 -0
  20. package/dist/component/textEditor/view.d.ts +68 -0
  21. package/dist/core/const.d.ts +1 -0
  22. package/dist/core/enum.d.ts +135 -0
  23. package/dist/core/index.d.ts +3 -0
  24. package/dist/core/mainEngine.d.ts +163 -0
  25. package/dist/core/msgEvent/activeZIndex/forMain.d.ts +12 -0
  26. package/dist/core/msgEvent/activeZIndex/forWorker.d.ts +8 -0
  27. package/dist/core/msgEvent/base.d.ts +18 -0
  28. package/dist/core/msgEvent/baseForWorker.d.ts +13 -0
  29. package/dist/core/msgEvent/copyNode/forMain.d.ts +47 -0
  30. package/dist/core/msgEvent/copyNode/forWorker.d.ts +8 -0
  31. package/dist/core/msgEvent/deleteNode/forMain.d.ts +11 -0
  32. package/dist/core/msgEvent/deleteNode/forWorker.d.ts +13 -0
  33. package/dist/core/msgEvent/forWorker.d.ts +14 -0
  34. package/dist/core/msgEvent/index.d.ts +15 -0
  35. package/dist/core/msgEvent/rotateNode/forMain.d.ts +16 -0
  36. package/dist/core/msgEvent/rotateNode/forWorker.d.ts +9 -0
  37. package/dist/core/msgEvent/scaleNode/forMain.d.ts +20 -0
  38. package/dist/core/msgEvent/scaleNode/forWorker.d.ts +9 -0
  39. package/dist/core/msgEvent/setColor/forMain.d.ts +18 -0
  40. package/dist/core/msgEvent/setColor/forWorker.d.ts +9 -0
  41. package/dist/core/msgEvent/setFont/forMain.d.ts +18 -0
  42. package/dist/core/msgEvent/setFont/forWorker.d.ts +9 -0
  43. package/dist/core/msgEvent/setLock/forMain.d.ts +12 -0
  44. package/dist/core/msgEvent/setLock/forWorker.d.ts +9 -0
  45. package/dist/core/msgEvent/setPoint/forMain.d.ts +15 -0
  46. package/dist/core/msgEvent/setPoint/forWorker.d.ts +9 -0
  47. package/dist/core/msgEvent/setShape/forMain.d.ts +18 -0
  48. package/dist/core/msgEvent/setShape/forWorker.d.ts +9 -0
  49. package/dist/core/msgEvent/setZIndex/forMain.d.ts +22 -0
  50. package/dist/core/msgEvent/setZIndex/forWorker.d.ts +9 -0
  51. package/dist/core/msgEvent/translateNode/forMain.d.ts +20 -0
  52. package/dist/core/msgEvent/translateNode/forWorker.d.ts +9 -0
  53. package/dist/core/tools/arrow.d.ts +46 -0
  54. package/dist/core/tools/base.d.ts +82 -0
  55. package/dist/core/tools/ellipse.d.ts +44 -0
  56. package/dist/core/tools/eraser.d.ts +41 -0
  57. package/dist/core/tools/image.d.ts +53 -0
  58. package/dist/core/tools/index.d.ts +13 -0
  59. package/dist/core/tools/laserPen.d.ts +42 -0
  60. package/dist/core/tools/pencil.d.ts +66 -0
  61. package/dist/core/tools/polygon.d.ts +45 -0
  62. package/dist/core/tools/rectangle.d.ts +46 -0
  63. package/dist/core/tools/selector.d.ts +83 -0
  64. package/dist/core/tools/speechBalloon.d.ts +49 -0
  65. package/dist/core/tools/star.d.ts +47 -0
  66. package/dist/core/tools/straight.d.ts +46 -0
  67. package/dist/core/tools/text.d.ts +42 -0
  68. package/dist/core/tools/utils.d.ts +39 -0
  69. package/dist/core/types.d.ts +295 -0
  70. package/dist/core/utils/bezier.d.ts +43 -0
  71. package/dist/core/utils/getSvgPathFromPoints.d.ts +10 -0
  72. package/dist/core/utils/index.d.ts +364 -0
  73. package/dist/core/utils/math.d.ts +57 -0
  74. package/dist/core/utils/primitives/Box2d.d.ts +100 -0
  75. package/dist/core/utils/primitives/Point2d.d.ts +71 -0
  76. package/dist/core/utils/primitives/Vec2d.d.ts +146 -0
  77. package/dist/core/utils/primitives/easings.d.ts +24 -0
  78. package/dist/core/utils/proxy.d.ts +21 -0
  79. package/dist/core/utils/spriteNode.d.ts +4 -0
  80. package/dist/core/worker/base.d.ts +103 -0
  81. package/dist/core/worker/fullWorker.d.ts +1 -0
  82. package/dist/core/worker/fullWorkerLocal.d.ts +46 -0
  83. package/dist/core/worker/fullWorkerService.d.ts +41 -0
  84. package/dist/core/worker/subWorker.d.ts +1 -0
  85. package/dist/core/worker/subWorkerLocal.d.ts +20 -0
  86. package/dist/core/worker/vNodeManager.d.ts +32 -0
  87. package/dist/core/worker/workerManager.d.ts +71 -0
  88. package/dist/cursors/index.d.ts +73 -0
  89. package/dist/displayer/const.d.ts +11 -0
  90. package/dist/displayer/cursor/index.d.ts +15 -0
  91. package/dist/displayer/floatBar/index.d.ts +10 -0
  92. package/dist/displayer/floatBtns/colors.d.ts +6 -0
  93. package/dist/displayer/floatBtns/del.d.ts +6 -0
  94. package/dist/displayer/floatBtns/duplicate.d.ts +5 -0
  95. package/dist/displayer/floatBtns/fontSize.d.ts +4 -0
  96. package/dist/displayer/floatBtns/fontStyle.d.ts +4 -0
  97. package/dist/displayer/floatBtns/index.d.ts +11 -0
  98. package/dist/displayer/floatBtns/layer.d.ts +3 -0
  99. package/dist/displayer/floatBtns/lock.d.ts +7 -0
  100. package/dist/displayer/floatBtns/shapeOpt.d.ts +3 -0
  101. package/dist/displayer/highlightBox/index.d.ts +5 -0
  102. package/dist/displayer/icons/index.d.ts +4 -0
  103. package/dist/displayer/resizable/index.d.ts +16 -0
  104. package/dist/displayer/rotate/index.d.ts +4 -0
  105. package/dist/displayer/types.d.ts +51 -0
  106. package/dist/hotkey/index.d.ts +51 -0
  107. package/dist/index.d.ts +1 -0
  108. package/dist/members/index.d.ts +15 -0
  109. package/dist/plugin/applianceMultiPlugin.d.ts +24 -0
  110. package/dist/plugin/applianceSinglePlugin.d.ts +28 -0
  111. package/dist/plugin/baseApplianceManager.d.ts +82 -0
  112. package/dist/plugin/baseViewContainerManager.d.ts +174 -0
  113. package/dist/plugin/displayerView.d.ts +55 -0
  114. package/dist/plugin/external.d.ts +2 -0
  115. package/dist/plugin/index.d.ts +6 -0
  116. package/dist/plugin/multi/applianceMultiManager.d.ts +14 -0
  117. package/dist/plugin/multi/containerManager.d.ts +24 -0
  118. package/dist/plugin/multi/displayer/appViewDisplayerManager.d.ts +24 -0
  119. package/dist/plugin/multi/displayer/mainViewDisplayerManager.d.ts +25 -0
  120. package/dist/plugin/single/applianceDisplayer.d.ts +16 -0
  121. package/dist/plugin/single/applianceSingleManager.d.ts +13 -0
  122. package/dist/plugin/single/containerManager.d.ts +11 -0
  123. package/dist/plugin/single/displayer/mainViewDisplayerManager.d.ts +25 -0
  124. package/dist/plugin/types.d.ts +310 -0
  125. package/dist/plugin/utils.d.ts +6 -0
  126. package/dist/style.css +1 -0
  127. package/dist/undo/index.d.ts +70 -0
  128. package/package.json +59 -0
@@ -0,0 +1,42 @@
1
+ import { Group, Label, Polyline } from "spritejs";
2
+ import { BaseNodeMapItem, IMainMessage, IRectType, IUpdateNodeOpt } from "../types";
3
+ import { EScaleType, EToolsKey } from "../enum";
4
+ import { Point2d } from "../utils/primitives/Point2d";
5
+ import { BaseShapeTool, BaseShapeToolProps } from "./base";
6
+ import { TextOptions } from "../../component/textEditor";
7
+ import { ShapeNodes } from "./utils";
8
+ import { VNodeManager } from "../worker/vNodeManager";
9
+ export declare class TextShape extends BaseShapeTool {
10
+ readonly canRotate: boolean;
11
+ readonly scaleType: EScaleType;
12
+ readonly toolsType: EToolsKey;
13
+ protected tmpPoints: Array<Point2d>;
14
+ protected workOptions: TextOptions;
15
+ oldRect?: IRectType;
16
+ constructor(props: BaseShapeToolProps);
17
+ consume(): IMainMessage;
18
+ consumeAll(): IMainMessage;
19
+ private draw;
20
+ consumeService(props: {
21
+ isFullWork: boolean;
22
+ replaceId?: string;
23
+ isDrawLabel?: boolean;
24
+ }): IRectType | undefined;
25
+ updataOptService(updateNodeOpt: IUpdateNodeOpt): IRectType | undefined;
26
+ clearTmpPoints(): void;
27
+ static getFontWidth(param: {
28
+ text: string;
29
+ ctx: OffscreenCanvasRenderingContext2D;
30
+ opt: TextOptions;
31
+ worldScaling: number[];
32
+ }): number;
33
+ static createLabels(textOpt: TextOptions, layer: Group): (Polyline | Label)[];
34
+ static updateNodeOpt(param: {
35
+ node: ShapeNodes;
36
+ opt: IUpdateNodeOpt;
37
+ vNodes: VNodeManager;
38
+ willSerializeData?: boolean;
39
+ targetNode?: BaseNodeMapItem;
40
+ }): IRectType | undefined;
41
+ static getRectFromLayer(layer: Group, name: string): IRectType | undefined;
42
+ }
@@ -0,0 +1,39 @@
1
+ import { EPostMessageType, EToolsKey } from "../enum";
2
+ import { IRectType } from "../types";
3
+ import type { Ellipse, Group, Path, Polyline, Rect, Sprite } from "spritejs";
4
+ import { PencilOptions, PencilShape } from "./pencil";
5
+ import { LaserPenOptions, LaserPenShape } from "./laserPen";
6
+ import { EraserOptions, EraserShape } from "./eraser";
7
+ import { StarOptions, StarShape } from "./star";
8
+ import { SelectorOptions, SelectorShape } from "./selector";
9
+ import { ArrowOptions, ArrowShape } from "./arrow";
10
+ import { StraightOptions, StraightShape } from "./straight";
11
+ import { EllipseOptions, EllipseShape } from "./ellipse";
12
+ import { PolygonOptions, PolygonShape } from "./polygon";
13
+ import { RectangleOptions, RectangleShape } from "./rectangle";
14
+ import { VNodeManager } from "../worker/vNodeManager";
15
+ import { SpeechBalloonOptions, SpeechBalloonShape } from "./speechBalloon";
16
+ import { TextShape } from "./text";
17
+ import { TextOptions } from "../../component/textEditor";
18
+ import { ImageOptions, ImageShape } from "./image";
19
+ import type { ServiceWorkForFullWorker } from "../worker/fullWorkerService";
20
+ export type ShapeTools = typeof PencilShape | typeof LaserPenShape | typeof EraserShape | typeof StarShape | typeof SelectorShape | typeof ArrowShape | typeof EllipseShape | typeof RectangleShape | typeof StarShape | typeof PolygonShape | typeof TextShape | typeof SpeechBalloonShape | typeof ImageShape;
21
+ export type ShapeOptions = PencilOptions | LaserPenOptions | EraserOptions | StarOptions | SelectorOptions | ArrowOptions | EllipseOptions | RectangleOptions | StarOptions | PolygonOptions | StraightOptions | TextOptions | SpeechBalloonOptions | ImageOptions;
22
+ export type ShapeNodes = Group | Path | Polyline | Rect | Ellipse | Sprite;
23
+ export interface CombineConsumeResult {
24
+ type: EPostMessageType;
25
+ rect: IRectType | undefined;
26
+ consumeIndex: number;
27
+ }
28
+ export interface ShapeStateInfo {
29
+ willClear: boolean;
30
+ }
31
+ export declare function getShapeTools(toolsType: EToolsKey): typeof PencilShape | typeof LaserPenShape | typeof ArrowShape | typeof StraightShape | typeof EllipseShape | typeof PolygonShape | typeof StarShape | typeof RectangleShape | typeof SpeechBalloonShape | typeof TextShape | typeof EraserShape | typeof SelectorShape | typeof ImageShape | undefined;
32
+ export declare function getShapeInstance(param: {
33
+ toolsType: EToolsKey;
34
+ toolsOpt: ShapeOptions;
35
+ vNodes: VNodeManager;
36
+ fullLayer: Group;
37
+ drawLayer?: Group;
38
+ }, serviceWork?: ServiceWorkForFullWorker): SelectorShape | PencilShape | LaserPenShape | ArrowShape | StraightShape | EllipseShape | PolygonShape | StarShape | RectangleShape | SpeechBalloonShape | TextShape | EraserShape | ImageShape | undefined;
39
+ export declare function findShapeBody(nodes: ShapeNodes[]): ShapeNodes[];
@@ -0,0 +1,295 @@
1
+ import type { Scene } from 'spritejs';
2
+ import { BaseCollectorReducerAction, INormalPushMsg, ISerializableStorageData } from '../collector/types';
3
+ import { ETextEditorType, FontStyleType, FontWeightType, TextOptions } from '../component/textEditor/types';
4
+ import { EmitEventType } from '../plugin/types';
5
+ import { ECanvasContextType, ECanvasShowType, EDataType, EPostMessageType, EScaleType, EToolsKey, ElayerType, EvevtWorkState } from './enum';
6
+ import { BaseShapeOptions, BaseShapeTool, ShapeOptions } from './tools';
7
+ import type { SelectorShape } from './tools';
8
+ import type { Direction } from "re-resizable/lib/resizer";
9
+ import { ShapeOptType } from '../displayer/types';
10
+ export type IworkId = string | number;
11
+ export type IqueryTask = Partial<IWorkerMessage> | undefined;
12
+ export type ViewWorkerOptions = {
13
+ offscreenCanvasOpt: IOffscreenCanvasOptionType;
14
+ layerOpt: ILayerOptionType;
15
+ dpr: number;
16
+ originalPoint: [number, number];
17
+ cameraOpt: ICameraOpt;
18
+ };
19
+ export interface ICanvasSceneType {
20
+ /** canvas 上下文 */
21
+ /** canvas 宽度 */
22
+ width: number;
23
+ /** canvas 高度 */
24
+ height: number;
25
+ /** canvas */
26
+ canvas: HTMLCanvasElement;
27
+ }
28
+ export interface IOffscreenCanvasOptionType {
29
+ /** offscreenCanvas 宽度 */
30
+ width: number;
31
+ /** offscreenCanvas 高度 */
32
+ height: number;
33
+ /** 上下文类型,默认webgl2 */
34
+ contextType?: ECanvasContextType;
35
+ /** 是否自动渲染,默认自动渲染 */
36
+ autoRender?: boolean;
37
+ /** 缓冲区大小,默认1500 */
38
+ bufferSize?: number;
39
+ [key: string]: any;
40
+ }
41
+ export interface ILayerOptionType {
42
+ offscreen?: boolean;
43
+ handleEvent?: boolean;
44
+ depth?: boolean;
45
+ width: number;
46
+ height: number;
47
+ bufferSize?: number;
48
+ }
49
+ export interface IUpdateNodeOpt {
50
+ scale?: [number, number];
51
+ box?: {
52
+ x: number;
53
+ y: number;
54
+ w: number;
55
+ h: number;
56
+ };
57
+ dir?: Direction;
58
+ translate?: [number, number];
59
+ selectorColor?: string;
60
+ strokeColor?: string;
61
+ fillColor?: string;
62
+ fontColor?: string;
63
+ fontBgColor?: string;
64
+ isOpacity?: boolean;
65
+ pos?: [number, number];
66
+ workState?: EvevtWorkState;
67
+ useAnimation?: boolean;
68
+ zIndex?: number;
69
+ zIndexLayer?: ElayerType;
70
+ originPos?: [number, number];
71
+ ops?: string;
72
+ angle?: number;
73
+ centralPoint?: [number, number];
74
+ selectScale?: number[];
75
+ boxScale?: [number, number];
76
+ boxTranslate?: [number, number];
77
+ bold?: FontWeightType;
78
+ italic?: FontStyleType;
79
+ underline?: boolean;
80
+ lineThrough?: boolean;
81
+ fontSize?: number;
82
+ pointMap?: Map<string, [number, number][]>;
83
+ textInfos?: Map<string, Partial<TextOptions>>;
84
+ isLocked?: boolean;
85
+ toolsType?: EToolsKey;
86
+ willRefresh?: boolean;
87
+ [key: string]: any;
88
+ }
89
+ export type IWorkerMessage = Omit<Partial<BaseCollectorReducerAction>, 'op'> & {
90
+ viewId: string;
91
+ msgType: EPostMessageType;
92
+ dataType: EDataType;
93
+ scenePath?: string;
94
+ workState?: EvevtWorkState;
95
+ op?: number[];
96
+ offscreenCanvasOpt?: IOffscreenCanvasOptionType;
97
+ dpr?: number;
98
+ vertex?: string;
99
+ fragment?: string;
100
+ workId?: IworkId;
101
+ workOption?: BaseShapeOptions;
102
+ toolsType?: EToolsKey;
103
+ uid?: string;
104
+ cameraOpt?: ICameraOpt;
105
+ translate?: [number, number];
106
+ scale?: number;
107
+ currentToolsData?: IActiveToolsDataType;
108
+ updateNodeOpt?: IUpdateNodeOpt;
109
+ layerOpt?: ILayerOptionType;
110
+ drawCount?: number;
111
+ useAnimation?: boolean;
112
+ willRefreshSelector?: boolean;
113
+ willSyncService?: boolean;
114
+ willRefresh?: boolean;
115
+ isActiveZIndex?: boolean;
116
+ selectStore?: Map<string, {
117
+ ops?: string;
118
+ opt?: BaseShapeOptions;
119
+ updateNodeOpt?: IUpdateNodeOpt;
120
+ }>;
121
+ willSerializeData?: boolean;
122
+ isRunSubWork?: boolean;
123
+ undoTickerId?: number;
124
+ scenes?: ISerializableStorageData;
125
+ textType?: ETextEditorType;
126
+ mainTasksqueueCount?: number;
127
+ textUpdateForWoker?: boolean;
128
+ tasksqueue?: Map<string, IWorkerMessage>;
129
+ point?: [number, number];
130
+ [key: string]: any;
131
+ };
132
+ export interface IRectType {
133
+ x: number;
134
+ y: number;
135
+ w: number;
136
+ h: number;
137
+ }
138
+ export interface IMainMessage extends INormalPushMsg {
139
+ type: EPostMessageType;
140
+ dataType?: EDataType;
141
+ imageBitmap?: ImageBitmap | OffscreenCanvas;
142
+ rect?: IRectType;
143
+ dpr?: number;
144
+ translate?: [number, number];
145
+ scale?: number;
146
+ removeIds?: Array<string>;
147
+ /** 是否是完整的一次任务 */
148
+ isFullWork?: boolean;
149
+ drawCount?: number;
150
+ selectIds?: Array<string>;
151
+ padding?: number;
152
+ selectRect?: IRectType;
153
+ selectorColor?: string;
154
+ strokeColor?: string;
155
+ fillColor?: string;
156
+ isOpacity?: boolean;
157
+ updateNodeOpts?: Map<string, IUpdateNodeOpt>;
158
+ willSyncService?: boolean;
159
+ newWorkDatas?: Map<string, {
160
+ op: number[];
161
+ opt: BaseShapeOptions;
162
+ workId: IworkId;
163
+ toolsType: EToolsKey;
164
+ }>;
165
+ undoTickerId?: number;
166
+ scenePath?: string;
167
+ canvasWidth?: number;
168
+ canvasHeight?: number;
169
+ workState?: EvevtWorkState;
170
+ canTextEdit?: boolean;
171
+ canRotate?: boolean;
172
+ canLock?: boolean;
173
+ scaleType?: EScaleType;
174
+ textOpt?: TextOptions;
175
+ viewId?: string;
176
+ points?: [number, number][];
177
+ isRefresh?: boolean;
178
+ renderRect?: IRectType;
179
+ isLocked?: boolean;
180
+ shapeOpt?: ShapeOptType;
181
+ toolsTypes?: EToolsKey[];
182
+ }
183
+ export interface IMainMessageRenderData {
184
+ viewId: string;
185
+ rect?: IRectType;
186
+ imageBitmap?: ImageBitmap;
187
+ isDrawAll?: boolean;
188
+ drawCanvas?: ECanvasShowType;
189
+ isClear?: boolean;
190
+ isClearAll?: boolean;
191
+ clearCanvas?: ECanvasShowType;
192
+ /** 是否需要销毁imageBitmap */
193
+ isUnClose?: boolean;
194
+ isFullWork?: boolean;
195
+ workerType?: EDataType.Local | EDataType.Service;
196
+ offset?: {
197
+ x: number;
198
+ y: number;
199
+ };
200
+ translate?: [number, number];
201
+ }
202
+ export interface IBatchMainMessage {
203
+ /** 绘制数据 */
204
+ render?: Array<IMainMessageRenderData>;
205
+ /** 同步服务端数据 */
206
+ sp?: Array<IMainMessage>;
207
+ drawCount?: number;
208
+ workerTasksqueueCount?: number;
209
+ }
210
+ export interface ICameraOpt {
211
+ centerX: number;
212
+ centerY: number;
213
+ scale: number;
214
+ width: number;
215
+ height: number;
216
+ }
217
+ export interface IUpdateSelectorPropsType {
218
+ updateSelectorOpt: IUpdateNodeOpt;
219
+ willRefreshSelector?: boolean;
220
+ willSyncService?: boolean;
221
+ willSerializeData?: boolean;
222
+ emitEventType?: EmitEventType;
223
+ isSync?: boolean;
224
+ textUpdateForWoker?: boolean;
225
+ scene?: Scene;
226
+ }
227
+ export interface IUpdateSelectorCallbackPropsType {
228
+ res?: IMainMessage;
229
+ param: IUpdateSelectorPropsType;
230
+ postData: Pick<IBatchMainMessage, 'sp' | 'render'>;
231
+ workShapeNode: SelectorShape;
232
+ newServiceStore: Map<string, {
233
+ opt: BaseShapeOptions;
234
+ toolsType: EToolsKey;
235
+ ops?: string;
236
+ }>;
237
+ }
238
+ export interface IActiveToolsDataType {
239
+ toolsType: EToolsKey;
240
+ toolsOpt: ShapeOptions;
241
+ }
242
+ export interface IActiveWorkDataType {
243
+ workState: EvevtWorkState;
244
+ toolsOpt?: ShapeOptions;
245
+ viewId?: string;
246
+ workId?: IworkId;
247
+ undoTickerId?: number;
248
+ }
249
+ export type IServiceWorkItem = {
250
+ toolsType: EToolsKey;
251
+ animationWorkData?: number[];
252
+ animationIndex?: number;
253
+ type: EPostMessageType;
254
+ node?: BaseShapeTool;
255
+ updateNodeOpt?: IUpdateNodeOpt;
256
+ ops?: string;
257
+ isDel?: boolean;
258
+ timer?: number;
259
+ useAnimation?: boolean;
260
+ bindSelector?: string;
261
+ selectIds?: string[];
262
+ oldRect?: IRectType;
263
+ totalRect?: IRectType;
264
+ isDiff?: boolean;
265
+ };
266
+ export type BaseNodeMapItem = {
267
+ name: string;
268
+ rect: IRectType;
269
+ op: number[];
270
+ opt: BaseShapeOptions;
271
+ centerPos: [number, number];
272
+ toolsType: EToolsKey;
273
+ canRotate: boolean;
274
+ scaleType: EScaleType;
275
+ };
276
+ export type Size = {
277
+ /**
278
+ * 宽
279
+ */
280
+ width: number;
281
+ /**
282
+ * 高
283
+ */
284
+ height: number;
285
+ };
286
+ export type Rectangle = Size & {
287
+ /**
288
+ * 矩形的左上角 x 坐标
289
+ */
290
+ originX: number;
291
+ /**
292
+ * 矩形的左上角 y 坐标
293
+ */
294
+ originY: number;
295
+ };
@@ -0,0 +1,43 @@
1
+ import { Vec2d } from "./primitives/Vec2d";
2
+ /**
3
+ * @desc 贝塞尔曲线算法,包含了3阶贝塞尔
4
+ */
5
+ export declare class Bezier {
6
+ static bezier(num: number, points: Vec2d[]): Vec2d[];
7
+ /**
8
+ * @desc 获取点,这里可以设置点的个数
9
+ * @param {number} num 点个数
10
+ * @param {Vec2d} p1 点坐标
11
+ * @param {Vec2d} p2 点坐标
12
+ * @param {Vec2d} p3 点坐标
13
+ * @param {Vec2d} p4 点坐标
14
+ * 如果参数是 num, p1, p2 为一阶贝塞尔
15
+ * 如果参数是 num, p1, c1, p2 为二阶贝塞尔
16
+ * 如果参数是 num, p1, c1, c2, p2 为三阶贝塞尔
17
+ */
18
+ static getBezierPoints(num: number | undefined, p1: Vec2d, p2: Vec2d, p3?: Vec2d, p4?: Vec2d): Vec2d[];
19
+ /**
20
+ * @desc 一阶贝塞尔
21
+ * @param {number} t 当前百分比
22
+ * @param {Vec2d} p1 起点坐标
23
+ * @param {Vec2d} p2 终点坐标
24
+ */
25
+ static oneBezier(t: number, p1: Vec2d, p2: Vec2d): Vec2d;
26
+ /**
27
+ * @desc 二阶贝塞尔
28
+ * @param {number} t 当前百分比
29
+ * @param {Array} p1 起点坐标
30
+ * @param {Array} p2 终点坐标
31
+ * @param {Array} cp 控制点
32
+ */
33
+ static twoBezier(t: number, p1: Vec2d, cp: Vec2d, p2: Vec2d): Vec2d;
34
+ /**
35
+ * @desc 三阶贝塞尔
36
+ * @param {number} t 当前百分比
37
+ * @param {Array} p1 起点坐标
38
+ * @param {Array} p2 终点坐标
39
+ * @param {Array} cp1 控制点1
40
+ * @param {Array} cp2 控制点2
41
+ */
42
+ static threeBezier(t: number, p1: Vec2d, cp1: Vec2d, cp2: Vec2d, p2: Vec2d): Vec2d;
43
+ }
@@ -0,0 +1,10 @@
1
+ import { PointLike } from './primitives/Point2d';
2
+ /**
3
+ * Turn an array of points into a path of quadradic curves.
4
+ *
5
+ * @param points - The points returned from perfect-freehand
6
+ * @param closed - Whether the stroke is closed
7
+ *
8
+ * @public
9
+ */
10
+ export declare function getSvgPathFromPoints(points: PointLike[], closed?: boolean): string;