@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.
- package/README.md +138 -0
- package/cdn/appliance-plugin.js +1 -0
- package/cdn/appliance-plugin.mjs +8639 -0
- package/cdn/style.css +1 -0
- package/dist/appliance-plugin.js +1 -0
- package/dist/appliance-plugin.mjs +8639 -0
- package/dist/collector/base.d.ts +20 -0
- package/dist/collector/collector.d.ts +53 -0
- package/dist/collector/const.d.ts +3 -0
- package/dist/collector/enum.d.ts +13 -0
- package/dist/collector/eventCollector.d.ts +29 -0
- package/dist/collector/index.d.ts +4 -0
- package/dist/collector/types.d.ts +70 -0
- package/dist/collector/utils/color.d.ts +31 -0
- package/dist/collector/utils/index.d.ts +5 -0
- package/dist/component/textEditor/index.d.ts +2 -0
- package/dist/component/textEditor/manager.d.ts +120 -0
- package/dist/component/textEditor/types.d.ts +50 -0
- package/dist/component/textEditor/utils.d.ts +3 -0
- package/dist/component/textEditor/view.d.ts +68 -0
- package/dist/core/const.d.ts +1 -0
- package/dist/core/enum.d.ts +135 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/mainEngine.d.ts +163 -0
- package/dist/core/msgEvent/activeZIndex/forMain.d.ts +12 -0
- package/dist/core/msgEvent/activeZIndex/forWorker.d.ts +8 -0
- package/dist/core/msgEvent/base.d.ts +18 -0
- package/dist/core/msgEvent/baseForWorker.d.ts +13 -0
- package/dist/core/msgEvent/copyNode/forMain.d.ts +47 -0
- package/dist/core/msgEvent/copyNode/forWorker.d.ts +8 -0
- package/dist/core/msgEvent/deleteNode/forMain.d.ts +11 -0
- package/dist/core/msgEvent/deleteNode/forWorker.d.ts +13 -0
- package/dist/core/msgEvent/forWorker.d.ts +14 -0
- package/dist/core/msgEvent/index.d.ts +15 -0
- package/dist/core/msgEvent/rotateNode/forMain.d.ts +16 -0
- package/dist/core/msgEvent/rotateNode/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/scaleNode/forMain.d.ts +20 -0
- package/dist/core/msgEvent/scaleNode/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setColor/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setColor/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setFont/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setFont/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setLock/forMain.d.ts +12 -0
- package/dist/core/msgEvent/setLock/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setPoint/forMain.d.ts +15 -0
- package/dist/core/msgEvent/setPoint/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setShape/forMain.d.ts +18 -0
- package/dist/core/msgEvent/setShape/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/setZIndex/forMain.d.ts +22 -0
- package/dist/core/msgEvent/setZIndex/forWorker.d.ts +9 -0
- package/dist/core/msgEvent/translateNode/forMain.d.ts +20 -0
- package/dist/core/msgEvent/translateNode/forWorker.d.ts +9 -0
- package/dist/core/tools/arrow.d.ts +46 -0
- package/dist/core/tools/base.d.ts +82 -0
- package/dist/core/tools/ellipse.d.ts +44 -0
- package/dist/core/tools/eraser.d.ts +41 -0
- package/dist/core/tools/image.d.ts +53 -0
- package/dist/core/tools/index.d.ts +13 -0
- package/dist/core/tools/laserPen.d.ts +42 -0
- package/dist/core/tools/pencil.d.ts +66 -0
- package/dist/core/tools/polygon.d.ts +45 -0
- package/dist/core/tools/rectangle.d.ts +46 -0
- package/dist/core/tools/selector.d.ts +83 -0
- package/dist/core/tools/speechBalloon.d.ts +49 -0
- package/dist/core/tools/star.d.ts +47 -0
- package/dist/core/tools/straight.d.ts +46 -0
- package/dist/core/tools/text.d.ts +42 -0
- package/dist/core/tools/utils.d.ts +39 -0
- package/dist/core/types.d.ts +295 -0
- package/dist/core/utils/bezier.d.ts +43 -0
- package/dist/core/utils/getSvgPathFromPoints.d.ts +10 -0
- package/dist/core/utils/index.d.ts +364 -0
- package/dist/core/utils/math.d.ts +57 -0
- package/dist/core/utils/primitives/Box2d.d.ts +100 -0
- package/dist/core/utils/primitives/Point2d.d.ts +71 -0
- package/dist/core/utils/primitives/Vec2d.d.ts +146 -0
- package/dist/core/utils/primitives/easings.d.ts +24 -0
- package/dist/core/utils/proxy.d.ts +21 -0
- package/dist/core/utils/spriteNode.d.ts +4 -0
- package/dist/core/worker/base.d.ts +103 -0
- package/dist/core/worker/fullWorker.d.ts +1 -0
- package/dist/core/worker/fullWorkerLocal.d.ts +46 -0
- package/dist/core/worker/fullWorkerService.d.ts +41 -0
- package/dist/core/worker/subWorker.d.ts +1 -0
- package/dist/core/worker/subWorkerLocal.d.ts +20 -0
- package/dist/core/worker/vNodeManager.d.ts +32 -0
- package/dist/core/worker/workerManager.d.ts +71 -0
- package/dist/cursors/index.d.ts +73 -0
- package/dist/displayer/const.d.ts +11 -0
- package/dist/displayer/cursor/index.d.ts +15 -0
- package/dist/displayer/floatBar/index.d.ts +10 -0
- package/dist/displayer/floatBtns/colors.d.ts +6 -0
- package/dist/displayer/floatBtns/del.d.ts +6 -0
- package/dist/displayer/floatBtns/duplicate.d.ts +5 -0
- package/dist/displayer/floatBtns/fontSize.d.ts +4 -0
- package/dist/displayer/floatBtns/fontStyle.d.ts +4 -0
- package/dist/displayer/floatBtns/index.d.ts +11 -0
- package/dist/displayer/floatBtns/layer.d.ts +3 -0
- package/dist/displayer/floatBtns/lock.d.ts +7 -0
- package/dist/displayer/floatBtns/shapeOpt.d.ts +3 -0
- package/dist/displayer/highlightBox/index.d.ts +5 -0
- package/dist/displayer/icons/index.d.ts +4 -0
- package/dist/displayer/resizable/index.d.ts +16 -0
- package/dist/displayer/rotate/index.d.ts +4 -0
- package/dist/displayer/types.d.ts +51 -0
- package/dist/hotkey/index.d.ts +51 -0
- package/dist/index.d.ts +1 -0
- package/dist/members/index.d.ts +15 -0
- package/dist/plugin/applianceMultiPlugin.d.ts +24 -0
- package/dist/plugin/applianceSinglePlugin.d.ts +28 -0
- package/dist/plugin/baseApplianceManager.d.ts +82 -0
- package/dist/plugin/baseViewContainerManager.d.ts +174 -0
- package/dist/plugin/displayerView.d.ts +55 -0
- package/dist/plugin/external.d.ts +2 -0
- package/dist/plugin/index.d.ts +6 -0
- package/dist/plugin/multi/applianceMultiManager.d.ts +14 -0
- package/dist/plugin/multi/containerManager.d.ts +24 -0
- package/dist/plugin/multi/displayer/appViewDisplayerManager.d.ts +24 -0
- package/dist/plugin/multi/displayer/mainViewDisplayerManager.d.ts +25 -0
- package/dist/plugin/single/applianceDisplayer.d.ts +16 -0
- package/dist/plugin/single/applianceSingleManager.d.ts +13 -0
- package/dist/plugin/single/containerManager.d.ts +11 -0
- package/dist/plugin/single/displayer/mainViewDisplayerManager.d.ts +25 -0
- package/dist/plugin/types.d.ts +310 -0
- package/dist/plugin/utils.d.ts +6 -0
- package/dist/style.css +1 -0
- package/dist/undo/index.d.ts +70 -0
- package/package.json +59 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { Box2d } from './primitives/Box2d';
|
|
2
|
+
import { Vec2d, VecLike } from './primitives/Vec2d';
|
|
3
|
+
export * from "./math";
|
|
4
|
+
export * from "./spriteNode";
|
|
5
|
+
/** @public */
|
|
6
|
+
export declare function precise(A: VecLike): string;
|
|
7
|
+
/** @public */
|
|
8
|
+
export declare function average(A: VecLike, B: VecLike): string;
|
|
9
|
+
/** @public */
|
|
10
|
+
export declare const PI: number;
|
|
11
|
+
/** @public */
|
|
12
|
+
export declare const TAU: number;
|
|
13
|
+
/** @public */
|
|
14
|
+
export declare const PI2: number;
|
|
15
|
+
/** @public */
|
|
16
|
+
export declare const EPSILON: number;
|
|
17
|
+
/** @public */
|
|
18
|
+
export declare const SIN: (x: number) => number;
|
|
19
|
+
/**
|
|
20
|
+
* Clamp a value into a range.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
*
|
|
24
|
+
* ```ts
|
|
25
|
+
* const A = clamp(0, 1) // 1
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @param n - The number to clamp.
|
|
29
|
+
* @param min - The minimum value.
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
export declare function clamp(n: number, min: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Clamp a value into a range.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
*
|
|
38
|
+
* ```ts
|
|
39
|
+
* const A = clamp(0, 1, 10) // 1
|
|
40
|
+
* const B = clamp(11, 1, 10) // 10
|
|
41
|
+
* const C = clamp(5, 1, 10) // 5
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param n - The number to clamp.
|
|
45
|
+
* @param min - The minimum value.
|
|
46
|
+
* @param max - The maximum value.
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export declare function clamp(n: number, min: number, max: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Get a number to a precision.
|
|
52
|
+
*
|
|
53
|
+
* @param n - The number.
|
|
54
|
+
* @param precision - The precision.
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare function toPrecision(n: number, precision?: number): number;
|
|
58
|
+
/**
|
|
59
|
+
* Whether two numbers numbers a and b are approximately equal.
|
|
60
|
+
*
|
|
61
|
+
* @param a - The first point.
|
|
62
|
+
* @param b - The second point.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export declare function approximately(a: number, b: number, precision?: number): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Find the approximate perimeter of an ellipse.
|
|
68
|
+
*
|
|
69
|
+
* @param rx - The ellipse's x radius.
|
|
70
|
+
* @param ry - The ellipse's y radius.
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
export declare function perimeterOfEllipse(rx: number, ry: number): number;
|
|
74
|
+
/**
|
|
75
|
+
* @param a - Any angle in radians
|
|
76
|
+
* @returns A number between 0 and 2 * PI
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
export declare function canonicalizeRotation(a: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* Get the clockwise angle distance between two angles.
|
|
82
|
+
*
|
|
83
|
+
* @param a0 - The first angle.
|
|
84
|
+
* @param a1 - The second angle.
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare function clockwiseAngleDist(a0: number, a1: number): number;
|
|
88
|
+
/**
|
|
89
|
+
* Get the counter-clockwise angle distance between two angles.
|
|
90
|
+
*
|
|
91
|
+
* @param a0 - The first angle.
|
|
92
|
+
* @param a1 - The second angle.
|
|
93
|
+
* @public
|
|
94
|
+
*/
|
|
95
|
+
export declare function counterClockwiseAngleDist(a0: number, a1: number): number;
|
|
96
|
+
/**
|
|
97
|
+
* Get the short angle distance between two angles.
|
|
98
|
+
*
|
|
99
|
+
* @param a0 - The first angle.
|
|
100
|
+
* @param a1 - The second angle.
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare function shortAngleDist(a0: number, a1: number): number;
|
|
104
|
+
/**
|
|
105
|
+
* Get the long angle distance between two angles.
|
|
106
|
+
*
|
|
107
|
+
* @param a0 - The first angle.
|
|
108
|
+
* @param a1 - The second angle.
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
export declare function longAngleDist(a0: number, a1: number): number;
|
|
112
|
+
/**
|
|
113
|
+
* Interpolate an angle between two angles.
|
|
114
|
+
*
|
|
115
|
+
* @param a0 - The first angle.
|
|
116
|
+
* @param a1 - The second angle.
|
|
117
|
+
* @param t - The interpolation value.
|
|
118
|
+
* @public
|
|
119
|
+
*/
|
|
120
|
+
export declare function lerpAngles(a0: number, a1: number, t: number): number;
|
|
121
|
+
/**
|
|
122
|
+
* Get the short distance between two angles.
|
|
123
|
+
*
|
|
124
|
+
* @param a0 - The first angle.
|
|
125
|
+
* @param a1 - The second angle.
|
|
126
|
+
* @public
|
|
127
|
+
*/
|
|
128
|
+
export declare function angleDelta(a0: number, a1: number): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get the "sweep" or short distance between two points on a circle's perimeter.
|
|
131
|
+
*
|
|
132
|
+
* @param C - The center of the circle.
|
|
133
|
+
* @param A - The first point.
|
|
134
|
+
* @param B - The second point.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export declare function getSweep(C: VecLike, A: VecLike, B: VecLike): number;
|
|
138
|
+
/**
|
|
139
|
+
* Clamp radians within 0 and 2PI
|
|
140
|
+
*
|
|
141
|
+
* @param r - The radian value.
|
|
142
|
+
* @public
|
|
143
|
+
*/
|
|
144
|
+
export declare function clampRadians(r: number): number;
|
|
145
|
+
/**
|
|
146
|
+
* Clamp rotation to even segments.
|
|
147
|
+
*
|
|
148
|
+
* @param r - The rotation in radians.
|
|
149
|
+
* @param segments - The number of segments.
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export declare function snapAngle(r: number, segments: number): number;
|
|
153
|
+
/**
|
|
154
|
+
* Checks whether two angles are approximately at right-angles or parallel to each other
|
|
155
|
+
*
|
|
156
|
+
* @param a - Angle a (radians)
|
|
157
|
+
* @param b - Angle b (radians)
|
|
158
|
+
* @returns True iff the angles are approximately at right-angles or parallel to each other
|
|
159
|
+
* @public
|
|
160
|
+
*/
|
|
161
|
+
export declare function areAnglesCompatible(a: number, b: number): boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Is angle c between angles a and b?
|
|
164
|
+
*
|
|
165
|
+
* @param a - The first angle.
|
|
166
|
+
* @param b - The second angle.
|
|
167
|
+
* @param c - The third angle.
|
|
168
|
+
* @public
|
|
169
|
+
*/
|
|
170
|
+
export declare function isAngleBetween(a: number, b: number, c: number): boolean;
|
|
171
|
+
/**
|
|
172
|
+
* Convert degrees to radians.
|
|
173
|
+
*
|
|
174
|
+
* @param d - The degree in degrees.
|
|
175
|
+
* @public
|
|
176
|
+
*/
|
|
177
|
+
export declare function degreesToRadians(d: number): number;
|
|
178
|
+
/**
|
|
179
|
+
* Convert radians to degrees.
|
|
180
|
+
*
|
|
181
|
+
* @param r - The degree in radians.
|
|
182
|
+
* @public
|
|
183
|
+
*/
|
|
184
|
+
export declare function radiansToDegrees(r: number): number;
|
|
185
|
+
/**
|
|
186
|
+
* Get the length of an arc between two points on a circle's perimeter.
|
|
187
|
+
*
|
|
188
|
+
* @param C - The circle's center as [x, y].
|
|
189
|
+
* @param r - The circle's radius.
|
|
190
|
+
* @param A - The first point.
|
|
191
|
+
* @param B - The second point.
|
|
192
|
+
* @public
|
|
193
|
+
*/
|
|
194
|
+
export declare function getArcLength(C: VecLike, r: number, A: VecLike, B: VecLike): number;
|
|
195
|
+
/**
|
|
196
|
+
* Get a point on the perimeter of a circle.
|
|
197
|
+
*
|
|
198
|
+
* @param cx - The center x of the circle.
|
|
199
|
+
* @param cy - The center y of the circle.
|
|
200
|
+
* @param r - The radius of the circle.
|
|
201
|
+
* @param a - The normalized point on the circle.
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export declare function getPointOnCircle(cx: number, cy: number, r: number, a: number): Vec2d;
|
|
205
|
+
/** @public */
|
|
206
|
+
export declare function getPolygonVertices(width: number, height: number, sides: number): Vec2d[];
|
|
207
|
+
/**
|
|
208
|
+
* @param a0 - The start point in the A range
|
|
209
|
+
* @param a1 - The end point in the A range
|
|
210
|
+
* @param b0 - The start point in the B range
|
|
211
|
+
* @param b1 - The end point in the B range
|
|
212
|
+
* @returns True if the ranges overlap
|
|
213
|
+
* @public
|
|
214
|
+
*/
|
|
215
|
+
export declare function rangesOverlap(a0: number, a1: number, b0: number, b1: number): boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Finds the intersection of two ranges.
|
|
218
|
+
*
|
|
219
|
+
* @param a0 - The start point in the A range
|
|
220
|
+
* @param a1 - The end point in the A range
|
|
221
|
+
* @param b0 - The start point in the B range
|
|
222
|
+
* @param b1 - The end point in the B range
|
|
223
|
+
* @returns The intersection of the ranges, or null if no intersection
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export declare function rangeIntersection(a0: number, a1: number, b0: number, b1: number): [number, number] | null;
|
|
227
|
+
/**
|
|
228
|
+
* Gets the width/height of a star given its input bounds.
|
|
229
|
+
*
|
|
230
|
+
* @param sides - Number of sides
|
|
231
|
+
* @param w - T target width
|
|
232
|
+
* @param h - Target height
|
|
233
|
+
* @returns Box2d
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
export declare const getStarBounds: (sides: number, w: number, h: number) => Box2d;
|
|
237
|
+
/**
|
|
238
|
+
* Utils for working with points.
|
|
239
|
+
*
|
|
240
|
+
* @public
|
|
241
|
+
*/
|
|
242
|
+
/**
|
|
243
|
+
* Get whether a point is inside of a circle.
|
|
244
|
+
*
|
|
245
|
+
* @param A - The point to check.
|
|
246
|
+
* @param C - The circle's center point as [x, y].
|
|
247
|
+
* @param r - The circle's radius.
|
|
248
|
+
* @returns Boolean
|
|
249
|
+
* @public
|
|
250
|
+
*/
|
|
251
|
+
export declare function pointInCircle(A: VecLike, C: VecLike, r: number): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Get whether a point is inside of an ellipse.
|
|
254
|
+
*
|
|
255
|
+
* @param point - The point to check.
|
|
256
|
+
* @param center - The ellipse's center point as [x, y].
|
|
257
|
+
* @param rx - The ellipse's x radius.
|
|
258
|
+
* @param ry - The ellipse's y radius.
|
|
259
|
+
* @param rotation - The ellipse's rotation.
|
|
260
|
+
* @returns Boolean
|
|
261
|
+
* @public
|
|
262
|
+
*/
|
|
263
|
+
export declare function pointInEllipse(A: VecLike, C: VecLike, rx: number, ry: number, rotation?: number): boolean;
|
|
264
|
+
/**
|
|
265
|
+
* Get whether a point is inside of a rectangle.
|
|
266
|
+
*
|
|
267
|
+
* @param A - The point to check.
|
|
268
|
+
* @param point - The rectangle's top left point as [x, y].
|
|
269
|
+
* @param size - The rectangle's size as [width, height].
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare function pointInRect(A: VecLike, point: VecLike, size: VecLike): boolean;
|
|
273
|
+
/**
|
|
274
|
+
* Get whether a point is inside of a polygon.
|
|
275
|
+
*
|
|
276
|
+
* ```ts
|
|
277
|
+
* const result = pointInPolygon(myPoint, myPoints)
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
export declare function pointInPolygon(A: VecLike, points: VecLike[]): boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Get whether a point is inside of a bounds.
|
|
285
|
+
*
|
|
286
|
+
* @param A - The point to check.
|
|
287
|
+
* @param b - The bounds to check.
|
|
288
|
+
* @returns Boolean
|
|
289
|
+
* @public
|
|
290
|
+
*/
|
|
291
|
+
export declare function pointInBounds(A: VecLike, b: Box2d): boolean;
|
|
292
|
+
/**
|
|
293
|
+
* Hit test a point and a polyline using a minimum distance.
|
|
294
|
+
*
|
|
295
|
+
* @param A - The point to check.
|
|
296
|
+
* @param points - The points that make up the polyline.
|
|
297
|
+
* @param distance - The mininum distance that qualifies a hit.
|
|
298
|
+
* @returns Boolean
|
|
299
|
+
* @public
|
|
300
|
+
*/
|
|
301
|
+
export declare function pointInPolyline(A: VecLike, points: VecLike[], distance?: number): boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Get whether a point is within a certain distance from a polyline.
|
|
304
|
+
*
|
|
305
|
+
* @param A - The point to check.
|
|
306
|
+
* @param points - The points that make up the polyline.
|
|
307
|
+
* @param distance - The mininum distance that qualifies a hit.
|
|
308
|
+
* @public
|
|
309
|
+
*/
|
|
310
|
+
export declare function pointNearToPolyline(A: VecLike, points: VecLike[], distance?: number): boolean;
|
|
311
|
+
/**
|
|
312
|
+
* Get whether a point is within a certain distance from a line segment.
|
|
313
|
+
*
|
|
314
|
+
* @param A - The point to check.
|
|
315
|
+
* @param p1 - The polyline's first point.
|
|
316
|
+
* @param p2 - The polyline's second point.
|
|
317
|
+
* @param distance - The mininum distance that qualifies a hit.
|
|
318
|
+
* @public
|
|
319
|
+
*/
|
|
320
|
+
export declare function pointNearToLineSegment(A: VecLike, p1: VecLike, p2: VecLike, distance?: number): boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Simplify a line (using Ramer-Douglas-Peucker algorithm).
|
|
323
|
+
*
|
|
324
|
+
* @param points - An array of points as [x, y, ...][]
|
|
325
|
+
* @param tolerance - The minimum line distance (also called epsilon).
|
|
326
|
+
* @returns Simplified array as [x, y, ...][]
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
export declare function simplify(points: VecLike[], tolerance?: number): VecLike[];
|
|
330
|
+
/** @public */
|
|
331
|
+
export declare function simplify2(points: VecLike[], tolerance?: number): VecLike[];
|
|
332
|
+
/** @public */
|
|
333
|
+
export declare function getMinX(pts: VecLike[]): number;
|
|
334
|
+
/** @public */
|
|
335
|
+
export declare function getMinY(pts: VecLike[]): number;
|
|
336
|
+
/** @public */
|
|
337
|
+
export declare function getMaxX(pts: VecLike[]): number;
|
|
338
|
+
/** @public */
|
|
339
|
+
export declare function getMaxY(pts: VecLike[]): number;
|
|
340
|
+
/** @public */
|
|
341
|
+
export declare function getMidX(pts: VecLike[]): number;
|
|
342
|
+
/** @public */
|
|
343
|
+
export declare function getMidY(pts: VecLike[]): number;
|
|
344
|
+
/** @public */
|
|
345
|
+
export declare function getWidth(pts: VecLike[]): number;
|
|
346
|
+
/** @public */
|
|
347
|
+
export declare function getHeight(pts: VecLike[]): number;
|
|
348
|
+
/**
|
|
349
|
+
* The DOM likes values to be fixed to 3 decimal places
|
|
350
|
+
*
|
|
351
|
+
* @public
|
|
352
|
+
*/
|
|
353
|
+
export declare function toDomPrecision(v: number): number;
|
|
354
|
+
/**
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
357
|
+
export declare function toFixed(v: number): number;
|
|
358
|
+
/**
|
|
359
|
+
* Check if a float is safe to use. ie: Not too big or small.
|
|
360
|
+
* @public
|
|
361
|
+
*/
|
|
362
|
+
export declare const isSafeFloat: (n: number) => boolean;
|
|
363
|
+
export declare const requestAsyncCallBack: (callBack: () => void, timeout: number) => Promise<void>;
|
|
364
|
+
export declare const getRatioWithContext: (context: CanvasRenderingContext2D) => number;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Group } from "spritejs";
|
|
2
|
+
import { IRectType } from "../types";
|
|
3
|
+
import { Point2d } from "./primitives/Point2d";
|
|
4
|
+
import { Vec2d } from "./primitives/Vec2d";
|
|
5
|
+
import type { Rectangle } from "../types";
|
|
6
|
+
export declare function outerRect(rect: IRectType, offset: number): {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
};
|
|
12
|
+
export declare function interRect(rect: IRectType, offset: number): {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
w: number;
|
|
16
|
+
h: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function computRect(rect1?: IRectType, rect2?: IRectType): IRectType | undefined;
|
|
19
|
+
export declare function computRectangle(rect1?: Rectangle, rect2?: Rectangle): Rectangle | undefined;
|
|
20
|
+
export declare function getRectFromPoints(points: (Point2d | Vec2d)[], offset?: number): {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
w: number;
|
|
24
|
+
h: number;
|
|
25
|
+
};
|
|
26
|
+
export declare function isIntersect(rect1: IRectType, rect2: IRectType): boolean;
|
|
27
|
+
export declare function isSameArray(a: Array<string | number>, b: Array<string | number>): boolean;
|
|
28
|
+
export declare function getSafetyRect(oldRect: IRectType, tolerance?: number): {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
w: number;
|
|
32
|
+
h: number;
|
|
33
|
+
};
|
|
34
|
+
export declare function getRectTranslated(rect: IRectType, translate: [number, number]): {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
w: number;
|
|
38
|
+
h: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function getRectRotated(rect: IRectType, angle: number): {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
w: number;
|
|
44
|
+
h: number;
|
|
45
|
+
};
|
|
46
|
+
export declare function getRectScaleed(rect: IRectType, scale: [number, number]): {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
w: number;
|
|
50
|
+
h: number;
|
|
51
|
+
};
|
|
52
|
+
export declare function rotatePoints(points: number[], originPos: [number, number], angle: number): void;
|
|
53
|
+
export declare function scalePoints(points: number[], originPos: [number, number], scale: [number, number]): void;
|
|
54
|
+
export declare function getNodeRect(key: string, layer?: Group, safeBorderPadding?: number): IRectType | undefined;
|
|
55
|
+
export declare function isIntersectForPoint(point: [number, number], rect: IRectType): boolean;
|
|
56
|
+
export declare const getLineSegIntersection: (p1: [number, number], p2: [number, number], p3: [number, number], p4: [number, number]) => [number, number] | null;
|
|
57
|
+
export declare function getWHRatio(w: number, h: number): [number, number];
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Vec2d, VecLike } from './Vec2d';
|
|
2
|
+
/**
|
|
3
|
+
* A serializable model for 2D boxes.
|
|
4
|
+
*
|
|
5
|
+
* @public */
|
|
6
|
+
export interface Box2dModel {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
}
|
|
12
|
+
/** @public */
|
|
13
|
+
export type SelectionEdge = 'top' | 'right' | 'bottom' | 'left';
|
|
14
|
+
/** @public */
|
|
15
|
+
export type SelectionCorner = 'top_left' | 'top_right' | 'bottom_right' | 'bottom_left';
|
|
16
|
+
/** @public */
|
|
17
|
+
export type SelectionHandle = SelectionEdge | SelectionCorner;
|
|
18
|
+
/** @public */
|
|
19
|
+
export type RotateCorner = 'top_left_rotate' | 'top_right_rotate' | 'bottom_right_rotate' | 'bottom_left_rotate' | 'mobile_rotate';
|
|
20
|
+
/** @public */
|
|
21
|
+
export declare class Box2d {
|
|
22
|
+
constructor(x?: number, y?: number, w?: number, h?: number);
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
w: number;
|
|
26
|
+
h: number;
|
|
27
|
+
get point(): Vec2d;
|
|
28
|
+
set point(val: Vec2d);
|
|
29
|
+
get minX(): number;
|
|
30
|
+
set minX(n: number);
|
|
31
|
+
get midX(): number;
|
|
32
|
+
get maxX(): number;
|
|
33
|
+
get minY(): number;
|
|
34
|
+
set minY(n: number);
|
|
35
|
+
get midY(): number;
|
|
36
|
+
get maxY(): number;
|
|
37
|
+
get width(): number;
|
|
38
|
+
set width(n: number);
|
|
39
|
+
get height(): number;
|
|
40
|
+
set height(n: number);
|
|
41
|
+
get aspectRatio(): number;
|
|
42
|
+
get center(): Vec2d;
|
|
43
|
+
set center(v: Vec2d);
|
|
44
|
+
get corners(): Vec2d[];
|
|
45
|
+
get snapPoints(): Vec2d[];
|
|
46
|
+
get sides(): Array<[Vec2d, Vec2d]>;
|
|
47
|
+
get size(): Vec2d;
|
|
48
|
+
toFixed(): this;
|
|
49
|
+
setTo(B: Box2d): this;
|
|
50
|
+
set(x?: number, y?: number, w?: number, h?: number): this;
|
|
51
|
+
expand(A: Box2d): this;
|
|
52
|
+
expandBy(n: number): this;
|
|
53
|
+
scale(n: number): this;
|
|
54
|
+
clone(): Box2d;
|
|
55
|
+
translate(delta: VecLike): this;
|
|
56
|
+
snapToGrid(size: number): void;
|
|
57
|
+
collides(B: Box2d): boolean;
|
|
58
|
+
contains(B: Box2d): boolean;
|
|
59
|
+
includes(B: Box2d): boolean;
|
|
60
|
+
containsPoint(V: VecLike, margin?: number): boolean;
|
|
61
|
+
getHandlePoint(handle: SelectionCorner | SelectionEdge): Vec2d;
|
|
62
|
+
toJson(): Box2dModel;
|
|
63
|
+
resize(handle: SelectionCorner | SelectionEdge | string, dx: number, dy: number): void;
|
|
64
|
+
union(box: Box2dModel): this;
|
|
65
|
+
static From(box: Box2dModel): Box2d;
|
|
66
|
+
static FromPoints(points: VecLike[]): Box2d;
|
|
67
|
+
static Expand(A: Box2d, B: Box2d): Box2d;
|
|
68
|
+
static ExpandBy(A: Box2d, n: number): Box2d;
|
|
69
|
+
static Collides: (A: Box2d, B: Box2d) => boolean;
|
|
70
|
+
static Contains: (A: Box2d, B: Box2d) => boolean;
|
|
71
|
+
static Includes: (A: Box2d, B: Box2d) => boolean;
|
|
72
|
+
static ContainsPoint: (A: Box2d, B: VecLike, margin?: number) => boolean;
|
|
73
|
+
static Common: (boxes: Box2d[]) => Box2d;
|
|
74
|
+
static Sides: (A: Box2d, inset?: number) => Vec2d[][];
|
|
75
|
+
static Resize(box: Box2d, handle: SelectionCorner | SelectionEdge | string, dx: number, dy: number, isAspectRatioLocked?: boolean): {
|
|
76
|
+
box: Box2d;
|
|
77
|
+
scaleX: number;
|
|
78
|
+
scaleY: number;
|
|
79
|
+
};
|
|
80
|
+
equals(other: Box2d | Box2dModel): boolean;
|
|
81
|
+
static Equals(a: Box2d | Box2dModel, b: Box2d | Box2dModel): boolean;
|
|
82
|
+
zeroFix(): this;
|
|
83
|
+
static ZeroFix(other: Box2d | Box2dModel): Box2d;
|
|
84
|
+
}
|
|
85
|
+
/** @public */
|
|
86
|
+
export declare function flipSelectionHandleY(handle: SelectionHandle): "top" | "bottom" | "left" | "right" | "top_left" | "top_right" | "bottom_right" | "bottom_left";
|
|
87
|
+
/** @public */
|
|
88
|
+
export declare function flipSelectionHandleX(handle: SelectionHandle): "top" | "bottom" | "left" | "right" | "top_left" | "top_right" | "bottom_right" | "bottom_left";
|
|
89
|
+
/** @public */
|
|
90
|
+
export declare function rotateSelectionHandle(handle: SelectionHandle, rotation: number): SelectionHandle;
|
|
91
|
+
/** @public */
|
|
92
|
+
export declare function isSelectionCorner(selection: string): selection is SelectionCorner;
|
|
93
|
+
/** @public */
|
|
94
|
+
export declare const ROTATE_CORNER_TO_SELECTION_CORNER: {
|
|
95
|
+
readonly top_left_rotate: "top_left";
|
|
96
|
+
readonly top_right_rotate: "top_right";
|
|
97
|
+
readonly bottom_right_rotate: "bottom_right";
|
|
98
|
+
readonly bottom_left_rotate: "bottom_left";
|
|
99
|
+
readonly mobile_rotate: "top_left";
|
|
100
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Vec2d, Vec2dSimple, VecLike } from "./Vec2d";
|
|
2
|
+
/**
|
|
3
|
+
* A serializable model for 2D vectors.
|
|
4
|
+
*
|
|
5
|
+
* @public */
|
|
6
|
+
export interface Point2dModel extends Vec2dSimple {
|
|
7
|
+
/** 压力值 */
|
|
8
|
+
z: number;
|
|
9
|
+
/** 基于上一点的向量 */
|
|
10
|
+
v?: VecLike;
|
|
11
|
+
/** 时间戳 */
|
|
12
|
+
t?: number;
|
|
13
|
+
/** 当前点基于前后两个点的夹角度数(0-360) */
|
|
14
|
+
a?: number;
|
|
15
|
+
}
|
|
16
|
+
/** @public */
|
|
17
|
+
export type PointLike = Point2d | Point2dModel;
|
|
18
|
+
/** @public */
|
|
19
|
+
export declare class Point2d extends Vec2d {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
z: number;
|
|
23
|
+
v: {
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
};
|
|
27
|
+
t: number;
|
|
28
|
+
a: number;
|
|
29
|
+
constructor(x?: number, y?: number, z?: number, v?: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}, t?: number, a?: number);
|
|
33
|
+
get timestamp(): number;
|
|
34
|
+
get pressure(): number;
|
|
35
|
+
get angleNum(): number;
|
|
36
|
+
get XY(): [number, number];
|
|
37
|
+
setA(a: number): void;
|
|
38
|
+
setT(t: number): void;
|
|
39
|
+
setv(v: Vec2dSimple): this;
|
|
40
|
+
set(x?: number, y?: number, z?: number, v?: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
}, t?: number, a?: number): this;
|
|
44
|
+
clone(): Point2d;
|
|
45
|
+
distance(p: Point2d): number;
|
|
46
|
+
isNear(p: Point2d, tolerance: number): boolean;
|
|
47
|
+
getAngleByPoints(pre: Point2d, next: Point2d): number;
|
|
48
|
+
static Sub(A: PointLike, B: VecLike): Point2d;
|
|
49
|
+
static Add(A: PointLike, B: VecLike): Point2d;
|
|
50
|
+
static GetDistance(p0: Point2d, p1: Point2d): number;
|
|
51
|
+
static GetAngleByPoints(pre: Point2d, cur: Point2d, next: Point2d): number;
|
|
52
|
+
static IsNear(p0: Point2d, p1: Point2d, tolerance: number): boolean;
|
|
53
|
+
static RotWith(A: Point2d | Vec2d, C: Point2d | Vec2d, r: number, decimal?: number): Point2d;
|
|
54
|
+
/**
|
|
55
|
+
* 根据圆心和半径,获取圆上的等份点
|
|
56
|
+
* @param o 圆心
|
|
57
|
+
* @param radius 半径
|
|
58
|
+
* @param average 均分数
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
static GetDotStroke(o: Point2d, radius: number, average?: number): Point2d[];
|
|
62
|
+
/**
|
|
63
|
+
* 根据圆心和圆上的起始点,获取半圆上的等份点
|
|
64
|
+
* @param o 圆心
|
|
65
|
+
* @param p 圆弧起始点
|
|
66
|
+
* @param radian 1,逆时针180度 -1,顺时针
|
|
67
|
+
* @param average 均分数
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
static GetSemicircleStroke(o: Point2d, p: Point2d, radian?: number, average?: number): Point2d[];
|
|
71
|
+
}
|