mudlet-map-renderer 0.28.0-konva → 0.29.1-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.
@@ -1,5 +1,9 @@
1
1
  import { Settings } from './types/Settings';
2
2
  import { GroupNode, LayerNode } from './backend/DrawingBackend';
3
+ export type CoordinateTransform = (x: number, y: number) => {
4
+ x: number;
5
+ y: number;
6
+ };
3
7
  export type RoomNodeEntry = {
4
8
  room: MapData.Room;
5
9
  group: GroupNode;
@@ -48,7 +52,11 @@ export declare class CullingManager {
48
52
  private standaloneExitBoundsRoomSize?;
49
53
  private cullingScheduled;
50
54
  private perfMonitor;
55
+ private coordinateTransform;
51
56
  constructor(stageInfo: StageInfo, roomLayer: LayerNode, linkLayer: LayerNode, settings: Settings);
57
+ setCoordinateTransform(fn: CoordinateTransform): void;
58
+ private transformPoint;
59
+ private transformBounds;
52
60
  computeBucketSize(): void;
53
61
  clear(): void;
54
62
  private getBucketKey;
@@ -10,7 +10,12 @@ export declare class GridRenderer {
10
10
  private readonly settings;
11
11
  private readonly backend;
12
12
  private cachedBounds;
13
+ private inverseTransform;
13
14
  constructor(layer: LayerNode, settings: Settings, backend: DrawingBackend);
15
+ setInverseTransform(fn: (x: number, y: number) => {
16
+ x: number;
17
+ y: number;
18
+ }): void;
14
19
  invalidateCache(): void;
15
20
  render(viewportBounds: ViewportBounds): void;
16
21
  }
@@ -0,0 +1,30 @@
1
+ import { DrawingBackend, GroupNode, RectConfig, CircleConfig, LineConfig, PolygonConfig, TextConfig, ImageConfig } from './DrawingBackend';
2
+ /**
3
+ * Decorator that wraps a DrawingBackend and remaps all colors to a
4
+ * technical blueprint aesthetic (white lines on deep blue).
5
+ *
6
+ * - **Fills** are mapped through a luminance-based blue gradient
7
+ * (deep blue → lighter blue) so different environment colors stay
8
+ * visually distinct while keeping the blueprint look.
9
+ * - **Strokes** become light cyan-white.
10
+ * - **Text** uses near-white blue for legibility.
11
+ * - **Images** pass through unchanged.
12
+ *
13
+ * For the best result, also adjust the map settings:
14
+ * ```ts
15
+ * settings.backgroundColor = '#0a1628';
16
+ * settings.lineColor = '#4a7ab5';
17
+ * settings.fontFamily = '"Courier New", monospace';
18
+ * ```
19
+ */
20
+ export declare class BlueprintBackend implements DrawingBackend {
21
+ private readonly inner;
22
+ constructor(inner: DrawingBackend);
23
+ createGroup(x: number, y: number): GroupNode;
24
+ addRect(parent: GroupNode, config: RectConfig): void;
25
+ addCircle(parent: GroupNode, config: CircleConfig): void;
26
+ addLine(parent: GroupNode, config: LineConfig): void;
27
+ addPolygon(parent: GroupNode, config: PolygonConfig): void;
28
+ addText(parent: GroupNode, config: TextConfig): void;
29
+ addImage(parent: GroupNode, config: ImageConfig): void;
30
+ }
@@ -75,6 +75,9 @@ export interface TextConfig {
75
75
  baselineRatio?: number;
76
76
  /** Konva vertical correction: offsetY = ratio * fontSize shifts text up to true visual centre. */
77
77
  konvaCorrectionRatio?: number;
78
+ /** Optional 2D affine transform [a, b, c, d, e, f] applied to the text.
79
+ * When set, the text is drawn at the origin and the matrix positions/skews it. */
80
+ transform?: [number, number, number, number, number, number];
78
81
  }
79
82
  export interface ImageConfig {
80
83
  x: number;
@@ -82,6 +85,9 @@ export interface ImageConfig {
82
85
  width: number;
83
86
  height: number;
84
87
  src: string;
88
+ /** Optional 2D affine transform [a, b, c, d, e, f] applied to the image.
89
+ * When set, x/y/width/height describe the source rect; the matrix positions the output. */
90
+ transform?: [number, number, number, number, number, number];
85
91
  }
86
92
  export interface DrawingBackend {
87
93
  createGroup(x: number, y: number): GroupNode;
@@ -0,0 +1,76 @@
1
+ import { DrawingBackend, GroupNode, RectConfig, CircleConfig, LineConfig, PolygonConfig, TextConfig, ImageConfig } from './DrawingBackend';
2
+ /**
3
+ * Rotation angle in degrees for the isometric view.
4
+ * Any number is accepted. Common presets:
5
+ *
6
+ * | Angle | Effect |
7
+ * |-------|--------|
8
+ * | 0 | Standard iso — north points upper-right |
9
+ * | 30 | Gentle tilt — north near top, subtle depth |
10
+ * | 45 | North points straight up, max depth feel |
11
+ * | 90 | North points upper-left |
12
+ */
13
+ export type IsometricRotation = number;
14
+ /**
15
+ * Decorator that wraps a DrawingBackend and projects all geometry through a
16
+ * 2:1 isometric transformation.
17
+ *
18
+ * - **Rectangles** become diamond (rhombus) polygons.
19
+ * - **Circles** become ellipse polygons.
20
+ * - **Lines** and **polygons** have their coordinates transformed.
21
+ * - **Text** is repositioned but stays upright for readability.
22
+ * - **Images** are repositioned with dimensions preserved.
23
+ *
24
+ * When `depth > 0`, rooms gain two visible cube side faces (right lighter,
25
+ * left darker) drawn beneath the top face diamond for a 3D block effect.
26
+ *
27
+ * Composes with other decorators — recommended order:
28
+ * ```ts
29
+ * // Isometric cubes with parchment colors and hand-drawn wobble
30
+ * new IsometricBackend(
31
+ * new SketchyBackend(new ParchmentBackend(new KonvaBackend()), 0.012, '#4a3728'),
32
+ * { depth: 0.18, rotation: 90 },
33
+ * );
34
+ * ```
35
+ */
36
+ export declare class IsometricBackend implements DrawingBackend {
37
+ private readonly inner;
38
+ private readonly depth;
39
+ private readonly iso;
40
+ private readonly isoInv;
41
+ /**
42
+ * @param inner The backend to delegate to after iso-transforming coordinates.
43
+ * @param options Depth (cube side face height, default 0.18) and rotation (0/90/180/270, default 0).
44
+ */
45
+ constructor(inner: DrawingBackend, options?: {
46
+ depth?: number;
47
+ rotation?: IsometricRotation;
48
+ } | number);
49
+ private ix;
50
+ private iy;
51
+ private isoFlatPoints;
52
+ private rectToDiamond;
53
+ createGroup(x: number, y: number): GroupNode;
54
+ addRect(parent: GroupNode, config: RectConfig): void;
55
+ addCircle(parent: GroupNode, config: CircleConfig): void;
56
+ addLine(parent: GroupNode, config: LineConfig): void;
57
+ addPolygon(parent: GroupNode, config: PolygonConfig): void;
58
+ /**
59
+ * Compute the 2D affine transform [a, b, c, d, e, f] that maps a rect
60
+ * at (x, y, w, h) in local space to its iso-projected parallelogram.
61
+ */
62
+ private isoAffine;
63
+ addText(parent: GroupNode, config: TextConfig): void;
64
+ addImage(parent: GroupNode, config: ImageConfig): void;
65
+ /**
66
+ * Returns the iso transform function for use with CullingManager.setCoordinateTransform().
67
+ */
68
+ getTransform(): (x: number, y: number) => {
69
+ x: number;
70
+ y: number;
71
+ };
72
+ getInverseTransform(): (x: number, y: number) => {
73
+ x: number;
74
+ y: number;
75
+ };
76
+ }
@@ -0,0 +1,28 @@
1
+ import { DrawingBackend, GroupNode, RectConfig, CircleConfig, LineConfig, PolygonConfig, TextConfig, ImageConfig } from './DrawingBackend';
2
+ /**
3
+ * Decorator that wraps a DrawingBackend and remaps all colors to a
4
+ * cyberpunk/neon aesthetic — glowing colored outlines on a dark background.
5
+ *
6
+ * - **Fills** become very dark with a subtle tint of the original hue.
7
+ * - **Strokes** become bright neon colors (hue-preserved, saturation/lightness boosted).
8
+ * - A **glow** effect is achieved by drawing a wider translucent stroke underneath.
9
+ * - **Text** uses bright cyan-green.
10
+ * - **Images** pass through unchanged.
11
+ *
12
+ * For the best result, also adjust the map settings:
13
+ * ```ts
14
+ * settings.backgroundColor = '#0a0a0f';
15
+ * settings.lineColor = '#00ffaa';
16
+ * ```
17
+ */
18
+ export declare class NeonBackend implements DrawingBackend {
19
+ private readonly inner;
20
+ constructor(inner: DrawingBackend);
21
+ createGroup(x: number, y: number): GroupNode;
22
+ addRect(parent: GroupNode, config: RectConfig): void;
23
+ addCircle(parent: GroupNode, config: CircleConfig): void;
24
+ addLine(parent: GroupNode, config: LineConfig): void;
25
+ addPolygon(parent: GroupNode, config: PolygonConfig): void;
26
+ addText(parent: GroupNode, config: TextConfig): void;
27
+ addImage(parent: GroupNode, config: ImageConfig): void;
28
+ }
@@ -0,0 +1,43 @@
1
+ import { DrawingBackend, GroupNode, RectConfig, CircleConfig, LineConfig, PolygonConfig, TextConfig, ImageConfig } from './DrawingBackend';
2
+ /**
3
+ * Decorator that wraps a DrawingBackend and remaps all colors to a
4
+ * warm sepia / old-parchment palette.
5
+ *
6
+ * - **Fills** are mapped through a luminance-based parchment gradient
7
+ * (dark brown → light parchment) so different environment colors stay
8
+ * visually distinct while keeping the aged-paper look.
9
+ * - **Strokes** become dark ink brown.
10
+ * - **Text** uses a very dark brown for legibility.
11
+ * - **Images** pass through unchanged.
12
+ *
13
+ * Composes naturally with {@link SketchyBackend} for the full old-map aesthetic:
14
+ * ```ts
15
+ * // Parchment colors only
16
+ * const backend = new ParchmentBackend(new KonvaBackend());
17
+ *
18
+ * // Parchment + hand-drawn wobble
19
+ * const backend = new SketchyBackend(
20
+ * new ParchmentBackend(new KonvaBackend()),
21
+ * 0.012, '#4a3728',
22
+ * );
23
+ * ```
24
+ *
25
+ * For the best result, also adjust the map settings:
26
+ * ```ts
27
+ * settings.backgroundColor = '#f4e4c1';
28
+ * settings.lineColor = '#5c4033';
29
+ * settings.gridColor = 'rgba(139, 119, 101, 0.15)';
30
+ * settings.fontFamily = 'Georgia, serif';
31
+ * ```
32
+ */
33
+ export declare class ParchmentBackend implements DrawingBackend {
34
+ private readonly inner;
35
+ constructor(inner: DrawingBackend);
36
+ createGroup(x: number, y: number): GroupNode;
37
+ addRect(parent: GroupNode, config: RectConfig): void;
38
+ addCircle(parent: GroupNode, config: CircleConfig): void;
39
+ addLine(parent: GroupNode, config: LineConfig): void;
40
+ addPolygon(parent: GroupNode, config: PolygonConfig): void;
41
+ addText(parent: GroupNode, config: TextConfig): void;
42
+ addImage(parent: GroupNode, config: ImageConfig): void;
43
+ }