mudlet-map-renderer 1.0.0 → 1.2.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.
Files changed (106) hide show
  1. package/README.md +520 -0
  2. package/dist/AreaMapRenderer.d.ts +125 -0
  3. package/dist/CullingManager.d.ts +15 -0
  4. package/dist/ExitRenderer.d.ts +109 -0
  5. package/dist/InteractionHandler.d.ts +47 -0
  6. package/dist/MapGraph.d.ts +28 -0
  7. package/dist/MapReader-mU_4JWv_.js +224 -0
  8. package/dist/MapReader-mU_4JWv_.js.map +1 -0
  9. package/dist/MapState.d.ts +110 -0
  10. package/dist/PathData.d.ts +18 -0
  11. package/dist/PathFinder.d.ts +12 -0
  12. package/dist/ScenePipeline.d.ts +226 -0
  13. package/dist/SvgTypes.d.ts +21 -0
  14. package/dist/TypedEventEmitter.d.ts +17 -0
  15. package/dist/binary/BinaryMapReader.d.ts +36 -0
  16. package/dist/binary/index.d.ts +2 -0
  17. package/dist/binary.mjs +34 -0
  18. package/dist/binary.mjs.map +1 -0
  19. package/dist/camera/Camera.d.ts +118 -0
  20. package/dist/coord/CoordFn.d.ts +13 -0
  21. package/dist/directions.d.ts +25 -0
  22. package/dist/draw/DrawCommand.d.ts +104 -0
  23. package/dist/draw/DrawCommandBuilder.d.ts +19 -0
  24. package/dist/export/CanvasExporter.d.ts +71 -0
  25. package/dist/export/Exporter.d.ts +58 -0
  26. package/dist/export/PngExporter.d.ts +23 -0
  27. package/dist/export/SvgExporter.d.ts +19 -0
  28. package/dist/export/canvasToBytes.d.ts +19 -0
  29. package/dist/export/clipSceneToViewport.d.ts +48 -0
  30. package/dist/export/flushSceneShapes.d.ts +21 -0
  31. package/dist/export/sceneBounds.d.ts +24 -0
  32. package/dist/hit/HitTester.d.ts +101 -0
  33. package/dist/index.d.ts +61 -0
  34. package/dist/index.mjs +6670 -0
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/lens/ExplorationLens.d.ts +29 -0
  37. package/dist/lens/RoomLens.d.ts +47 -0
  38. package/dist/lens/composeLenses.d.ts +31 -0
  39. package/dist/lens/index.d.ts +5 -0
  40. package/dist/overlay/AmbientLightOverlay.d.ts +32 -0
  41. package/dist/overlay/LiveEffect.d.ts +33 -0
  42. package/dist/overlay/SceneOverlay.d.ts +68 -0
  43. package/dist/reader/Area.d.ts +63 -0
  44. package/dist/reader/Exit.d.ts +15 -0
  45. package/dist/reader/MapReader.d.ts +34 -0
  46. package/dist/reader/Plane.d.ts +33 -0
  47. package/dist/render/CanvasRenderer.d.ts +17 -0
  48. package/dist/render/RecordingLayer.d.ts +158 -0
  49. package/dist/render/SvgRenderer.d.ts +7 -0
  50. package/dist/render/shapeToRecording.d.ts +3 -0
  51. package/dist/rendering/KonvaRenderBackend.d.ts +122 -0
  52. package/dist/rendering/MapRenderer.d.ts +213 -0
  53. package/dist/rendering/SceneManager.d.ts +54 -0
  54. package/dist/scene/AmbientLightStyle.d.ts +29 -0
  55. package/dist/scene/GridStyle.d.ts +21 -0
  56. package/dist/scene/InnerExitStyle.d.ts +24 -0
  57. package/dist/scene/OverlayStyle.d.ts +47 -0
  58. package/dist/scene/RoomStyle.d.ts +32 -0
  59. package/dist/scene/Shape.d.ts +151 -0
  60. package/dist/scene/SpecialExitStyle.d.ts +37 -0
  61. package/dist/scene/StubStyle.d.ts +15 -0
  62. package/dist/scene/elements/ExitLayout.d.ts +22 -0
  63. package/dist/scene/elements/GridLayout.d.ts +24 -0
  64. package/dist/scene/elements/LabelLayout.d.ts +11 -0
  65. package/dist/scene/elements/OverlayLayout.d.ts +14 -0
  66. package/dist/scene/elements/RoomLayout.d.ts +19 -0
  67. package/dist/scene/elements/SpecialExitLayout.d.ts +19 -0
  68. package/dist/scene/elements/StubLayout.d.ts +19 -0
  69. package/dist/style/Style.d.ts +60 -0
  70. package/dist/style/applyStyle.d.ts +3 -0
  71. package/dist/style/index.d.ts +21 -0
  72. package/dist/style/shape/BlueprintStyle.d.ts +11 -0
  73. package/dist/style/shape/ConstructionStyle.d.ts +17 -0
  74. package/dist/style/shape/IsometricStyle.d.ts +32 -0
  75. package/dist/style/shape/NeonStyle.d.ts +17 -0
  76. package/dist/style/shape/ParchmentStyle.d.ts +13 -0
  77. package/dist/style/shape/SciFiStyle.d.ts +16 -0
  78. package/dist/style/shape/SketchyStyle.d.ts +22 -0
  79. package/dist/style/shape/index.d.ts +25 -0
  80. package/dist/style/shape/paintMap.d.ts +25 -0
  81. package/dist/style/shape/wobble.d.ts +24 -0
  82. package/{src/types/MapData.ts → dist/types/MapData.d.ts} +70 -90
  83. package/dist/types/Settings.d.ts +206 -0
  84. package/dist/utils/color.d.ts +12 -0
  85. package/dist/utils/textMeasure.d.ts +38 -0
  86. package/package.json +67 -37
  87. package/demo/colors.json +0 -1
  88. package/demo/index.html +0 -102
  89. package/demo/main.ts +0 -389
  90. package/demo/mapExport.json +0 -1
  91. package/demo/tsconfig.json +0 -11
  92. package/src/ExitRenderer.ts +0 -275
  93. package/src/PathFinder.ts +0 -93
  94. package/src/PathRenderer.ts +0 -129
  95. package/src/Renderer.ts +0 -374
  96. package/src/directions.ts +0 -66
  97. package/src/index.ts +0 -4
  98. package/src/reader/Area.ts +0 -96
  99. package/src/reader/Exit.ts +0 -36
  100. package/src/reader/ExplorationArea.ts +0 -132
  101. package/src/reader/MapReader.ts +0 -123
  102. package/src/reader/Plane.ts +0 -42
  103. package/tsconfig.json +0 -17
  104. package/vercel.json +0 -5
  105. package/vite.config.ts +0 -29
  106. package/vite.demo.config.ts +0 -15
