modern-canvas 0.0.3 → 0.1.1

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,52 +26,52 @@ npm i modern-canvas
27
26
 
28
27
  ## 🦄 Usage
29
28
 
30
- ```ts
31
- import { createApp, plugins } from 'modern-canvas'
29
+ ```javascript
30
+ import { Animation2D, Engine, Image2D, Text2D } from 'modern-canvas'
31
+ import { fonts } from 'modern-font'
32
32
 
33
- const app = createApp({
34
- view: document.querySelector('canvas'),
35
- children: [
36
- {
37
- type: 'image',
38
- style: {
39
- left: 0,
40
- top: 0,
41
- width: 130,
42
- height: 130,
43
- rotation: 30,
44
- },
45
- src: '/example.jpg',
46
- },
47
- {
48
- type: 'text',
49
- style: {
50
- left: 60,
51
- top: 60,
52
- width: 240,
53
- height: 240,
54
- rotation: 0,
55
- fontSize: 40,
56
- color: 'red',
57
- },
58
- content: 'TEXT',
59
- },
60
- {
61
- type: 'video',
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()
39
+
40
+ engine.root.addChild(
41
+ new Image2D({
62
42
  style: {
63
- left: 60,
64
- top: 60,
65
- width: 30,
66
- height: 30,
67
- rotation: 30,
43
+ left: 100,
44
+ top: 100,
45
+ width: 100,
46
+ height: 100,
47
+ rotate: 30,
48
+ opacity: 0.5,
49
+ backgroundColor: '#00FF00',
50
+ filter: 'brightness(102%) contrast(90%) saturate(128%) sepia(18%)',
68
51
  },
69
- src: 'example.mp4',
70
- },
71
- ],
72
- plugins,
73
- })
52
+ src: '/example.png',
53
+ })
54
+ .addChild(
55
+ new Text2D({
56
+ style: {
57
+ fontSize: 30,
58
+ },
59
+ content: '/example.png',
60
+ }),
61
+ )
62
+ .addChild(
63
+ new Animation2D({
64
+ duration: 3000,
65
+ loop: true,
66
+ keyframes: [
67
+ { offset: 1, rotate: 180 },
68
+ ],
69
+ }),
70
+ )
71
+ )
74
72
 
75
- await app.load()
73
+ console.log(engine)
76
74
 
77
- app.start()
75
+ document.body.append(engine.view)
76
+ })
78
77
  ```