Skip to content

Commit ea3131b

Browse files
committed
Update README.md
1 parent a0f3a65 commit ea3131b

File tree

1 file changed

+64
-21
lines changed

1 file changed

+64
-21
lines changed

README.md

+64-21
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,80 @@
1-
# pkg-placeholder
1+
# @trbn/jsoncanvas
22

33
[![npm version][npm-version-src]][npm-version-href]
44
[![npm downloads][npm-downloads-src]][npm-downloads-href]
55
[![bundle][bundle-src]][bundle-href]
66
[![JSDocs][jsdocs-src]][jsdocs-href]
77
[![License][license-src]][license-href]
88

9-
_description_
9+
`@trbn/jsoncanvas` is an implementation of the [JSONCanvas Spec](https://jsoncanvas.org/spec/1.0/) in TypeScript.
1010

11-
> **Note**:
12-
> Replace `pkg-placeholder`, `_description_` and `antfu` globally to use this template.
11+
> Note: This package does NOT include a rendering engine. It is only a data structure for a canvas.
1312
14-
## Sponsors
13+
## Installation
1514

16-
<p align="center">
17-
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
18-
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
19-
</a>
20-
</p>
15+
With pnpm:
16+
17+
```bash
18+
pnpm install @trbn/jsoncanvas
19+
```
20+
21+
22+
## Example Usage
23+
24+
```typescript
25+
import { JSONCanvas } from '@trbn/jsoncanvas';
26+
27+
const canvas = new JSONCanvas();
28+
29+
// Adds a text node to the canvas
30+
canvas.addNode({
31+
id: 'node1',
32+
type: 'text',
33+
text: 'Hello, World!',
34+
x: 100,
35+
y: 100,
36+
width: 100,
37+
height: 100,
38+
});
39+
40+
// Adds another text node to the canvas
41+
canvas.addNode({
42+
id: 'node2',
43+
type: 'text',
44+
text: 'Hello, World 2!',
45+
x: 200,
46+
y: 200,
47+
radius: 50,
48+
});
49+
50+
// Adds an connection between node1 and node2
51+
canvas.addEdge({
52+
id: 'edge1',
53+
fromNode: 'node1',
54+
toNode: 'node2',
55+
label: 'Edge 1',
56+
});
57+
58+
// Removes node2 and all connections to it
59+
canvas.removeNode('node2');
60+
61+
// Outputs the canvas as a string
62+
console.log(canvas.toString());
63+
```
2164

2265
## License
2366

24-
[MIT](./LICENSE) License © 2023-PRESENT [Anthony Fu](https://github.com/antfu)
67+
[MIT](./LICENSE) License © 2024-PRESENT [Torben Haack](https://github.com/haackt)
2568

2669
<!-- Badges -->
2770

28-
[npm-version-src]: https://img.shields.io/npm/v/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669
29-
[npm-version-href]: https://npmjs.com/package/pkg-placeholder
30-
[npm-downloads-src]: https://img.shields.io/npm/dm/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669
31-
[npm-downloads-href]: https://npmjs.com/package/pkg-placeholder
32-
[bundle-src]: https://img.shields.io/bundlephobia/minzip/pkg-placeholder?style=flat&colorA=080f12&colorB=1fa669&label=minzip
33-
[bundle-href]: https://bundlephobia.com/result?p=pkg-placeholder
34-
[license-src]: https://img.shields.io/github/license/antfu/pkg-placeholder.svg?style=flat&colorA=080f12&colorB=1fa669
35-
[license-href]: https://github.com/antfu/pkg-placeholder/blob/main/LICENSE
36-
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
37-
[jsdocs-href]: https://www.jsdocs.io/package/pkg-placeholder
71+
[npm-version-src]: https://img.shields.io/npm/v/@trbn/jsoncanvas?style=flat&colorA=080f12&colorB=1fa669
72+
[npm-version-href]: https://npmjs.com/package/@trbn/jsoncanvas
73+
[npm-downloads-src]: https://img.shields.io/npm/dm/@trbn/jsoncanvas?style=flat&colorA=080f12&colorB=1fa669
74+
[npm-downloads-href]: https://npmjs.com/package/@trbn/jsoncanvas
75+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/@trbn/jsoncanvas?style=flat&colorA=080f12&colorB=1fa669&label=minzip
76+
[bundle-href]: https://bundlephobia.com/result?p=@trbn/jsoncanvas
77+
[license-src]: https://img.shields.io/github/license/haackt/@trbn/jsoncanvas.svg?style=flat&colorA=080f12&colorB=1fa669
78+
[license-href]: https://github.com/haackt/@trbn/jsoncanvas/blob/main/LICENSE
79+
[jsdocs-src]: https://img.shields.io/badge/@trbn/jsoncanvas-080f12?style=flat&colorA=080f12&colorB=1fa669
80+
[jsdocs-href]: https://www.jsdocs.io/package/@trbn/jsoncanvas

0 commit comments

Comments
 (0)