route-graphics 0.0.15 → 0.0.16
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/README.md +136 -1
- package/dist/RouteGraphics.js +114 -104
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -22,6 +22,141 @@ Route Graphics follows a **render cycle** where:
|
|
|
22
22
|
3. **Animation Functions** apply smooth transitions between states
|
|
23
23
|
4. **Audio Functions** handle sound effects and background music
|
|
24
24
|
|
|
25
|
+
## API Reference
|
|
26
|
+
|
|
27
|
+
### createRouteGraphics()
|
|
28
|
+
|
|
29
|
+
Creates and returns a RouteGraphics instance.
|
|
30
|
+
|
|
31
|
+
```javascript
|
|
32
|
+
const app = createRouteGraphics();
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Instance Methods
|
|
36
|
+
|
|
37
|
+
#### `init(options)`
|
|
38
|
+
|
|
39
|
+
Initialize the RouteGraphics application.
|
|
40
|
+
|
|
41
|
+
**Parameters:**
|
|
42
|
+
- `options` (Object)
|
|
43
|
+
- `width` (number) - Canvas width
|
|
44
|
+
- `height` (number) - Canvas height
|
|
45
|
+
- `backgroundColor` (number, optional) - Background color as hex (e.g., `0x000000`)
|
|
46
|
+
- `debug` (boolean, optional) - Enable debug mode (default: `false`)
|
|
47
|
+
- `eventHandler` (Function) - Callback for events `(eventName, payload) => void`
|
|
48
|
+
- `plugins` (Object)
|
|
49
|
+
- `elements` (Array) - Element plugins to register
|
|
50
|
+
- `animations` (Array) - Animation plugins to register
|
|
51
|
+
- `audio` (Array) - Audio plugins to register
|
|
52
|
+
|
|
53
|
+
**Returns:** `Promise<RouteGraphicsInstance>`
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
#### `loadAssets(assetBufferMap)`
|
|
58
|
+
|
|
59
|
+
Load assets from pre-loaded buffer data.
|
|
60
|
+
|
|
61
|
+
**Parameters:**
|
|
62
|
+
- `assetBufferMap` (Object) - Map of asset key to `{ buffer: ArrayBuffer, type: string }`
|
|
63
|
+
- Example: `{ "hero": { buffer: ArrayBuffer, type: "image/png" } }`
|
|
64
|
+
|
|
65
|
+
**Returns:** `Promise<Array>` - Array of loaded assets
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
#### `render(state)`
|
|
70
|
+
|
|
71
|
+
Render the UI from a state object.
|
|
72
|
+
|
|
73
|
+
**Parameters:**
|
|
74
|
+
- `state` (RouteGraphicsState)
|
|
75
|
+
- `elements` (Array) - Array of element definitions
|
|
76
|
+
- `animations` (Array) - Array of animation definitions
|
|
77
|
+
- `audio` (Array) - Array of audio definitions
|
|
78
|
+
- `global` (Object, optional) - Global configuration
|
|
79
|
+
- `cursorStyles` (Object) - Custom cursor styles
|
|
80
|
+
- `keyboard` (Object) - Keyboard hotkey mappings
|
|
81
|
+
|
|
82
|
+
**Returns:** `void`
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
#### `parse(state)`
|
|
87
|
+
|
|
88
|
+
Parse elements from state object using registered parser plugins (without rendering).
|
|
89
|
+
|
|
90
|
+
**Parameters:**
|
|
91
|
+
- `state` (RouteGraphicsState) - State object containing element definitions
|
|
92
|
+
|
|
93
|
+
**Returns:** `RouteGraphicsState` - Parsed state with AST elements
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
#### `updatedBackgroundColor(color)`
|
|
98
|
+
|
|
99
|
+
Update the canvas background color.
|
|
100
|
+
|
|
101
|
+
**Parameters:**
|
|
102
|
+
- `color` (string) - New background color as hex (e.g., `"0xffffff"`)
|
|
103
|
+
|
|
104
|
+
**Returns:** `void`
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
#### `findElementByLabel(targetLabel)`
|
|
109
|
+
|
|
110
|
+
Find an element in the stage by its label.
|
|
111
|
+
|
|
112
|
+
**Parameters:**
|
|
113
|
+
- `targetLabel` (string) - Label to search for
|
|
114
|
+
|
|
115
|
+
**Returns:** `DisplayObject | null` - Found element or null
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
#### `extractBase64(element)`
|
|
120
|
+
|
|
121
|
+
Extract a base64 representation of an element.
|
|
122
|
+
|
|
123
|
+
**Parameters:**
|
|
124
|
+
- `element` (DisplayObject) - Element to extract
|
|
125
|
+
|
|
126
|
+
**Returns:** `Promise<string>` - Base64 string
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
#### `assignStageEvent(eventType, callback)`
|
|
131
|
+
|
|
132
|
+
Assign an event listener to the stage.
|
|
133
|
+
|
|
134
|
+
**Parameters:**
|
|
135
|
+
- `eventType` (string) - Event type (e.g., `"click"`, `"pointermove"`)
|
|
136
|
+
- `callback` (Function) - Event callback function
|
|
137
|
+
|
|
138
|
+
**Returns:** `void`
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
#### `destroy()`
|
|
143
|
+
|
|
144
|
+
Destroy the application and cleanup resources.
|
|
145
|
+
|
|
146
|
+
**Returns:** `void`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
### Instance Properties
|
|
151
|
+
|
|
152
|
+
#### `canvas`
|
|
153
|
+
|
|
154
|
+
The HTML canvas element.
|
|
155
|
+
|
|
156
|
+
**Type:** `HTMLCanvasElement` (read-only)
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
25
160
|
## Architecture Overview
|
|
26
161
|
|
|
27
162
|
Route Graphics follows a modular plugin architecture with three main plugin categories:
|
|
@@ -109,7 +244,7 @@ await app.init({
|
|
|
109
244
|
},
|
|
110
245
|
eventHandler: (eventName, payload) => {
|
|
111
246
|
console.log('Event:', eventName, payload);
|
|
112
|
-
}
|
|
247
|
+
},
|
|
113
248
|
});
|
|
114
249
|
|
|
115
250
|
// Load assets into the app and add to DOM
|