mudlet-map-renderer 0.32.0-konva → 0.33.0-konva
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/backend/CanvasBackend.d.ts +129 -0
- package/dist/backend/DrawingBackend.d.ts +6 -0
- package/dist/backend/KonvaBackend.d.ts +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +560 -323
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { default as Konva } from 'konva';
|
|
2
|
+
import { DrawingBackend, GroupNode, LayerNode, CoordFn, RectConfig, CircleConfig, LineConfig, PolygonConfig, TextConfig, ImageConfig } from './DrawingBackend';
|
|
3
|
+
type RectCommand = {
|
|
4
|
+
type: 'rect';
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
fill?: string;
|
|
10
|
+
stroke?: string;
|
|
11
|
+
sw: number;
|
|
12
|
+
cr: number;
|
|
13
|
+
dash?: number[];
|
|
14
|
+
};
|
|
15
|
+
type CircleCommand = {
|
|
16
|
+
type: 'circle';
|
|
17
|
+
cx: number;
|
|
18
|
+
cy: number;
|
|
19
|
+
r: number;
|
|
20
|
+
fill?: string;
|
|
21
|
+
stroke?: string;
|
|
22
|
+
sw: number;
|
|
23
|
+
dash?: number[];
|
|
24
|
+
};
|
|
25
|
+
type LineCommand = {
|
|
26
|
+
type: 'line';
|
|
27
|
+
points: number[];
|
|
28
|
+
stroke?: string;
|
|
29
|
+
sw: number;
|
|
30
|
+
dash?: number[];
|
|
31
|
+
lineCap?: string;
|
|
32
|
+
lineJoin?: string;
|
|
33
|
+
alpha?: number;
|
|
34
|
+
};
|
|
35
|
+
type PolygonCommand = {
|
|
36
|
+
type: 'polygon';
|
|
37
|
+
vertices: number[];
|
|
38
|
+
fill?: string;
|
|
39
|
+
stroke?: string;
|
|
40
|
+
sw: number;
|
|
41
|
+
};
|
|
42
|
+
type TextCommand = {
|
|
43
|
+
type: 'text';
|
|
44
|
+
x: number;
|
|
45
|
+
y: number;
|
|
46
|
+
text: string;
|
|
47
|
+
fontSize: number;
|
|
48
|
+
fontFamily: string;
|
|
49
|
+
fontStyle: string;
|
|
50
|
+
fill: string;
|
|
51
|
+
align: string;
|
|
52
|
+
vAlign: string;
|
|
53
|
+
w: number;
|
|
54
|
+
h: number;
|
|
55
|
+
baselineRatio?: number;
|
|
56
|
+
transform?: [number, number, number, number, number, number];
|
|
57
|
+
};
|
|
58
|
+
type ImageCommand = {
|
|
59
|
+
type: 'image';
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
w: number;
|
|
63
|
+
h: number;
|
|
64
|
+
image: HTMLImageElement | any;
|
|
65
|
+
transform?: [number, number, number, number, number, number];
|
|
66
|
+
};
|
|
67
|
+
type DrawCommand = RectCommand | CircleCommand | LineCommand | PolygonCommand | TextCommand | ImageCommand;
|
|
68
|
+
export declare class RecordingGroupNode implements GroupNode {
|
|
69
|
+
x: number;
|
|
70
|
+
y: number;
|
|
71
|
+
_visible: boolean;
|
|
72
|
+
readonly commands: DrawCommand[];
|
|
73
|
+
/** Lazily created when this group is materialized for a KonvaLayerNode. */
|
|
74
|
+
_konvaGroup?: Konva.Group;
|
|
75
|
+
constructor(x: number, y: number);
|
|
76
|
+
setVisible(visible: boolean): void;
|
|
77
|
+
isVisible(): boolean;
|
|
78
|
+
destroy(): void;
|
|
79
|
+
setPosition(x: number, y: number): void;
|
|
80
|
+
getPosition(): {
|
|
81
|
+
x: number;
|
|
82
|
+
y: number;
|
|
83
|
+
};
|
|
84
|
+
moveToTop(): void;
|
|
85
|
+
/**
|
|
86
|
+
* Materialize this recording as a Konva.Group + Konva.Shape.
|
|
87
|
+
* Used when the group is added to a KonvaLayerNode (overlay/position layers).
|
|
88
|
+
*/
|
|
89
|
+
materialize(): Konva.Group;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* A LayerNode backed by a single Konva.Shape whose sceneFunc replays
|
|
93
|
+
* all recorded groups. Much faster than individual Konva nodes.
|
|
94
|
+
*/
|
|
95
|
+
export declare class RecordingLayerNode implements LayerNode {
|
|
96
|
+
private groups;
|
|
97
|
+
private readonly konvaLayer;
|
|
98
|
+
private konvaShape;
|
|
99
|
+
constructor(konvaLayer: Konva.Layer);
|
|
100
|
+
private ensureShape;
|
|
101
|
+
addNode(node: GroupNode): void;
|
|
102
|
+
destroyChildren(): void;
|
|
103
|
+
batchDraw(): void;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* DrawingBackend that records draw commands into RecordingGroupNodes.
|
|
107
|
+
* Commands are replayed via Canvas2D in a single Konva.Shape sceneFunc
|
|
108
|
+
* per layer, eliminating per-node Konva overhead.
|
|
109
|
+
*
|
|
110
|
+
* Drop-in replacement for KonvaBackend. Decorator backends wrap this
|
|
111
|
+
* the same way they wrap KonvaBackend.
|
|
112
|
+
*/
|
|
113
|
+
export declare class CanvasBackend implements DrawingBackend {
|
|
114
|
+
createGroup(x: number, y: number): RecordingGroupNode;
|
|
115
|
+
addRect(parent: GroupNode, config: RectConfig): void;
|
|
116
|
+
addCircle(parent: GroupNode, config: CircleConfig): void;
|
|
117
|
+
addLine(parent: GroupNode, config: LineConfig): void;
|
|
118
|
+
addPolygon(parent: GroupNode, config: PolygonConfig): void;
|
|
119
|
+
addText(parent: GroupNode, config: TextConfig): void;
|
|
120
|
+
addImage(parent: GroupNode, config: ImageConfig): void;
|
|
121
|
+
supportsBatchExitRendering(): boolean;
|
|
122
|
+
getExitDepthOffset(): {
|
|
123
|
+
x: number;
|
|
124
|
+
y: number;
|
|
125
|
+
};
|
|
126
|
+
getTransform(): CoordFn;
|
|
127
|
+
getInverseTransform(): CoordFn;
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
@@ -103,6 +103,12 @@ export interface DrawingBackend {
|
|
|
103
103
|
addPolygon(parent: GroupNode, config: PolygonConfig): void;
|
|
104
104
|
addText(parent: GroupNode, config: TextConfig): void;
|
|
105
105
|
addImage(parent: GroupNode, config: ImageConfig): void;
|
|
106
|
+
/**
|
|
107
|
+
* Whether this backend supports batch exit rendering via a single Canvas2D shape.
|
|
108
|
+
* When true, link exits are collected as ExitDrawData and drawn in one batched
|
|
109
|
+
* Konva.Shape sceneFunc instead of creating individual nodes per exit.
|
|
110
|
+
*/
|
|
111
|
+
supportsBatchExitRendering?(): boolean;
|
|
106
112
|
/**
|
|
107
113
|
* Cartesian offset for exit line groups so they connect at the cube base
|
|
108
114
|
* instead of the top face. Returns {x:0, y:0} for flat backends.
|
|
@@ -34,6 +34,7 @@ export declare class KonvaBackend implements DrawingBackend {
|
|
|
34
34
|
addPolygon(parent: GroupNode, config: PolygonConfig): void;
|
|
35
35
|
addText(parent: GroupNode, config: TextConfig): void;
|
|
36
36
|
addImage(parent: GroupNode, config: ImageConfig): void;
|
|
37
|
+
supportsBatchExitRendering(): boolean;
|
|
37
38
|
getExitDepthOffset(): {
|
|
38
39
|
x: number;
|
|
39
40
|
y: number;
|