modern-canvas 0.0.2 → 0.1.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 CHANGED
@@ -18,7 +18,6 @@
18
18
  </a>
19
19
  </p>
20
20
 
21
-
22
21
  ## 📦 Install
23
22
 
24
23
  ```shell
@@ -27,22 +26,44 @@ npm i modern-canvas
27
26
 
28
27
  ## 🦄 Usage
29
28
 
30
- ```ts
31
- import { createCanvas, plugins } from 'modern-canvas'
32
-
33
- const canvas = createCanvas({
34
- view: document.querySelector('canvas'),
35
- children: [
36
- { x: 0, y: 0, width: 30, height: 30, rotation: 30, image: '/example.jpg' },
37
- { x: 30, y: 30, width: 200, height: 200, image: '/example.png' },
38
- { x: 60, y: 60, width: 120, height: 120, rotation: 50, image: '/example.jpg' },
39
- { x: 200, y: 200, width: 100, height: 100, image: '/example.png' },
40
- { x: 30, y: 30, width: 100, height: 100, rotation: 40, text: 'example' },
41
- ],
42
- plugins,
43
- })
29
+ ```javascript
30
+ import { Engine } from 'modern-canvas'
31
+ import { fonts } from 'modern-font'
32
+
33
+ async function loadFallbackFont() {
34
+ fonts.fallbackFont = await fonts.load({ family: 'fallbackFont', src: '/fallback.woff' })
35
+ }
36
+
37
+ loadFallbackFont().then(() => {
38
+ const engine = new Engine({ width: 500, height: 500 }).start()
44
39
 
45
- await canvas.load()
40
+ engine.root.addChild(
41
+ new Image2D({
42
+ style: {
43
+ left: 100,
44
+ top: 100,
45
+ width: 100,
46
+ height: 100,
47
+ rotate: 30,
48
+ filter: 'sepia(0.5)',
49
+ },
50
+ src: '/example.png',
51
+ }),
52
+ )
46
53
 
47
- canvas.startRenderLoop()
54
+ engine.root.addChild(
55
+ new Text2D({
56
+ style: {
57
+ left: 100,
58
+ top: 100,
59
+ fontSize: 30,
60
+ },
61
+ content: '/example.png',
62
+ }),
63
+ )
64
+
65
+ console.log(engine)
66
+
67
+ document.body.append(engine.view)
68
+ })
48
69
  ```