nhanh-pure-function 3.0.5 → 3.0.6-beta.10
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/Canvas/LayerGroup/index.d.ts +30 -0
- package/dist/Canvas/LayerGroup/layer.d.ts +44 -0
- package/dist/Canvas/OverlayGroup/arc.d.ts +98 -0
- package/dist/Canvas/OverlayGroup/arcTo.d.ts +51 -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 +32 -0
- package/dist/Canvas/OverlayGroup/point.d.ts +41 -0
- package/dist/Canvas/OverlayGroup/polygon.d.ts +47 -0
- package/dist/Canvas/OverlayGroup/public/geometricBoundary.d.ts +70 -0
- package/dist/Canvas/OverlayGroup/public/overlay.d.ts +176 -0
- package/dist/Canvas/OverlayGroup/text.d.ts +28 -0
- package/dist/Canvas/common.type.d.ts +117 -0
- package/dist/Canvas/core/axis.d.ts +43 -0
- package/dist/Canvas/core/basedata.d.ts +178 -0
- package/dist/Canvas/core/draw.d.ts +33 -0
- package/dist/Canvas/core/event.d.ts +77 -0
- package/dist/Canvas/core/quikmethod.d.ts +106 -0
- package/dist/Canvas/core/style.d.ts +24 -0
- package/dist/Canvas/index.d.ts +70 -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/File/index.d.ts +24 -4
- package/dist/Format/index.d.ts +36 -0
- package/dist/Math/index.d.ts +6 -0
- package/dist/Types/index.d.ts +39 -0
- package/dist/Utility/index.d.ts +14 -29
- package/dist/Utility/type.d.ts +10 -0
- package/dist/Valid/index.d.ts +2 -8
- package/dist/Valid/type.d.ts +1 -1
- package/dist/index.cjs.js +9 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.es.js +5512 -779
- package/package.json +4 -1
|
@@ -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,98 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
import { ArcStyleType, PolygonStyleType } from '../common.type';
|
|
5
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<ArcStyleType, [number, number]>>[0] & {
|
|
6
|
+
/** 是否填充 */
|
|
7
|
+
isFill?: boolean;
|
|
8
|
+
/** 是否闭合 */
|
|
9
|
+
isClosed?: boolean;
|
|
10
|
+
/** 闭合时是否经过中心点 */
|
|
11
|
+
isClosedThroughCenter?: boolean;
|
|
12
|
+
/** 圆弧的半径。必须为正值。 */
|
|
13
|
+
radiusValue?: number;
|
|
14
|
+
/** 圆弧的半径。必须为正值。 */
|
|
15
|
+
radiusPosition?: number;
|
|
16
|
+
/** 圆弧的起始点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
17
|
+
startAngle: number;
|
|
18
|
+
/** 圆弧的终点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
19
|
+
endAngle: number;
|
|
20
|
+
/** 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。默认为 false(顺时针)。 */
|
|
21
|
+
counterclockwise?: boolean;
|
|
22
|
+
/** 是否可显示控制点 */
|
|
23
|
+
isHandlePointsVisible?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export default class Arc extends Overlay<ArcStyleType, [number, number]> {
|
|
26
|
+
private _isFill;
|
|
27
|
+
/** 是否填充 */
|
|
28
|
+
get isFill(): boolean;
|
|
29
|
+
set isFill(isFill: boolean);
|
|
30
|
+
protected _isClosed: boolean;
|
|
31
|
+
/** 是否闭合 */
|
|
32
|
+
get isClosed(): boolean;
|
|
33
|
+
set isClosed(isClosed: boolean);
|
|
34
|
+
private _isClosedThroughCenter;
|
|
35
|
+
/** 闭合时是否经过中心点 */
|
|
36
|
+
get isClosedThroughCenter(): boolean;
|
|
37
|
+
set isClosedThroughCenter(isClosedThroughCenter: boolean);
|
|
38
|
+
private _radiusValue;
|
|
39
|
+
/** 圆弧的半径。必须为正值。 */
|
|
40
|
+
get radiusValue(): number;
|
|
41
|
+
set radiusValue(radius: number);
|
|
42
|
+
private _radiusPosition;
|
|
43
|
+
/** 圆弧的半径。必须为正值。 */
|
|
44
|
+
get radiusPosition(): number;
|
|
45
|
+
set radiusPosition(radius: number);
|
|
46
|
+
private _startAngle;
|
|
47
|
+
/** 圆弧的起始点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
48
|
+
get startAngle(): number;
|
|
49
|
+
set startAngle(startAngle: number);
|
|
50
|
+
private _endAngle;
|
|
51
|
+
/** 圆弧的终点,从 x 轴方向开始计算,以弧度为单位。 */
|
|
52
|
+
get endAngle(): number;
|
|
53
|
+
set endAngle(endAngle: number);
|
|
54
|
+
private _counterclockwise;
|
|
55
|
+
/** 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。默认为 false(顺时针)。 */
|
|
56
|
+
get counterclockwise(): boolean;
|
|
57
|
+
set counterclockwise(counterclockwise: boolean);
|
|
58
|
+
/** 当前是否渲染了控制点 */
|
|
59
|
+
private isShowHandlePoint;
|
|
60
|
+
/** 是否可显示控制点 */
|
|
61
|
+
private _isHandlePointsVisible;
|
|
62
|
+
/** 是否可显示控制点 */
|
|
63
|
+
get isHandlePointsVisible(): boolean;
|
|
64
|
+
set isHandlePointsVisible(value: boolean);
|
|
65
|
+
/** 偏移量 */
|
|
66
|
+
get offset(): {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
70
|
+
set offset(offset: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
});
|
|
74
|
+
constructor(option: ConstructorOption);
|
|
75
|
+
/** 默认点击事件 点击后切换控制点显示状态 */
|
|
76
|
+
defaultClick: EventHandler<"click">;
|
|
77
|
+
/** 处理拖动状态变化 */
|
|
78
|
+
defaultDragg: EventHandler<"dragg">;
|
|
79
|
+
protected updateValueScope(): void;
|
|
80
|
+
isPointInPath(x: number, y: number): boolean;
|
|
81
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
82
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
83
|
+
get cursorStyle(): string | undefined;
|
|
84
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): PolygonStyleType;
|
|
85
|
+
protected get computedValueScopeStyles(): PolygonStyleType;
|
|
86
|
+
/** 控制点 */
|
|
87
|
+
private handlePoints;
|
|
88
|
+
/** 控制点数组 */
|
|
89
|
+
private get handlePointsArr();
|
|
90
|
+
/** 更新控制点 */
|
|
91
|
+
private updateHandlePoints;
|
|
92
|
+
protected updateBaseData(): void;
|
|
93
|
+
/** 绘制辅助虚线 */
|
|
94
|
+
private drawGuideLine;
|
|
95
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
96
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
97
|
+
}
|
|
98
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
import { ArcToStyleType } from '../common.type';
|
|
5
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<ArcToStyleType, [number, number][]>>[0] & {
|
|
6
|
+
/** 是否可显示控制点 */
|
|
7
|
+
isHandlePointsVisible?: boolean;
|
|
8
|
+
/** 圆弧的半径。必须为正值。 */
|
|
9
|
+
radiusValue?: number;
|
|
10
|
+
/** 圆弧的半径。必须为正值。 */
|
|
11
|
+
radiusPosition?: number;
|
|
12
|
+
};
|
|
13
|
+
export default class ArcTo extends Overlay<ArcToStyleType, [number, number][]> {
|
|
14
|
+
/** 控制点 */
|
|
15
|
+
private handlePoints?;
|
|
16
|
+
/** 控制点数组 */
|
|
17
|
+
private get handlePointsArr();
|
|
18
|
+
/** 当前是否渲染了控制点 */
|
|
19
|
+
private isShowHandlePoint;
|
|
20
|
+
/** 是否可显示控制点 */
|
|
21
|
+
private _isHandlePointsVisible;
|
|
22
|
+
/** 是否可显示控制点 */
|
|
23
|
+
get isHandlePointsVisible(): boolean;
|
|
24
|
+
set isHandlePointsVisible(value: boolean);
|
|
25
|
+
private _radiusValue;
|
|
26
|
+
/** 圆弧的半径。必须为正值。 */
|
|
27
|
+
get radiusValue(): number;
|
|
28
|
+
set radiusValue(radius: number);
|
|
29
|
+
private _radiusPosition;
|
|
30
|
+
/** 圆弧的半径。必须为正值。 */
|
|
31
|
+
get radiusPosition(): number;
|
|
32
|
+
set radiusPosition(radius: number);
|
|
33
|
+
constructor(option: ConstructorOption);
|
|
34
|
+
/** 默认点击事件 点击后切换控制点显示状态 */
|
|
35
|
+
defaultClick: EventHandler<"click">;
|
|
36
|
+
/** 处理拖动状态变化 */
|
|
37
|
+
defaultDragg: EventHandler<"dragg">;
|
|
38
|
+
protected updateValueScope(): void;
|
|
39
|
+
isPointInPath(x: number, y: number): boolean;
|
|
40
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
41
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
42
|
+
get cursorStyle(): string;
|
|
43
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): ArcToStyleType;
|
|
44
|
+
protected get computedValueScopeStyles(): ArcToStyleType;
|
|
45
|
+
/** 更新控制点 */
|
|
46
|
+
private updateHandlePoints;
|
|
47
|
+
protected updateBaseData(): void;
|
|
48
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
49
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
50
|
+
}
|
|
51
|
+
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,32 @@
|
|
|
1
|
+
import { OverlayType } from './index';
|
|
2
|
+
import { default as GeometricBoundary } from './public/geometricBoundary';
|
|
3
|
+
import { LineStyleType } from '../common.type';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<LineStyleType>>[0] & {
|
|
5
|
+
/** 是否是 两点相连向外延展的无限线 */
|
|
6
|
+
isInfinite?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export default class Line extends GeometricBoundary<LineStyleType> {
|
|
9
|
+
private _isInfinite?;
|
|
10
|
+
/** 是否是 两点相连向外延展的无限线 */
|
|
11
|
+
get isInfinite(): boolean | undefined;
|
|
12
|
+
set isInfinite(isInfinite: boolean | undefined);
|
|
13
|
+
protected isClosed: boolean;
|
|
14
|
+
protected minNeededHandlePoints: number;
|
|
15
|
+
constructor(option: ConstructorOption);
|
|
16
|
+
protected updateValueScope(): void;
|
|
17
|
+
isPointInPath(x: number, y: number): boolean;
|
|
18
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
19
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
20
|
+
protected get isWithinRange(): boolean;
|
|
21
|
+
protected updateBaseData(): void;
|
|
22
|
+
/** 更新动态点位数据 */
|
|
23
|
+
protected updateDynamicPosition(): void;
|
|
24
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): LineStyleType;
|
|
25
|
+
protected get computedValueScopeStyles(): LineStyleType;
|
|
26
|
+
/** 绘制线段 */
|
|
27
|
+
drawLine(ctx: CanvasRenderingContext2D, position?: [number, number][]): void;
|
|
28
|
+
/** 绘制无限延伸线段 */
|
|
29
|
+
drawisInfiniteStraightLine(ctx: CanvasRenderingContext2D): void;
|
|
30
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { default as Overlay } from './public/overlay';
|
|
2
|
+
import { OverlayType } from './index';
|
|
3
|
+
import { EventHandler } from '../public/eventController';
|
|
4
|
+
import { PointStyleType } from '../common.type';
|
|
5
|
+
type ConstructorOption = ConstructorParameters<typeof Overlay<PointStyleType, [number, number]>>[0];
|
|
6
|
+
export default class Point extends Overlay<PointStyleType, [number, number]> {
|
|
7
|
+
private angle;
|
|
8
|
+
constructor(option: ConstructorOption);
|
|
9
|
+
protected updateValueScope(): void;
|
|
10
|
+
defaultDragg: EventHandler<"dragg">;
|
|
11
|
+
/** 填充进度 */
|
|
12
|
+
private fillProgress?;
|
|
13
|
+
/** 处理悬停状态变化 */
|
|
14
|
+
defaultHover: EventHandler<"hover">;
|
|
15
|
+
/** 取消当前动画并重新开始相反方向的动画 */
|
|
16
|
+
private cancelAndRestartAnimation;
|
|
17
|
+
/** 开始新的悬停动画 */
|
|
18
|
+
private startNewHoverAnimation;
|
|
19
|
+
/** 更新线宽偏移并触发重绘 */
|
|
20
|
+
private updateLineWidthOffset;
|
|
21
|
+
isPointInPath(x: number, y: number): boolean;
|
|
22
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
23
|
+
protected updateBaseData(): void;
|
|
24
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): {
|
|
25
|
+
radius: number;
|
|
26
|
+
stroke: string;
|
|
27
|
+
width: number;
|
|
28
|
+
fill: string;
|
|
29
|
+
};
|
|
30
|
+
protected get computedValueScopeStyles(): {
|
|
31
|
+
point: {
|
|
32
|
+
radius: number;
|
|
33
|
+
stroke: string;
|
|
34
|
+
width: number;
|
|
35
|
+
fill: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
draw(ctx: CanvasRenderingContext2D): void;
|
|
39
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { OverlayType } from './index';
|
|
2
|
+
import { default as GeometricBoundary } from './public/geometricBoundary';
|
|
3
|
+
import { PolygonStyleType } from '../common.type';
|
|
4
|
+
type ConstructorOption = ConstructorParameters<typeof GeometricBoundary<PolygonStyleType>>[0] & {
|
|
5
|
+
/** 是否为矩形 */
|
|
6
|
+
isRect?: boolean;
|
|
7
|
+
/** 矩形圆角半径 */
|
|
8
|
+
borderRadius?: number | number[];
|
|
9
|
+
/** 矩形圆角半径类型. 默认为 "position" */
|
|
10
|
+
borderRadiusType?: "position" | "value";
|
|
11
|
+
};
|
|
12
|
+
export default class Polygon extends GeometricBoundary<PolygonStyleType> {
|
|
13
|
+
private _isRect;
|
|
14
|
+
/** 是否为矩形 */
|
|
15
|
+
get isRect(): boolean;
|
|
16
|
+
set isRect(isRect: boolean);
|
|
17
|
+
/** 动态矩形圆角半径 */
|
|
18
|
+
private dynamicBorderRadius?;
|
|
19
|
+
private _borderRadius?;
|
|
20
|
+
/** 矩形圆角半径 */
|
|
21
|
+
get borderRadius(): number | number[] | undefined;
|
|
22
|
+
set borderRadius(borderRadius: number | number[] | undefined);
|
|
23
|
+
private _borderRadiusType;
|
|
24
|
+
/** 矩形圆角半径类型. 默认为 "position" */
|
|
25
|
+
get borderRadiusType(): "position" | "value";
|
|
26
|
+
set borderRadiusType(borderRadiusType: "position" | "value");
|
|
27
|
+
protected isClosed: boolean;
|
|
28
|
+
protected minNeededHandlePoints: number;
|
|
29
|
+
constructor(option: ConstructorOption);
|
|
30
|
+
protected updateValueScope(): void;
|
|
31
|
+
isPointInPath(x: number, y: number): boolean;
|
|
32
|
+
isPointInStroke(x: number, y: number): boolean;
|
|
33
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
34
|
+
/** 更新动态圆角半径 */
|
|
35
|
+
private updateDynamicRadius;
|
|
36
|
+
private handleSingleRadius;
|
|
37
|
+
/** 更新基础数据 */
|
|
38
|
+
protected updateBaseData(): void;
|
|
39
|
+
protected setOverlayStyles(ctx?: CanvasRenderingContext2D): PolygonStyleType;
|
|
40
|
+
protected get computedValueScopeStyles(): PolygonStyleType;
|
|
41
|
+
/** 绘制矩形 */
|
|
42
|
+
drawRect(ctx: CanvasRenderingContext2D): void;
|
|
43
|
+
/** 绘制多边形 */
|
|
44
|
+
drawPolygon(ctx: CanvasRenderingContext2D): void;
|
|
45
|
+
getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
46
|
+
}
|
|
47
|
+
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 {};
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { default as _Canvas } from '../..';
|
|
2
|
+
import { OverlayType } from '../index';
|
|
3
|
+
import { EventHandler, default as EventController } from '../../public/eventController';
|
|
4
|
+
import { _Type_DeepPartial } from '../../..';
|
|
5
|
+
import { BaseLineStyle, PointStyleType } from '../../common.type';
|
|
6
|
+
type ConstructorOption<T, V> = ConstructorParameters<typeof EventController>[0] & {
|
|
7
|
+
/** 样式 */
|
|
8
|
+
style?: _Type_DeepPartial<T> | string;
|
|
9
|
+
/** 层级 */
|
|
10
|
+
zIndex?: number;
|
|
11
|
+
/** 坐标轴上的点位 */
|
|
12
|
+
position?: V;
|
|
13
|
+
/** 动态点位 */
|
|
14
|
+
dynamicPosition?: V;
|
|
15
|
+
/** 坐标轴上的值 */
|
|
16
|
+
value?: V;
|
|
17
|
+
/** 偏移 */
|
|
18
|
+
offset?: {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
};
|
|
22
|
+
/** 鼠标移入时是否重新绘制 */
|
|
23
|
+
redrawOnIsHoverChange?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export default abstract class Overlay<T, V extends [number, number] | [number, number][]> extends EventController {
|
|
26
|
+
static ctx: CanvasRenderingContext2D;
|
|
27
|
+
private _style?;
|
|
28
|
+
/** 样式 */
|
|
29
|
+
get style(): Overlay<T, V>["_style"] | undefined;
|
|
30
|
+
set style(style: Overlay<T, V>["_style"] | undefined);
|
|
31
|
+
private _position?;
|
|
32
|
+
/** 坐标轴上的点位 */
|
|
33
|
+
get position(): V | undefined;
|
|
34
|
+
set position(position: V | undefined);
|
|
35
|
+
private _value?;
|
|
36
|
+
/** 坐标轴上的值 */
|
|
37
|
+
get value(): V | undefined;
|
|
38
|
+
set value(value: V | undefined);
|
|
39
|
+
private _zIndex;
|
|
40
|
+
/** 层级 */
|
|
41
|
+
get zIndex(): number;
|
|
42
|
+
set zIndex(zIndex: number);
|
|
43
|
+
private _dynamicPosition?;
|
|
44
|
+
/** 动态点位 */
|
|
45
|
+
get dynamicPosition(): V | undefined;
|
|
46
|
+
private set dynamicPosition(value);
|
|
47
|
+
private _offset;
|
|
48
|
+
/** 偏移量 */
|
|
49
|
+
get offset(): {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
set offset(offset: {
|
|
54
|
+
x: number;
|
|
55
|
+
y: number;
|
|
56
|
+
});
|
|
57
|
+
/** 最终的动态位置(含:偏移) */
|
|
58
|
+
get finalDynamicPosition(): V;
|
|
59
|
+
/** 绘制路径 */
|
|
60
|
+
path?: Path2D;
|
|
61
|
+
constructor(option: ConstructorOption<T, V>);
|
|
62
|
+
/** 内部使用的属性映射表,请勿修改 */
|
|
63
|
+
private readonly publicToPrivateKeyMap;
|
|
64
|
+
/** 请勿在实体对象中调用此方法,此方法仅用于类内部无副作用更新 (请勿使用!) */
|
|
65
|
+
internalUpdate(option: {
|
|
66
|
+
offset?: {
|
|
67
|
+
x: number;
|
|
68
|
+
y: number;
|
|
69
|
+
};
|
|
70
|
+
position?: V;
|
|
71
|
+
value?: V;
|
|
72
|
+
dynamicPosition?: V;
|
|
73
|
+
zIndex?: number;
|
|
74
|
+
style?: _Type_DeepPartial<T> | string;
|
|
75
|
+
}, updateValueScope?: boolean): void;
|
|
76
|
+
/** 鼠标移入时是否重新绘制 */
|
|
77
|
+
redrawOnIsHoverChange: boolean;
|
|
78
|
+
/** 默认 hover 事件 */
|
|
79
|
+
defaultHover: EventHandler<"hover">;
|
|
80
|
+
setMainCanvas(mainCanvas?: _Canvas): void;
|
|
81
|
+
setNotifyReload(notifyReload?: () => void): void;
|
|
82
|
+
/** 值范围 */
|
|
83
|
+
private _valueScope?;
|
|
84
|
+
/** 值范围 */
|
|
85
|
+
get valueScope(): {
|
|
86
|
+
minX: number;
|
|
87
|
+
maxX: number;
|
|
88
|
+
minY: number;
|
|
89
|
+
maxY: number;
|
|
90
|
+
} | undefined;
|
|
91
|
+
private set valueScope(value);
|
|
92
|
+
/** 更新值范围 */
|
|
93
|
+
protected abstract updateValueScope(): void;
|
|
94
|
+
/** 初始化值范围 */
|
|
95
|
+
protected initValueScope(): void;
|
|
96
|
+
/** 计算 valueScope 所需要的样式 */
|
|
97
|
+
protected abstract get computedValueScopeStyles(): {
|
|
98
|
+
stroke?: BaseLineStyle;
|
|
99
|
+
point?: PointStyleType;
|
|
100
|
+
};
|
|
101
|
+
/** 描边半径值 */
|
|
102
|
+
private styleRadius;
|
|
103
|
+
/** 计算样式半径值 */
|
|
104
|
+
protected calculateStyleRadiusValue(uselastFact?: boolean): {
|
|
105
|
+
radius: number;
|
|
106
|
+
value: number;
|
|
107
|
+
} | undefined;
|
|
108
|
+
/** 额外偏移 */
|
|
109
|
+
private offsetValue;
|
|
110
|
+
/** 计算偏移 */
|
|
111
|
+
protected calculateOffsetValue(uselastFact?: boolean): void;
|
|
112
|
+
/** 固定的额外范围 */
|
|
113
|
+
private fixedExtraScope;
|
|
114
|
+
/** 初始化设置固定的额外范围 */
|
|
115
|
+
protected setFixedExtraScope(init: true): void;
|
|
116
|
+
/** 设置固定的额外范围 */
|
|
117
|
+
protected setFixedExtraScope(fixedExtraScope?: {
|
|
118
|
+
topV: number;
|
|
119
|
+
bottomV: number;
|
|
120
|
+
leftV: number;
|
|
121
|
+
rightV: number;
|
|
122
|
+
}): void;
|
|
123
|
+
/** 额外范围 */
|
|
124
|
+
private extraScope;
|
|
125
|
+
/** 初始化设置额外范围 */
|
|
126
|
+
protected setExtraScope(init: true): void;
|
|
127
|
+
/** 更新额外范围 */
|
|
128
|
+
protected setExtraScope(): void;
|
|
129
|
+
/** 设置新的额外范围 */
|
|
130
|
+
protected setExtraScope(extraScope?: {
|
|
131
|
+
top: number;
|
|
132
|
+
bottom: number;
|
|
133
|
+
left: number;
|
|
134
|
+
right: number;
|
|
135
|
+
}): void;
|
|
136
|
+
/** 判断是否在可视范围内 */
|
|
137
|
+
protected get isWithinRange(): boolean;
|
|
138
|
+
/** 判断是否需要渲染 */
|
|
139
|
+
protected get isNeedRender(): boolean;
|
|
140
|
+
/** 计算偏移量 */
|
|
141
|
+
protected calculateOffset(offsetX: number, offsetY: number): {
|
|
142
|
+
x: {
|
|
143
|
+
value: number;
|
|
144
|
+
position: number;
|
|
145
|
+
dynamicPosition: number;
|
|
146
|
+
};
|
|
147
|
+
y: {
|
|
148
|
+
value: number;
|
|
149
|
+
position: number;
|
|
150
|
+
dynamicPosition: number;
|
|
151
|
+
};
|
|
152
|
+
};
|
|
153
|
+
/** 处理一维数组的坐标数据 */
|
|
154
|
+
protected handleValuePosition(type: "array1D"): boolean;
|
|
155
|
+
/** 处理二维数组的坐标数据 */
|
|
156
|
+
protected handleValuePosition(type: "array2D", minLen: number): boolean;
|
|
157
|
+
/** 更新基础数据 */
|
|
158
|
+
protected abstract updateBaseData(): void;
|
|
159
|
+
/** 判断当前路径中是否包含指定点 */
|
|
160
|
+
abstract isPointInPath(x: number, y: number): boolean;
|
|
161
|
+
/** 检测某点是否在路径的描边所在的区域内 */
|
|
162
|
+
abstract isPointInStroke(x: number, y: number): boolean;
|
|
163
|
+
/** 检测某点是否在当前覆盖物中 */
|
|
164
|
+
isPointInAnywhere(x: number, y: number): boolean;
|
|
165
|
+
/** 设置透明度 */
|
|
166
|
+
setGlobalAlpha(ctx: CanvasRenderingContext2D): void;
|
|
167
|
+
/** 绘制线基础样式 */
|
|
168
|
+
protected setBaseLineStyle(ctx: CanvasRenderingContext2D, style: BaseLineStyle): BaseLineStyle;
|
|
169
|
+
/** 设置画布样式 */
|
|
170
|
+
protected abstract setOverlayStyles(ctx?: CanvasRenderingContext2D): T;
|
|
171
|
+
/** 光标样式 */
|
|
172
|
+
get cursorStyle(): string | undefined;
|
|
173
|
+
/** 获取绘制函数 */
|
|
174
|
+
abstract getDraw(): [(ctx: CanvasRenderingContext2D) => void, OverlayType] | void;
|
|
175
|
+
}
|
|
176
|
+
export {};
|