@@ -0,0 +1,151 @@
1
+ /**
2
+ * SceneIR — pure data shapes that {@link ScenePipeline} produces.
3
+ *
4
+ * Shapes carry world-space coordinates and engine-agnostic paint information.
5
+ * They are consumed by:
6
+ * - {@link CullingManager} (visibility queries against a camera viewport)
7
+ * - {@link HitTester} (point→shape lookup)
8
+ * - {@link DrawCommandBuilder} (translation to engine {@link DrawCommand}s)
9
+ *
10
+ * Shapes know nothing about Konva, SVG, or Canvas2D.
11
+ */
12
+ /** Logical layer for stacking. Mapped to engine-specific layers by renderers. */
13
+ export type LayerId = "grid" | "link" | "room" | "position" | "overlay" | "top";
14
+ /** Engine-agnostic paint description. */
15
+ export interface Paint {
16
+ fill?: string;
17
+ stroke?: string;
18
+ strokeWidth?: number;
19
+ dash?: number[];
20
+ dashEnabled?: boolean;
21
+ /** 0..1 multiplier on fill+stroke. */
22
+ alpha?: number;
23
+ }
24
+ /** Hit-test annotation. Set on shapes that should be pickable. */
25
+ export interface HitInfo {
26
+ /** What the shape represents at the model layer. */
27
+ kind: "room" | "exit" | "specialExit" | "stub" | "label" | "areaExit" | string;
28
+ /** Identifier of the owning model entity (room id, exit id, …). */
29
+ id?: number | string;
30
+ /** Free-form payload returned to callers from {@link HitTester}. */
31
+ payload?: unknown;
32
+ /**
33
+ * Multiplier on the current `roomSize` for the maximum pick distance.
34
+ * Smaller = stricter (used for thin geometry like exits and stubs).
35
+ * Defaults to a per-kind value when omitted (rooms 1.0, exits 0.35, stubs 0.3, …).
36
+ */
37
+ margin?: number;
38
+ /**
39
+ * Tiebreaker when multiple hits are within range. Higher = on top.
40
+ * Defaults to a per-kind value when omitted (rooms over exits over stubs, …).
41
+ */
42
+ priority?: number;
43
+ }
44
+ /** Common fields on every shape. */
45
+ export interface ShapeBase {
46
+ /** Logical layer; defaults to "room" when omitted. */
47
+ layer?: LayerId;
48
+ /** Set on shapes that participate in hit testing. */
49
+ hit?: HitInfo;
50
+ /**
51
+ * If true, the shape renders at a fixed pixel size regardless of camera
52
+ * zoom. Mirrors the legacy `GroupNode.noScaling` flag.
53
+ */
54
+ noScale?: boolean;
55
+ }
56
+ export interface RectShape extends ShapeBase {
57
+ type: "rect";
58
+ x: number;
59
+ y: number;
60
+ width: number;
61
+ height: number;
62
+ cornerRadius?: number;
63
+ paint: Paint;
64
+ }
65
+ export interface CircleShape extends ShapeBase {
66
+ type: "circle";
67
+ cx: number;
68
+ cy: number;
69
+ radius: number;
70
+ paint: Paint;
71
+ }
72
+ export interface LineShape extends ShapeBase {
73
+ type: "line";
74
+ /** Flat list of [x0, y0, x1, y1, …]. */
75
+ points: number[];
76
+ paint: Paint;
77
+ lineCap?: "butt" | "round" | "square";
78
+ lineJoin?: "miter" | "round" | "bevel";
79
+ /**
80
+ * Marks lines that are infrastructure (grid). Styles use this to skip
81
+ * decoration on grid (cheaper rendering) while still recolouring it.
82
+ */
83
+ grid?: boolean;
84
+ }
85
+ export interface PolygonShape extends ShapeBase {
86
+ type: "polygon";
87
+ /** Flat list of [x0, y0, x1, y1, …]. Closed implicitly. */
88
+ vertices: number[];
89
+ paint: Paint;
90
+ }
91
+ export interface TextShape extends ShapeBase {
92
+ type: "text";
93
+ x: number;
94
+ y: number;
95
+ text: string;
96
+ fontSize: number;
97
+ fontFamily?: string;
98
+ fontStyle?: string;
99
+ fill?: string;
100
+ stroke?: string;
101
+ strokeWidth?: number;
102
+ align?: "left" | "center" | "right";
103
+ verticalAlign?: "top" | "middle" | "bottom";
104
+ width?: number;
105
+ height?: number;
106
+ /** Fraction of fontSize from top to baseline (SVG positioning). */
107
+ baselineRatio?: number;
108
+ /** Konva offsetY ratio applied to centre text vertically. */
109
+ konvaCorrectionRatio?: number;
110
+ /** Optional 2D affine transform [a, b, c, d, e, f]. */
111
+ transform?: [number, number, number, number, number, number];
112
+ }
113
+ export interface ImageShape extends ShapeBase {
114
+ type: "image";
115
+ x: number;
116
+ y: number;
117
+ width: number;
118
+ height: number;
119
+ src: string;
120
+ /** Optional 2D affine transform [a, b, c, d, e, f]. */
121
+ transform?: [number, number, number, number, number, number];
122
+ }
123
+ /**
124
+ * Positional container. Children render relative to {@link x}, {@link y}.
125
+ * Groups can nest; the final world position of a child is the cumulative
126
+ * sum of group origins plus the child's own offset.
127
+ */
128
+ export interface GroupShape extends ShapeBase {
129
+ type: "group";
130
+ x: number;
131
+ y: number;
132
+ children: Shape[];
133
+ }
134
+ export type Shape = RectShape | CircleShape | LineShape | PolygonShape | TextShape | ImageShape | GroupShape;
135
+ /** Axis-aligned bounding box in world space. */
136
+ export interface Bbox {
137
+ minX: number;
138
+ minY: number;
139
+ maxX: number;
140
+ maxY: number;
141
+ }
142
+ /**
143
+ * Full output of one {@link ScenePipeline} build pass. Consumers slice this by
144
+ * layer and feed the relevant subset into culling, hit-testing, and rendering.
145
+ */
146
+ export interface SceneIR {
147
+ /** All shapes for the current scene, world-space. */
148
+ shapes: Shape[];
149
+ /** Optional pre-computed bbox for whole-scene framing. */
150
+ bounds?: Bbox;
151
+ }
@@ -0,0 +1,37 @@
1
+ import { Settings } from '../types/Settings';
2
+ export type SpecialExitLineData = {
3
+ points: number[];
4
+ stroke: string;
5
+ strokeWidth: number;
6
+ dash?: number[];
7
+ };
8
+ export type SpecialExitArrowData = {
9
+ tipX: number;
10
+ tipY: number;
11
+ x1: number;
12
+ y1: number;
13
+ x2: number;
14
+ y2: number;
15
+ fill: string;
16
+ stroke: string;
17
+ strokeWidth: number;
18
+ };
19
+ export type SpecialExitDoorData = {
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ stroke: string;
25
+ strokeWidth: number;
26
+ };
27
+ export type SpecialExitData = {
28
+ /** Exit name (customLines key) — short or long form as stored on the room. */
29
+ dir: string;
30
+ line: SpecialExitLineData;
31
+ arrow?: SpecialExitArrowData;
32
+ door?: SpecialExitDoorData;
33
+ };
34
+ /**
35
+ * Compute draw data for all custom lines (special exits) on a room.
36
+ */
37
+ export declare function computeSpecialExits(room: MapData.Room, settings: Settings, colorOverride?: string): SpecialExitData[];
@@ -0,0 +1,15 @@
1
+ import { Settings } from '../types/Settings';
2
+ export type StubData = {
3
+ roomId: number;
4
+ direction: MapData.direction;
5
+ x1: number;
6
+ y1: number;
7
+ x2: number;
8
+ y2: number;
9
+ stroke: string;
10
+ strokeWidth: number;
11
+ };
12
+ /**
13
+ * Compute stub line data for a room's one-way exit indicators.
14
+ */
15
+ export declare function computeStubs(room: MapData.Room, settings: Settings, colorOverride?: string): StubData[];
@@ -0,0 +1,22 @@
1
+ import { IMapReader } from '../../reader/MapReader';
2
+ import { Settings } from '../../types/Settings';
3
+ import { ExitDrawData } from '../../ExitRenderer';
4
+ import { GroupShape, HitInfo, PolygonShape } from '../Shape';
5
+ /**
6
+ * Pure layout for a room's inner exits (up/down/in/out triangles). Returns
7
+ * polygon shapes in coordinates relative to the room's top-left, ready to
8
+ * drop into the room's GroupShape as children.
9
+ */
10
+ export declare function layoutInnerExits(room: MapData.Room, mapReader: IMapReader, settings: Settings): PolygonShape[];
11
+ /**
12
+ * Pure layout for a single inter-room link exit, given its computed
13
+ * {@link ExitDrawData}. Returns a {@link GroupShape} at the world origin;
14
+ * the active {@link Style} (e.g. Isometric) is responsible for any
15
+ * cube-base offset on the link layer.
16
+ *
17
+ * `hit` is optional — callers that want the exit to participate in
18
+ * hit-testing pass an {@link HitInfo} carrying the exit identity (a, b,
19
+ * aDir, bDir). Omitted for one-off exit shapes used in current-room
20
+ * overlays where the exit isn't independently pickable.
21
+ */
22
+ export declare function layoutLinkExit(data: ExitDrawData, hit?: HitInfo): GroupShape;
@@ -0,0 +1,24 @@
1
+ import { Settings, ViewportBounds } from '../../types/Settings';
2
+ import { LineShape } from '../Shape';
3
+ export interface GridLayoutOptions {
4
+ /** Inverse coordinate transform (rendered → Cartesian) for warped pipelines. */
5
+ inverseTransform?: (x: number, y: number) => {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ }
10
+ /**
11
+ * Pure layout for the background grid. Returns the line shapes that span the
12
+ * given viewport bounds with one extra grid step of buffer on every edge.
13
+ *
14
+ * Returns an empty array when grids are disabled. Caching is the caller's
15
+ * responsibility (the previous renderer cached by snapped bounds).
16
+ */
17
+ export declare function layoutGrid(viewportBounds: ViewportBounds, settings: Settings, options?: GridLayoutOptions): LineShape[];
18
+ /** Snapped bounds — for cache-key comparison by callers. */
19
+ export declare function gridSnappedBounds(viewportBounds: ViewportBounds, settings: Settings, options?: GridLayoutOptions): {
20
+ left: number;
21
+ right: number;
22
+ top: number;
23
+ bottom: number;
24
+ } | null;
@@ -0,0 +1,11 @@
1
+ import { Settings } from '../../types/Settings';
2
+ import { GroupShape } from '../Shape';
3
+ /**
4
+ * Pure layout for one user-defined label. Returns a {@link GroupShape}, or
5
+ * `null` when the label is suppressed by `labelRenderMode === "none"`.
6
+ *
7
+ * `noScaling` labels are anchored at (X, -Y) with content at (0,0) so the
8
+ * RecordingLayerNode can cancel out stage zoom for those groups only — the
9
+ * group origin / child origin split mirrors that requirement.
10
+ */
11
+ export declare function labelToShape(label: MapData.Label, settings: Settings): GroupShape | null;
@@ -0,0 +1,14 @@
1
+ import { HighlightData, PathOverlayData, PositionMarkerData } from '../OverlayStyle';
2
+ import { Shape } from '../Shape';
3
+ /**
4
+ * Build a highlight ring around a room. Circle rooms get a single dashed
5
+ * stroke; rectangular variants get four independent dashed lines (wrapped in
6
+ * a group) so the corner dashes line up cleanly — each side's dash pattern
7
+ * starts fresh at the corner instead of wrapping continuously around the
8
+ * perimeter (same approach as the backend renderer).
9
+ */
10
+ export declare function highlightToShape(data: HighlightData): Shape;
11
+ /** Build the player-position marker. */
12
+ export declare function positionMarkerToShape(data: PositionMarkerData): Shape;
13
+ /** Build a path overlay: outline + inner colour line per segment, plus directional triangles. */
14
+ export declare function pathToShapes(data: PathOverlayData): Shape[];
@@ -0,0 +1,19 @@
1
+ import { IMapReader } from '../../reader/MapReader';
2
+ import { Settings } from '../../types/Settings';
3
+ import { GroupShape } from '../Shape';
4
+ export interface RoomLayoutOptions {
5
+ /** Override stroke colour (used for highlighted rooms). */
6
+ strokeOverride?: string;
7
+ /**
8
+ * Whether the active style preserves a flat coordinate space. Iso-style
9
+ * pipelines pass `false` to suppress concentric rings (which would render
10
+ * as flat diamonds outside the cube footprint).
11
+ */
12
+ flatPipeline: boolean;
13
+ }
14
+ /**
15
+ * Pure layout for a single room. Returns a {@link GroupShape} positioned at
16
+ * the room's top-left, with rect/circle/line/text children for the body,
17
+ * border, emboss, and symbol.
18
+ */
19
+ export declare function layoutRoom(room: MapData.Room, mapReader: IMapReader, settings: Settings, options: RoomLayoutOptions): GroupShape;
@@ -0,0 +1,19 @@
1
+ import { Settings } from '../../types/Settings';
2
+ import { SpecialExitData } from '../SpecialExitStyle';
3
+ import { GroupShape } from '../Shape';
4
+ export interface SpecialExitLayoutOptions {
5
+ /** Stroke override (used by highlighted-room overlays). */
6
+ colorOverride?: string;
7
+ }
8
+ /**
9
+ * Build a {@link GroupShape} for a single already-computed special-exit
10
+ * record. Lets callers compute the data once (e.g. ScenePipeline records
11
+ * `drawnSpecialExits` for hit-testing) and reuse it for layout.
12
+ */
13
+ export declare function specialExitToShape(se: SpecialExitData, roomId: number): GroupShape;
14
+ /**
15
+ * Pure layout for a room's custom-line special exits. Returns one
16
+ * {@link GroupShape} per special exit at the world origin; the active
17
+ * {@link Style} applies any depth offset for the link layer.
18
+ */
19
+ export declare function layoutSpecialExits(room: MapData.Room, settings: Settings, options?: SpecialExitLayoutOptions): GroupShape[];
@@ -0,0 +1,19 @@
1
+ import { Settings } from '../../types/Settings';
2
+ import { StubData } from '../StubStyle';
3
+ import { GroupShape } from '../Shape';
4
+ export interface StubLayoutOptions {
5
+ /** Stroke override (used by highlighted-room overlays). */
6
+ colorOverride?: string;
7
+ }
8
+ /**
9
+ * Build a {@link GroupShape} for a single already-computed stub. Lets callers
10
+ * compute the data once and reuse it for both layout and hit-testing records.
11
+ */
12
+ export declare function stubToShape(stub: StubData): GroupShape;
13
+ /**
14
+ * Pure layout for a room's stub indicators (the short lines for each entry
15
+ * in `room.stubs`). Returns one {@link GroupShape} per stub at the world
16
+ * origin; the active {@link Style} applies any depth offset for the link
17
+ * layer.
18
+ */
19
+ export declare function layoutStubs(room: MapData.Room, settings: Settings, options?: StubLayoutOptions): GroupShape[];
@@ -0,0 +1,60 @@
1
+ import { Shape } from '../scene/Shape';
2
+ /** Per-frame context passed to style transforms. */
3
+ export interface StyleContext {
4
+ /** Camera scale (BASE_SCALE * zoom). */
5
+ scale: number;
6
+ /** Active room size in world units (for jitter / depth tuning). */
7
+ roomSize: number;
8
+ }
9
+ export interface Style {
10
+ /**
11
+ * Transform one shape into one or more shapes. Implementations should be
12
+ * pure: same input + context → same output. Group children are walked by
13
+ * the caller (the pipeline / a wrapper); transforms see leaf shapes and
14
+ * group shapes as-is.
15
+ */
16
+ transform(shape: Shape, ctx: StyleContext): Shape | Shape[];
17
+ /**
18
+ * Optional world-space → scene-space coordinate map for styles that warp
19
+ * coordinates (e.g. Isometric). When set, {@link HitTester} and
20
+ * {@link Camera} use the inverse to translate clicks back to map space.
21
+ */
22
+ worldToScene?(x: number, y: number): {
23
+ x: number;
24
+ y: number;
25
+ };
26
+ /** Inverse of {@link worldToScene}. */
27
+ sceneToWorld?(x: number, y: number): {
28
+ x: number;
29
+ y: number;
30
+ };
31
+ }
32
+ /** Identity style — passes shapes through unchanged. */
33
+ export declare const identityStyle: Style;
34
+ /**
35
+ * Compose a chain of styles into a single style. Shapes flow **left → right**:
36
+ * the leftmost style transforms first, the rightmost transforms last and gets
37
+ * the final say on the emitted shapes.
38
+ *
39
+ * Order matters in two ways:
40
+ *
41
+ * 1. **Shape-changing styles must come before styles that depend on the new
42
+ * geometry.** {@link sketchyShapeStyle} converts rect/circle into polygon,
43
+ * and {@link isometricShapeStyle} only extrudes rect/circle into cubes — so
44
+ * Iso must run before Sketchy or the cubes never form.
45
+ * 2. **Paint-rewriting styles overwrite earlier paint choices.** Put the style
46
+ * whose colour palette you want on screen *last*: in
47
+ * `compose(Sketchy(...), Parchment)` Parchment recolours Sketchy's pencil
48
+ * fills/strokes into the parchment palette; reverse the order and Sketchy
49
+ * repaints over Parchment's choices.
50
+ *
51
+ * Example — isometric parchment cubes with hand-drawn wobble:
52
+ * ```ts
53
+ * compose(
54
+ * Isometric({depth, rotation}), // rects → cube-face polygons
55
+ * Sketchy({jitter, color: '#4a3728'}), // wobble each polygon
56
+ * Parchment, // recolour to parchment palette
57
+ * );
58
+ * ```
59
+ */
60
+ export declare function compose(...styles: Style[]): Style;
@@ -0,0 +1,3 @@
1
+ import { Shape } from '../scene/Shape';
2
+ import { Style, StyleContext } from './Style';
3
+ export declare function applyStyleToShapes(shapes: Shape[], style: Style, ctx: StyleContext): Shape[];
@@ -0,0 +1,21 @@
1
+ import { Style } from './Style';
2
+ import { SketchyOptions } from './shape/SketchyStyle';
3
+ import { IsometricOptions, IsometricRotation } from './shape/IsometricStyle';
4
+ export { compose, identityStyle } from './Style';
5
+ export type { Style, StyleContext } from './Style';
6
+ export { applyStyleToShapes } from './applyStyle';
7
+ /** Warm sepia / old-parchment palette. */
8
+ export declare const Parchment: Style;
9
+ /** Technical blueprint aesthetic — white lines on deep blue. */
10
+ export declare const Blueprint: Style;
11
+ /** Cyberpunk / neon aesthetic — glowing outlines on dark background. */
12
+ export declare const Neon: Style;
13
+ /** Hand-drawn pencil wobble. */
14
+ export declare function Sketchy(options: SketchyOptions): Style;
15
+ /** 2:1 isometric projection with optional cube depth. */
16
+ export declare function Isometric(options?: IsometricOptions): Style;
17
+ /** Construction-site hazard aesthetic — safety yellow on asphalt, orange exits. */
18
+ export declare const Construction: Style;
19
+ /** Sci-fi / space-exploration aesthetic — holographic cyan glow on void black. */
20
+ export declare const SciFi: Style;
21
+ export type { SketchyOptions, IsometricOptions, IsometricRotation };
@@ -0,0 +1,11 @@
1
+ import { Style } from '../Style';
2
+ /**
3
+ * Technical blueprint aesthetic as a {@link Style} — white lines on deep blue.
4
+ *
5
+ * - Fills are mapped through a luminance-based blue gradient (deep blue →
6
+ * lighter blue) so environment differences stay visible.
7
+ * - Strokes become light cyan-white.
8
+ * - Text uses near-white blue for legibility.
9
+ * - Images and groups pass through unchanged.
10
+ */
11
+ export declare const blueprintShapeStyle: Style;
@@ -0,0 +1,17 @@
1
+ import { Style } from '../Style';
2
+ /**
3
+ * Construction-site hazard aesthetic as a {@link Style}.
4
+ *
5
+ * Rect rooms get diagonal yellow/black stripes: the rect is rendered as a
6
+ * dark asphalt base, then yellow stripe polygons (clipped to the room bounds
7
+ * via Sutherland-Hodgman) are emitted on top, then the black border is drawn
8
+ * last so room edges stay crisp. The stripe period scales with `roomSize`
9
+ * so markings look consistent across zoom levels and room-size settings.
10
+ *
11
+ * Other shape types:
12
+ * - Circles use a luminance-mapped gradient (asphalt → safety yellow).
13
+ * - Exit lines and polygon arrows become safety orange (#FF6600).
14
+ * - Text uses safety yellow.
15
+ * - Images and groups pass through unchanged.
16
+ */
17
+ export declare const constructionShapeStyle: Style;
@@ -0,0 +1,32 @@
1
+ import { Style } from '../Style';
2
+ export type IsometricRotation = number;
3
+ export interface IsometricOptions {
4
+ /** Cube side face height. Defaults to 0.18. */
5
+ depth?: number;
6
+ /** Rotation angle in degrees. Defaults to 0. */
7
+ rotation?: IsometricRotation;
8
+ }
9
+ /**
10
+ * 2:1 isometric projection as a {@link Style}.
11
+ *
12
+ * - Rectangles → diamond (rhombus) polygons. Dashed rects decompose to four
13
+ * dashed line shapes (one per edge). With `depth > 0` and a fill, rooms gain
14
+ * right + left side faces (darker shades of the fill) drawn beneath the top
15
+ * diamond plus six outline edges, producing a 3D cube look.
16
+ * - Circles → ellipse polygons (32 segments). Dashed circles decompose to
17
+ * line segments. With `depth > 0` and a fill, the lower half extrudes into
18
+ * left + right side faces.
19
+ * - Lines / polygons / grid lines have their coordinates projected.
20
+ * - Text / images keep their position and gain an affine `transform` field
21
+ * that maps their bounding box to the iso parallelogram (text stays
22
+ * upright; readers consume `transform` directly).
23
+ * - Group origins are projected; children are projected separately. Because
24
+ * iso is linear, `iso(g) + iso(c) === iso(g + c)`, so the final positions
25
+ * line up exactly.
26
+ *
27
+ * Provides `worldToScene` / `sceneToWorld` so `HitTester` and `Camera` can
28
+ * round-trip clicks through the projection. Link-layer groups (exits,
29
+ * special exits, stubs) are shifted down by the cube depth in render space
30
+ * so connectors attach at the cube base instead of the top face.
31
+ */
32
+ export declare function isometricShapeStyle(options?: IsometricOptions): Style;
@@ -0,0 +1,17 @@
1
+ import { Style } from '../Style';
2
+ /**
3
+ * Cyberpunk / neon aesthetic as a {@link Style} — glowing coloured outlines
4
+ * on a dark background.
5
+ *
6
+ * - Fills become very dark with a subtle tint of the original hue.
7
+ * - Strokes become bright neon (hue-preserved, saturation/lightness boosted).
8
+ * - A glow effect is added for stroked rect / circle / line shapes by emitting
9
+ * an extra wider translucent shape **before** the main one, so callers see
10
+ * `[glow, main]` (the order in which they should be rendered).
11
+ * - Polygons get the neon repaint without a glow pass — same as the legacy
12
+ * decorator, since polygons in the pipeline are inner-exit triangles and
13
+ * exit arrowheads where a glow halo reads as visual noise.
14
+ * - Text uses bright cyan-green.
15
+ * - Images and groups pass through unchanged.
16
+ */
17
+ export declare const neonShapeStyle: Style;
@@ -0,0 +1,13 @@
1
+ import { Style } from '../Style';
2
+ /**
3
+ * Warm sepia / old-parchment palette as a {@link Style}.
4
+ *
5
+ * - Fills are mapped through a luminance-based parchment gradient
6
+ * (dark brown → light parchment) so different environment colours stay
7
+ * visually distinct while keeping the aged-paper look.
8
+ * - Strokes become dark ink brown.
9
+ * - Text uses a very dark brown for legibility.
10
+ * - Images and groups pass through unchanged (the caller walks group
11
+ * children separately).
12
+ */
13
+ export declare const parchmentShapeStyle: Style;
@@ -0,0 +1,16 @@
1
+ import { Style } from '../Style';
2
+ /**
3
+ * Sci-fi / space-exploration aesthetic as a {@link Style}.
4
+ *
5
+ * - Fills preserve the original room hue (so area colours stay distinct) but
6
+ * are pushed to a fixed dark lightness and moderate saturation, giving each
7
+ * zone a deep-space tinted look. Achromatic rooms default to cyan.
8
+ * - Room borders use electric cyan (#00C8FF) with a wide translucent glow halo,
9
+ * giving the holographic-display bloom effect.
10
+ * - Exit lines and arrow polygons use targeting green-cyan (#00FFAA) with a
11
+ * glow pass, evoking radar / navigation overlays.
12
+ * - Grid lines are rendered as a barely-visible dark tint — no glow.
13
+ * - Text uses near-white blue for crisp legibility on dark fills.
14
+ * - Images and groups pass through unchanged.
15
+ */
16
+ export declare const scifiShapeStyle: Style;
@@ -0,0 +1,22 @@
1
+ import { Style } from '../Style';
2
+ export interface SketchyOptions {
3
+ /** Jitter amount in map units (e.g. 0.015). */
4
+ jitter: number;
5
+ /** Pencil colour for all strokes/fills (e.g. `#444444`). */
6
+ color: string;
7
+ }
8
+ /**
9
+ * Hand-drawn pencil wobble as a {@link Style}. Subdivides edges into wobbly
10
+ * segments with seeded perpendicular jitter, so re-renders produce the same
11
+ * pattern.
12
+ *
13
+ * - Rectangles → wobbly polygons (paper-white fill on parchment, pencil stroke).
14
+ * Rounded-corner rectangles render as a paper-white fill rect plus a wobbly
15
+ * polygon outline, so the corners stay rounded but the silhouette wobbles.
16
+ * - Circles → wobbly 24-segment polygons.
17
+ * - Lines → wobbled polylines.
18
+ * - Polygons → wobbled edge subdivisions.
19
+ * - Text → repainted in pencil colour.
20
+ * - Images and groups pass through unchanged.
21
+ */
22
+ export declare function sketchyShapeStyle(options: SketchyOptions): Style;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shape-based {@link Style} implementations — geometry transformers per the
3
+ * {@link Style} interface in `../Style.ts`. Each style takes a {@link Shape}
4
+ * and returns one or more transformed shapes; no backend coupling.
5
+ *
6
+ * Usage:
7
+ * ```ts
8
+ * import {compose} from "../Style";
9
+ * import {parchmentShapeStyle, sketchyShapeStyle} from "./shape";
10
+ *
11
+ * const style = compose(parchmentShapeStyle, sketchyShapeStyle({
12
+ * jitter: 0.012,
13
+ * color: '#4a3728',
14
+ * }));
15
+ * ```
16
+ */
17
+ export { parchmentShapeStyle } from './ParchmentStyle';
18
+ export { blueprintShapeStyle } from './BlueprintStyle';
19
+ export { neonShapeStyle } from './NeonStyle';
20
+ export { sketchyShapeStyle } from './SketchyStyle';
21
+ export type { SketchyOptions } from './SketchyStyle';
22
+ export { isometricShapeStyle } from './IsometricStyle';
23
+ export type { IsometricOptions, IsometricRotation } from './IsometricStyle';
24
+ export { constructionShapeStyle } from './ConstructionStyle';
25
+ export { scifiShapeStyle } from './SciFiStyle';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Shared colour-parsing + paint-rewriting helpers used by the shape-based
3
+ * Style implementations (Parchment, Blueprint, Neon).
4
+ *
5
+ * The old BaseStyle decorator versions in `../ParchmentStyle.ts`,
6
+ * `../BlueprintStyle.ts`, and `../NeonStyle.ts` keep their own copies for
7
+ * now; they're deleted in step 11.
8
+ */
9
+ export interface ParsedRgb {
10
+ r: number;
11
+ g: number;
12
+ b: number;
13
+ /** 0..1 alpha — defaults to 1 when not present. */
14
+ a: number;
15
+ }
16
+ /**
17
+ * Parse a colour string in `rgb(r, g, b)`, `rgba(r, g, b, a)`, or
18
+ * `#rrggbb` form. Returns `null` for anything else (named colours,
19
+ * `hsl(...)`, etc.) so callers can fall back to a default.
20
+ */
21
+ export declare function parseRgb(color: string): ParsedRgb | null;
22
+ /** Format an `rgb(r, g, b)` or `rgba(r, g, b, a)` string. */
23
+ export declare function formatRgb(r: number, g: number, b: number, a?: number): string;
24
+ /** Perceived luminance in [0, 1] using ITU-R BT.601 weights. */
25
+ export declare function luminance(c: ParsedRgb): number;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Hand-drawn wobble math used by the shape-based SketchyStyle.
3
+ *
4
+ * Identical algorithms to `../SketchyStyle.ts` so cross-style snapshots
5
+ * stay byte-identical between old and new pipelines. When step 11 deletes
6
+ * the legacy decorator, this module becomes the single source of truth.
7
+ */
8
+ /** Simple seeded LCG. Returns values in `[0, 1)`. */
9
+ export declare function createRng(seed: number): () => number;
10
+ /** Hash a set of numeric values into a stable integer seed. */
11
+ export declare function hashCoords(...values: number[]): number;
12
+ /**
13
+ * Subdivide a straight segment into several sub-segments with slight
14
+ * perpendicular displacement, producing a hand-drawn wobble.
15
+ */
16
+ export declare function wobbleSegment(x1: number, y1: number, x2: number, y2: number, jitter: number, rng: () => number): number[];
17
+ /** Wobble an open polyline. */
18
+ export declare function wobblePolyline(points: number[], jitter: number, rng: () => number): number[];
19
+ /** Convert a rectangle to a closed wobbly polygon. */
20
+ export declare function wobbleRect(x: number, y: number, w: number, h: number, jitter: number, rng: () => number): number[];
21
+ /** Convert a circle to a wobbly polygon with slight radius variation. */
22
+ export declare function wobbleCircle(cx: number, cy: number, radius: number, jitter: number, rng: () => number): number[];
23
+ /** Wobble a closed polygon by subdividing each edge. */
24
+ export declare function wobblePolygonEdges(vertices: number[], jitter: number, rng: () => number): number[];