File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,30 @@ Vue.use(CanvasPlugin);
54
54
<CanvasView width=" 100 " height=" 100 " @draw=" draw " />
55
55
```
56
56
57
+ ## NativeScript + Svelte
58
+
59
+ ```ts
60
+ // app/app.ts
61
+ import { registerNativeViewElement } from 'svelte-native/dom';
62
+ registerNativeViewElement('canvasView', () => require('@nativescript-community/ui-canvas').CanvasView);
63
+ ```
64
+
65
+ ```svelte
66
+ <!-- app/components/Foo.svelte -->
67
+ <stackLayout>
68
+ <canvasView width=" 300 " height=" 300 " on:draw={draw} />
69
+ </stackLayout>
70
+ ```
71
+
57
72
## Draw Method
58
- ```typescript
73
+
74
+ ```ts
75
+ import type { Canvas } from '@nativescript-community/ui-canvas';
76
+ import { Paint, createRect } from '@nativescript-community/ui-canvas';
77
+ import { Color } from '@nativescript/core';
78
+
59
79
function draw(event: { canvas: Canvas }) {
80
+ const canvas = event.canvas;
60
81
const paint = new Paint();
61
82
paint.setColor(new Color('black'));
62
83
paint.strokeWidth = 10;
@@ -78,4 +99,4 @@ function draw(event: { canvas: Canvas }) {
78
99
- An example of animating a shape
79
100
80
101
{{ load:../../tools/readme/demos-and-development.md }}
81
- {{ load:../../tools/readme/questions.md }}
102
+ {{ load:../../tools/readme/questions.md }}
You can’t perform that action at this time.
0 commit comments