@canvas-tile-engine/core 0.1.0 → 0.3.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.
- package/README.md +22 -3
- package/dist/index.d.mts +676 -158
- package/dist/index.d.ts +676 -158
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
# @canvas-tile-engine/core
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@canvas-tile-engine/core)
|
|
4
|
+
[](https://bundlephobia.com/package/@canvas-tile-engine/core)
|
|
5
|
+
[](../../LICENSE)
|
|
6
|
+
|
|
3
7
|
Lightweight, framework-agnostic library for building interactive 2D grid-based maps and visualizations. Handles camera controls, coordinate transformations, layer-based rendering, and event handling.
|
|
4
8
|
|
|
5
9
|
## Install
|
|
6
10
|
|
|
7
11
|
```bash
|
|
8
|
-
npm install @canvas-tile-engine/core
|
|
12
|
+
npm install @canvas-tile-engine/core @canvas-tile-engine/renderer-canvas
|
|
9
13
|
```
|
|
10
14
|
|
|
11
15
|
## Quick Start
|
|
@@ -18,15 +22,17 @@ npm install @canvas-tile-engine/core
|
|
|
18
22
|
|
|
19
23
|
```ts
|
|
20
24
|
import { CanvasTileEngine } from "@canvas-tile-engine/core";
|
|
25
|
+
import { RendererCanvas } from "@canvas-tile-engine/renderer-canvas";
|
|
21
26
|
|
|
22
27
|
const engine = new CanvasTileEngine(
|
|
23
|
-
document.getElementById("wrapper"),
|
|
28
|
+
document.getElementById("wrapper") as HTMLDivElement,
|
|
24
29
|
{
|
|
25
30
|
scale: 50,
|
|
26
31
|
size: { width: 800, height: 600 },
|
|
27
32
|
backgroundColor: "#337426",
|
|
28
33
|
eventHandlers: { drag: true, zoom: true, click: true },
|
|
29
34
|
},
|
|
35
|
+
new RendererCanvas(),
|
|
30
36
|
{ x: 0, y: 0 }
|
|
31
37
|
);
|
|
32
38
|
|
|
@@ -36,9 +42,22 @@ engine.render();
|
|
|
36
42
|
engine.onClick = (coords) => console.log("Clicked:", coords.snapped);
|
|
37
43
|
```
|
|
38
44
|
|
|
45
|
+
## Architecture
|
|
46
|
+
|
|
47
|
+
The core package is renderer-agnostic. You inject a renderer that implements the `IRenderer` interface:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// Canvas2D
|
|
51
|
+
import { RendererCanvas } from "@canvas-tile-engine/renderer-canvas";
|
|
52
|
+
new CanvasTileEngine(wrapper, config, new RendererCanvas());
|
|
53
|
+
|
|
54
|
+
// Custom renderer
|
|
55
|
+
new CanvasTileEngine(wrapper, config, new MyCustomRenderer());
|
|
56
|
+
```
|
|
57
|
+
|
|
39
58
|
## Documentation
|
|
40
59
|
|
|
41
|
-
Full API reference and examples: [
|
|
60
|
+
Full API reference and examples: [canvastileengine.dev](https://canvastileengine.dev/docs/js/installation)
|
|
42
61
|
|
|
43
62
|
## License
|
|
44
63
|
|