nhanh-pure-function 3.0.4 → 3.0.6-beta.1
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/LICENSE +21 -21
- package/README.md +18 -18
- package/dist/Browser/index.d.ts +1 -1
- package/dist/Canvas/LayerGroup/index.d.ts +30 -0
- package/dist/Canvas/LayerGroup/layer.d.ts +44 -0
- package/dist/Canvas/OverlayGroup/arc.d.ts +97 -0
- package/dist/Canvas/OverlayGroup/arcTo.d.ts +50 -0
- package/dist/Canvas/OverlayGroup/bezierCurve.d.ts +1 -0
- package/dist/Canvas/OverlayGroup/custom.d.ts +24 -0
- package/dist/Canvas/OverlayGroup/ellipse.d.ts +1 -0
- package/dist/Canvas/OverlayGroup/index.d.ts +31 -0
- package/dist/Canvas/OverlayGroup/line.d.ts +31 -0
- package/dist/Canvas/OverlayGroup/point.d.ts +40 -0
- package/dist/Canvas/OverlayGroup/polygon.d.ts +46 -0
- package/dist/Canvas/OverlayGroup/public/geometricBoundary.d.ts +70 -0
- package/dist/Canvas/OverlayGroup/public/overlay.d.ts +174 -0
- package/dist/Canvas/OverlayGroup/text.d.ts +27 -0
- package/dist/Canvas/core/axis.d.ts +42 -0
- package/dist/Canvas/core/basedata.d.ts +177 -0
- package/dist/Canvas/core/draw.d.ts +34 -0
- package/dist/Canvas/core/event.d.ts +77 -0
- package/dist/Canvas/core/quikmethod.d.ts +104 -0
- package/dist/Canvas/core/style.d.ts +22 -0
- package/dist/Canvas/index.d.ts +58 -0
- package/dist/Canvas/index.types.d.ts +14 -0
- package/dist/Canvas/public/basedata.d.ts +64 -0
- package/dist/Canvas/public/eventController.d.ts +111 -0
- package/dist/Canvas/public/eventControllerBasedata.d.ts +62 -0
- package/dist/Canvas/public/tools.d.ts +6 -0
- package/dist/Element/index.d.ts +17 -0
- package/dist/Utility/index.d.ts +12 -28
- package/dist/Utility/type.d.ts +10 -0
- package/dist/Valid/index.d.ts +2 -8
- package/dist/index.cjs.js +9 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +5455 -818
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 ADMINnhanh
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ADMINnhanh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
# nhanh-pure-function
|
|
2
|
-
|
|
3
|
-
纯函数工具库,提供了一些常用的纯函数工具,帮助您在 JavaScript/TypeScript 项目中更高效地处理数据。
|
|
4
|
-
|
|
5
|
-
## 安装
|
|
6
|
-
|
|
7
|
-
您可以通过 npm 安装该库:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install nhanh-pure-function
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## 功能介绍
|
|
14
|
-
|
|
15
|
-
`nhanh-pure-function` 库旨在提供一系列纯函数,这些函数在处理数据时不会产生副作用,确保函数的输入和输出之间的映射关系是确定的。这使得代码更易于测试、维护和复用。
|
|
16
|
-
|
|
17
|
-
## 许可证
|
|
18
|
-
|
|
1
|
+
# nhanh-pure-function
|
|
2
|
+
|
|
3
|
+
纯函数工具库,提供了一些常用的纯函数工具,帮助您在 JavaScript/TypeScript 项目中更高效地处理数据。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
您可以通过 npm 安装该库:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install nhanh-pure-function
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## 功能介绍
|
|
14
|
+
|
|
15
|
+
`nhanh-pure-function` 库旨在提供一系列纯函数,这些函数在处理数据时不会产生副作用,确保函数的输入和输出之间的映射关系是确定的。这使得代码更易于测试、维护和复用。
|
|
16
|
+
|
|
17
|
+
## 许可证
|
|
18
|
+
|
|
19
19
|
[MIT](https://opensource.org/licenses/MIT)
|
package/dist/Browser/index.d.ts
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { default as _Canvas } from '..';
|
|
2
|
+
import { OverlayType } from '../OverlayGroup';
|
|
3
|
+
import { default as Layer } from './layer';
|
|
4
|
+
import { EventHandler, default as EventController } from '../public/eventController';
|
|
5
|
+
type ConstructorOption = ConstructorParameters<typeof EventController>[0];
|
|
6
|
+
export default class LayerGroup extends EventController {
|
|
7
|
+
/** 图层群组 */
|
|
8
|
+
layers: Map<string, Layer>;
|
|
9
|
+
constructor(option: ConstructorOption);
|
|
10
|
+
/** 地图的事件触发不需要传递 */
|
|
11
|
+
defaultContextmenu: EventHandler<"contextmenu">;
|
|
12
|
+
defaultClick: EventHandler<"click">;
|
|
13
|
+
defaultDoubleClick: EventHandler<"doubleClick">;
|
|
14
|
+
defaultHover: EventHandler<"hover">;
|
|
15
|
+
defaultDragg: EventHandler<"dragg">;
|
|
16
|
+
defaultDown: EventHandler<"down">;
|
|
17
|
+
setMainCanvas(mainCanvas?: _Canvas): void;
|
|
18
|
+
setNotifyReload(notifyReload?: () => void): void;
|
|
19
|
+
/** 获取图层 */
|
|
20
|
+
getLayer(name: string): Layer | undefined;
|
|
21
|
+
/** 添加图层 */
|
|
22
|
+
addLayer(layers: Layer | Layer[]): void;
|
|
23
|
+
/** 删除图层 */
|
|
24
|
+
removeLayer(layers: Layer | Layer[]): void;
|
|
25
|
+
/** 清空图层 */
|
|
26
|
+
clearLayers(): void;
|
|
27
|
+
/** 收集图层的 canvas */
|
|
28
|
+
fetchCanvas(): [number, HTMLCanvasElement, [[number, number], OverlayType][]][];
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { default as _Canvas } from '..';
|
|
2
|
+
import { default as OverlayGroup, OverlayType } from '../OverlayGroup';
|
|
3
|
+
import { default as EventController } from '../public/eventController';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof EventController>[0];
|
|
5
|
+
/**
|
|
6
|
+
* 图层事件触发机制说明:
|
|
7
|
+
*
|
|
8
|
+
* 注意事项:
|
|
9
|
+
* 图层级事件监听依赖其内部覆盖物的事件触发,仅当满足以下条件时触发:
|
|
10
|
+
* 事件发生在该图层包含的覆盖物上
|
|
11
|
+
* 该覆盖物已触发对应类型的事件
|
|
12
|
+
*
|
|
13
|
+
* 原因是:
|
|
14
|
+
* 若存在位于不同 图层 的两个覆盖物,点击位置上是 zIndex 较小的图层中的覆盖物时,
|
|
15
|
+
* 事件触发对象就应该是该 图层 中的 覆盖物,这时就不应该再触发其他 图层 的事件了;
|
|
16
|
+
*/
|
|
17
|
+
export default class Layer extends EventController {
|
|
18
|
+
/** 层级 */
|
|
19
|
+
zIndex: number;
|
|
20
|
+
protected canvas: HTMLCanvasElement;
|
|
21
|
+
protected ctx: CanvasRenderingContext2D;
|
|
22
|
+
/** 是否需要重新绘制 */
|
|
23
|
+
private isReload;
|
|
24
|
+
groups: Map<string, OverlayGroup>;
|
|
25
|
+
constructor(option: ConstructorOption);
|
|
26
|
+
setMainCanvas(mainCanvas?: _Canvas): void;
|
|
27
|
+
setNotifyReload(notifyReload?: () => void): void;
|
|
28
|
+
setGroupNotifyReload(group: OverlayGroup): void;
|
|
29
|
+
/** 获取覆盖物组 */
|
|
30
|
+
getGroup(name: string): OverlayGroup | undefined;
|
|
31
|
+
/** 添加覆盖物组 */
|
|
32
|
+
addGroup(groups: OverlayGroup | OverlayGroup[]): void;
|
|
33
|
+
/** 移除覆盖物组 */
|
|
34
|
+
removeGroup(groups: OverlayGroup | OverlayGroup[]): void;
|
|
35
|
+
/** 清空覆盖物 */
|
|
36
|
+
clearGroup(): void;
|
|
37
|
+
/** 设置图层的 zIndex 值 */
|
|
38
|
+
setzIndex(zIndex: number): void;
|
|
39
|
+
/** 本次绘制的覆盖物 */
|
|
40
|
+
private currentDrawOverlays;
|
|
41
|
+
/** 获取画布 */
|
|
42
|
+
getCanvas(): [number, HTMLCanvasElement, [[number, number], OverlayType][]] | undefined;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<ArcStyleType, [number, number]>>[0] & {
|
|
5
|
+
/** 是否填充 */
|
|
6
|
+
isFill?: boolean;
|
|
7
|
+
/** 是否闭合 */
|
|
8
|
+
isClosed?: boolean;
|
|
9
|
+
/** 闭合时是否经过中心点 */
|
|
10
|
+
isClosedThroughCenter?: boolean;
|
|
11
|
+
/** 圆弧的半径。必须为正值。 */
|
|
12
|
+
radiusValue?: number;
|
|
13
|
+
/** 圆弧的半径。必须为正值。 */
|
|
14
|
+
radiusPosition?: number;
|
|
15
|
+
/** 圆弧的起始点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
16
|
+
startAngle: number;
|
|
17
|
+
/** 圆弧的终点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
18
|
+
endAngle: number;
|
|
19
|
+
/** 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。默认为 false(顺时针)。 */
|
|
20
|
+
counterclockwise?: boolean;
|
|
21
|
+
/** 是否可显示控制点 */
|
|
22
|
+
isHandlePointsVisible?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export default class Arc extends Overlay<ArcStyleType, [number, number]> {
|
|
25
|
+
private _isFill;
|
|
26
|
+
/** 是否填充 */
|
|
27
|
+
get isFill(): boolean;
|
|
28
|
+
set isFill(isFill: boolean);
|
|
29
|
+
protected _isClosed: boolean;
|
|
30
|
+
/** 是否闭合 */
|
|
31
|
+
get isClosed(): boolean;
|
|
32
|
+
set isClosed(isClosed: boolean);
|
|
33
|
+
private _isClosedThroughCenter;
|
|
34
|
+
/** 闭合时是否经过中心点 */
|
|
35
|
+
get isClosedThroughCenter(): boolean;
|
|
36
|
+
set isClosedThroughCenter(isClosedThroughCenter: boolean);
|
|
37
|
+
private _radiusValue;
|
|
38
|
+
/** 圆弧的半径。必须为正值。 */
|
|
39
|
+
get radiusValue(): number;
|
|
40
|
+
set radiusValue(radius: number);
|
|
41
|
+
private _radiusPosition;
|
|
42
|
+
/** 圆弧的半径。必须为正值。 */
|
|
43
|
+
get radiusPosition(): number;
|
|
44
|
+
set radiusPosition(radius: number);
|
|
45
|
+
private _startAngle;
|
|
46
|
+
/** 圆弧的起始点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
47
|
+
get startAngle(): number;
|
|
48
|
+
set startAngle(startAngle: number);
|
|
49
|
+
private _endAngle;
|
|
50
|
+
/** 圆弧的终点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
51
|
+
get endAngle(): number;
|
|
52
|
+
set endAngle(endAngle: number);
|
|
53
|
+
private _counterclockwise;
|
|
54
|
+
/** 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。默认为 false(顺时针)。 */
|
|
55
|
+
get counterclockwise(): boolean;
|
|
56
|
+
set counterclockwise(counterclockwise: boolean);
|
|
57
|
+
/** 当前是否渲染了控制点 */
|
|
58
|
+
private isShowHandlePoint;
|
|
59
|
+
/** 是否可显示控制点 */
|
|
60
|
+
private _isHandlePointsVisible;
|
|
61
|
+
/** 是否可显示控制点 */
|
|
62
|
+
get isHandlePointsVisible(): boolean;
|
|
63
|
+
set isHandlePointsVisible(value: boolean);
|
|
64
|
+
/** 偏移量 */
|
|
65
|
+
get offset(): {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
};
|
|
69
|
+
set offset(offset: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
});
|
|
73
|
+
constructor(option: ConstructorOption);
|
|
74
|
+
/** 默认点击事件 点击后切换控制点显示状态 */
|
|
75
|
+
defaultClick: EventHandler<"click">;
|
|
76
|
+
/** 处理拖动状态变化 */
|
|
77
|
+
defaultDragg: EventHandler<"dragg">;
|
|
78
|
+
protected updateValueScope(): void;
|
|
79
|
+
isPointInPath(x: number, y: number): boolean;
|
|
80
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
81
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
82
|
+
get cursorStyle(): string | undefined;
|
|
83
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): PolygonStyleType;
|
|
84
|
+
protected get computedValueScopeStyles(): PolygonStyleType;
|
|
85
|
+
/** 控制点 */
|
|
86
|
+
private handlePoints;
|
|
87
|
+
/** 控制点数组 */
|
|
88
|
+
private get handlePointsArr();
|
|
89
|
+
/** 更新控制点 */
|
|
90
|
+
private updateHandlePoints;
|
|
91
|
+
protected updateBaseData(): void;
|
|
92
|
+
/** 绘制辅助虚线 */
|
|
93
|
+
private drawGuideLine;
|
|
94
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
95
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
96
|
+
}
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<ArcToStyleType, [number, number][]>>[0] & {
|
|
5
|
+
/** 是否可显示控制点 */
|
|
6
|
+
isHandlePointsVisible?: boolean;
|
|
7
|
+
/** 圆弧的半径。必须为正值。 */
|
|
8
|
+
radiusValue?: number;
|
|
9
|
+
/** 圆弧的半径。必须为正值。 */
|
|
10
|
+
radiusPosition?: number;
|
|
11
|
+
};
|
|
12
|
+
export default class ArcTo extends Overlay<ArcToStyleType, [number, number][]> {
|
|
13
|
+
/** 控制点 */
|
|
14
|
+
private handlePoints?;
|
|
15
|
+
/** 控制点数组 */
|
|
16
|
+
private get handlePointsArr();
|
|
17
|
+
/** 当前是否渲染了控制点 */
|
|
18
|
+
private isShowHandlePoint;
|
|
19
|
+
/** 是否可显示控制点 */
|
|
20
|
+
private _isHandlePointsVisible;
|
|
21
|
+
/** 是否可显示控制点 */
|
|
22
|
+
get isHandlePointsVisible(): boolean;
|
|
23
|
+
set isHandlePointsVisible(value: boolean);
|
|
24
|
+
private _radiusValue;
|
|
25
|
+
/** 圆弧的半径。必须为正值。 */
|
|
26
|
+
get radiusValue(): number;
|
|
27
|
+
set radiusValue(radius: number);
|
|
28
|
+
private _radiusPosition;
|
|
29
|
+
/** 圆弧的半径。必须为正值。 */
|
|
30
|
+
get radiusPosition(): number;
|
|
31
|
+
set radiusPosition(radius: number);
|
|
32
|
+
constructor(option: ConstructorOption);
|
|
33
|
+
/** 默认点击事件 点击后切换控制点显示状态 */
|
|
34
|
+
defaultClick: EventHandler<"click">;
|
|
35
|
+
/** 处理拖动状态变化 */
|
|
36
|
+
defaultDragg: EventHandler<"dragg">;
|
|
37
|
+
protected updateValueScope(): void;
|
|
38
|
+
isPointInPath(x: number, y: number): boolean;
|
|
39
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
40
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
41
|
+
get cursorStyle(): string;
|
|
42
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): ArcToStyleType;
|
|
43
|
+
protected get computedValueScopeStyles(): ArcToStyleType;
|
|
44
|
+
/** 更新控制点 */
|
|
45
|
+
private updateHandlePoints;
|
|
46
|
+
protected updateBaseData(): void;
|
|
47
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
48
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
type ConstructorOption<T> = ConstructorParameters<typeof Overlay<T, [number, number][]>>[0] & {
|
|
4
|
+
/** 绘制函数 */
|
|
5
|
+
draw: (ctx: CanvasRenderingContext2D) => void;
|
|
6
|
+
};
|
|
7
|
+
export default class Custom<T> extends Overlay<T, [number, number][]> {
|
|
8
|
+
constructor(option: ConstructorOption<T>);
|
|
9
|
+
protected updateValueScope(): void;
|
|
10
|
+
isPointInPath(x: number, y: number): boolean;
|
|
11
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
12
|
+
protected updateBaseData(): void;
|
|
13
|
+
private convertValuesToPositions;
|
|
14
|
+
private convertPositionsToValues;
|
|
15
|
+
private updateDataProperties;
|
|
16
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): any;
|
|
17
|
+
protected get computedValueScopeStyles(): {};
|
|
18
|
+
private _draw?;
|
|
19
|
+
/** 传入的自定义绘制函数 */
|
|
20
|
+
get draw(): (ctx: CanvasRenderingContext2D) => void;
|
|
21
|
+
set draw(draw: (ctx: CanvasRenderingContext2D) => void);
|
|
22
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { default as _Canvas } from '..';
|
|
2
|
+
import { default as EventController } from '../public/eventController';
|
|
3
|
+
import { default as Text } from './text';
|
|
4
|
+
import { default as Point } from './point';
|
|
5
|
+
import { default as Line } from './line';
|
|
6
|
+
import { default as Polygon } from './polygon';
|
|
7
|
+
import { default as Custom } from './custom';
|
|
8
|
+
import { default as Arc } from './arc';
|
|
9
|
+
import { default as ArcTo } from './arcTo';
|
|
10
|
+
type ConstructorOption = ConstructorParameters<typeof EventController>[0];
|
|
11
|
+
export type OverlayType = Text | Point | Line | Arc | ArcTo | Polygon | Custom<any>;
|
|
12
|
+
export default class OverlayGroup extends EventController {
|
|
13
|
+
/** 覆盖物集合 */
|
|
14
|
+
overlays: Set<OverlayType>;
|
|
15
|
+
constructor(option: ConstructorOption);
|
|
16
|
+
/** 设置主画布 */
|
|
17
|
+
setMainCanvas(mainCanvas?: _Canvas): void;
|
|
18
|
+
/** 设置覆盖物重新绘制方法 */
|
|
19
|
+
setNotifyReload(notifyReload?: () => void): void;
|
|
20
|
+
/** 添加覆盖物 */
|
|
21
|
+
addOverlays(overlays: OverlayType[] | OverlayType): void;
|
|
22
|
+
/** 是否包含覆盖物 */
|
|
23
|
+
hasOverlay(overlay: OverlayType): boolean;
|
|
24
|
+
/** 移除覆盖物 */
|
|
25
|
+
removeOverlays(overlays: OverlayType[] | OverlayType): void;
|
|
26
|
+
/** 清空覆盖物 */
|
|
27
|
+
clearOverlays(): void;
|
|
28
|
+
/** 获取覆盖物的绘制方法 */
|
|
29
|
+
getOverlaysDrawingMethod(): [number, [(ctx: CanvasRenderingContext2D) => void, OverlayType]][];
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { OverlayType } from './index';
|
|
2
|
+
import { default as GeometricBoundary } from './public/geometricBoundary';
|
|
3
|
+
type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<LineStyleType>>[0] & {
|
|
4
|
+
/** 是否是 两点相连向外延展的无限线 */
|
|
5
|
+
isInfinite?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default class Line extends GeometricBoundary<LineStyleType> {
|
|
8
|
+
private _isInfinite?;
|
|
9
|
+
/** 是否是 两点相连向外延展的无限线 */
|
|
10
|
+
get isInfinite(): boolean | undefined;
|
|
11
|
+
set isInfinite(isInfinite: boolean | undefined);
|
|
12
|
+
protected isClosed: boolean;
|
|
13
|
+
protected minNeededHandlePoints: number;
|
|
14
|
+
constructor(option: ConstructorOption);
|
|
15
|
+
protected updateValueScope(): void;
|
|
16
|
+
isPointInPath(x: number, y: number): boolean;
|
|
17
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
18
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
19
|
+
protected get isWithinRange(): boolean;
|
|
20
|
+
protected updateBaseData(): void;
|
|
21
|
+
/** 更新动态点位数据 */
|
|
22
|
+
protected updateDynamicPosition(): void;
|
|
23
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): LineStyleType;
|
|
24
|
+
protected get computedValueScopeStyles(): LineStyleType;
|
|
25
|
+
/** 绘制线段 */
|
|
26
|
+
drawLine(ctx: CanvasRenderingContext2D, position?: [number, number][]): void;
|
|
27
|
+
/** 绘制无限延伸线段 */
|
|
28
|
+
drawisInfiniteStraightLine(ctx: CanvasRenderingContext2D): void;
|
|
29
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<PointStyleType, [number, number]>>[0];
|
|
5
|
+
export default class Point extends Overlay<PointStyleType, [number, number]> {
|
|
6
|
+
private angle;
|
|
7
|
+
constructor(option: ConstructorOption);
|
|
8
|
+
protected updateValueScope(): void;
|
|
9
|
+
defaultDragg: EventHandler<"dragg">;
|
|
10
|
+
/** 填充进度 */
|
|
11
|
+
private fillProgress?;
|
|
12
|
+
/** 处理悬停状态变化 */
|
|
13
|
+
defaultHover: EventHandler<"hover">;
|
|
14
|
+
/** 取消当前动画并重新开始相反方向的动画 */
|
|
15
|
+
private cancelAndRestartAnimation;
|
|
16
|
+
/** 开始新的悬停动画 */
|
|
17
|
+
private startNewHoverAnimation;
|
|
18
|
+
/** 更新线宽偏移并触发重绘 */
|
|
19
|
+
private updateLineWidthOffset;
|
|
20
|
+
isPointInPath(x: number, y: number): boolean;
|
|
21
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
22
|
+
protected updateBaseData(): void;
|
|
23
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): {
|
|
24
|
+
radius: number;
|
|
25
|
+
stroke: string;
|
|
26
|
+
width: number;
|
|
27
|
+
fill: string;
|
|
28
|
+
};
|
|
29
|
+
protected get computedValueScopeStyles(): {
|
|
30
|
+
point: {
|
|
31
|
+
radius: number;
|
|
32
|
+
stroke: string;
|
|
33
|
+
width: number;
|
|
34
|
+
fill: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
38
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { OverlayType } from './index';
|
|
2
|
+
import { default as GeometricBoundary } from './public/geometricBoundary';
|
|
3
|
+
type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<PolygonStyleType>>[0] & {
|
|
4
|
+
/** 是否为矩形 */
|
|
5
|
+
isRect?: boolean;
|
|
6
|
+
/** 矩形圆角半径 */
|
|
7
|
+
borderRadius?: number | number[];
|
|
8
|
+
/** 矩形圆角半径类型. 默认为 "position" */
|
|
9
|
+
borderRadiusType?: "position" | "value";
|
|
10
|
+
};
|
|
11
|
+
export default class Polygon extends GeometricBoundary<PolygonStyleType> {
|
|
12
|
+
private _isRect;
|
|
13
|
+
/** 是否为矩形 */
|
|
14
|
+
get isRect(): boolean;
|
|
15
|
+
set isRect(isRect: boolean);
|
|
16
|
+
/** 动态矩形圆角半径 */
|
|
17
|
+
private dynamicBorderRadius?;
|
|
18
|
+
private _borderRadius?;
|
|
19
|
+
/** 矩形圆角半径 */
|
|
20
|
+
get borderRadius(): number | number[] | undefined;
|
|
21
|
+
set borderRadius(borderRadius: number | number[] | undefined);
|
|
22
|
+
private _borderRadiusType;
|
|
23
|
+
/** 矩形圆角半径类型. 默认为 "position" */
|
|
24
|
+
get borderRadiusType(): "position" | "value";
|
|
25
|
+
set borderRadiusType(borderRadiusType: "position" | "value");
|
|
26
|
+
protected isClosed: boolean;
|
|
27
|
+
protected minNeededHandlePoints: number;
|
|
28
|
+
constructor(option: ConstructorOption);
|
|
29
|
+
protected updateValueScope(): void;
|
|
30
|
+
isPointInPath(x: number, y: number): boolean;
|
|
31
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
32
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
33
|
+
/** 更新动态圆角半径 */
|
|
34
|
+
private updateDynamicRadius;
|
|
35
|
+
private handleSingleRadius;
|
|
36
|
+
/** 更新基础数据 */
|
|
37
|
+
protected updateBaseData(): void;
|
|
38
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): PolygonStyleType;
|
|
39
|
+
protected get computedValueScopeStyles(): PolygonStyleType;
|
|
40
|
+
/** 绘制矩形 */
|
|
41
|
+
drawRect(ctx: CanvasRenderingContext2D): void;
|
|
42
|
+
/** 绘制多边形 */
|
|
43
|
+
drawPolygon(ctx: CanvasRenderingContext2D): void;
|
|
44
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { default as Overlay } from './overlay';
|
|
2
|
+
import { default as Point } from '../point';
|
|
3
|
+
import { EventHandler } from '../../public/eventController';
|
|
4
|
+
type PointLocation = [number, number];
|
|
5
|
+
type ConstructorOption<T> = ConstructorParameters<typeof Overlay<T, PointLocation[]>>[0] & {
|
|
6
|
+
/** 是否可显示控制点 */
|
|
7
|
+
isHandlePointsVisible?: boolean;
|
|
8
|
+
/** 是否可以创建新的 控制点 */
|
|
9
|
+
canCreateOrDeleteHandlePoint?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export default abstract class GeometricBoundary<T> extends Overlay<T, PointLocation[]> {
|
|
12
|
+
/** 控制点 */
|
|
13
|
+
protected handlePoints: Point[];
|
|
14
|
+
/** 当前是否渲染了控制点 */
|
|
15
|
+
protected isShowHandlePoint: boolean;
|
|
16
|
+
/** 是否可显示控制点 */
|
|
17
|
+
private _isHandlePointsVisible;
|
|
18
|
+
/** 是否可显示控制点 */
|
|
19
|
+
get isHandlePointsVisible(): boolean;
|
|
20
|
+
set isHandlePointsVisible(value: boolean);
|
|
21
|
+
/** 是否闭合 */
|
|
22
|
+
protected abstract isClosed: boolean;
|
|
23
|
+
/** 是否可以创建新的 控制点 */
|
|
24
|
+
canCreateOrDeleteHandlePoint: boolean;
|
|
25
|
+
/** 最少需要的 控制点 数量 */
|
|
26
|
+
protected abstract minNeededHandlePoints: number;
|
|
27
|
+
/** 锁定是否可创建句柄点 */
|
|
28
|
+
private lockedCanCreateOrDeleteHandlePoint;
|
|
29
|
+
/** 偏移量 */
|
|
30
|
+
get offset(): {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
};
|
|
34
|
+
set offset(offset: {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
});
|
|
38
|
+
constructor(option: ConstructorOption<T>);
|
|
39
|
+
/** 默认点击事件 点击后切换控制点显示状态 */
|
|
40
|
+
defaultClick: EventHandler<"click">;
|
|
41
|
+
/** 默认点击事件 点击后 创建/删除 控制点 */
|
|
42
|
+
defaultDoubleClick: EventHandler<"doubleClick">;
|
|
43
|
+
/** 尝试在指定位置创建新控制点 */
|
|
44
|
+
private tryCreateNewHandlePoint;
|
|
45
|
+
/** 尝试删除指定位置的控制点 */
|
|
46
|
+
private tryDeleteHandlePoint;
|
|
47
|
+
/** 获取扩展后的动态位置 */
|
|
48
|
+
private getExtendedDynamicPositions;
|
|
49
|
+
/** 获取相邻的索引 */
|
|
50
|
+
private getAdjacentIndices;
|
|
51
|
+
/** 创建新的控制点 */
|
|
52
|
+
private createNewHandlePoint;
|
|
53
|
+
/** 插入点 */
|
|
54
|
+
private insertHandlePoint;
|
|
55
|
+
/** 删除点 */
|
|
56
|
+
private deleteHandlePoint;
|
|
57
|
+
/** 锁定点创建 */
|
|
58
|
+
private lockHandlePointCreationTemporarily;
|
|
59
|
+
/** 解锁点创建 */
|
|
60
|
+
private resetHandlePointLock;
|
|
61
|
+
/** 是否可以删除点 */
|
|
62
|
+
private get canDeleteHandlePoint();
|
|
63
|
+
/** 处理拖动状态变化 */
|
|
64
|
+
defaultDragg: EventHandler<"dragg">;
|
|
65
|
+
/** 更新控制点 */
|
|
66
|
+
protected updateHandlePoints(): void;
|
|
67
|
+
/** 更新控制点位置 */
|
|
68
|
+
protected updateHandlePointsPosition(): void;
|
|
69
|
+
}
|
|
70
|
+
export {};
|