File tree Expand file tree Collapse file tree 6 files changed +43
-7
lines changed Expand file tree Collapse file tree 6 files changed +43
-7
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 }}
Original file line number Diff line number Diff line change 14
14
"scripts" : {
15
15
"build" : " npm run tsc" ,
16
16
"build.all" : " npm run build" ,
17
- "build.angular" : " ng-packagr -p ../../src/ui-canvas/angular/ng-package.json -c ../../src/ui-canvas/angular/tsconfig.json" ,
17
+ "build.angular" : " ng-packagr -p ../../src/ui-canvas/angular/ng-package.json -c ../../src/ui-canvas/angular/tsconfig.json && rm angular/.npmignore " ,
18
18
"readme" : " readme generate -c ../../tools/readme/blueprint.json" ,
19
19
"tsc" : " cpy '**/*.d.ts' '../../packages/ui-canvas' --parents --cwd=../../src/ui-canvas && tsc -skipLibCheck -d" ,
20
20
"clean" : " rimraf ./*.d.ts ./*.js ./*.js.map"
Original file line number Diff line number Diff line change 14
14
"scripts" : {
15
15
"build" : " npm run tsc" ,
16
16
"build.all" : " npm run build" ,
17
- "build.angular" : " ng-packagr -p ../../src/ui-canvaslabel/angular/ng-package.json -c ../../src/ui-canvaslabel/angular/tsconfig.json" ,
17
+ "build.angular" : " ng-packagr -p ../../src/ui-canvaslabel/angular/ng-package.json -c ../../src/ui-canvaslabel/angular/tsconfig.json && rm angular/.npmignore " ,
18
18
"readme" : " readme generate -c ../../tools/readme/blueprint.json" ,
19
19
"tsc" : " cpy '**/*.d.ts' '../../packages/ui-canvaslabel' --parents --cwd=../../src/ui-canvaslabel && tsc -skipLibCheck -d" ,
20
20
"clean" : " rimraf ./*.d.ts ./*.js ./*.js.map"
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ Run the following command from the root of your project:
14
14
15
15
For now only ` vue ` (and core) is supported.
16
16
17
+ ### NativeScript + Vue
18
+
17
19
``` ts
18
20
import CanvasSVG from ' @nativescript-community/ui-svg/vue' ;
19
21
Vue .use (CanvasSVG );
@@ -47,10 +49,23 @@ Or within and Canvas View extending `CanvasView` like `CanvasLabel`
47
49
</CanvasSVG >
48
50
```
49
51
52
+ ### NativeScript + Svelte
53
+
54
+ ``` ts
55
+ // app/app.ts
56
+ import { registerNativeViewElement } from ' svelte-native/dom' ;
57
+ registerNativeViewElement (' svgView' , () => require (' @nativescript-community/ui-svg' ).SVGView );
58
+ ```
59
+
60
+ ``` svelte
61
+ <!-- app/components/Foo.svelte -->
62
+ <svgView src="~/assets/foo.svg" aspectFit="stretch" />
63
+ ```
64
+
50
65
### Examples:
51
66
52
67
- [ Basic] ( demo-snippets/vue/SVG.vue )
53
68
- A basic SVG example
54
69
55
70
{{ load:../../tools/readme/demos-and-development.md }}
56
- {{ load:../../tools/readme/questions.md }}
71
+ {{ load:../../tools/readme/questions.md }}
Original file line number Diff line number Diff line change 18
18
"scripts" : {
19
19
"build" : " npm run tsc" ,
20
20
"build.all" : " npm run build" ,
21
- "build.angular" : " ng-packagr -p ../../src/ui-svg/angular/ng-package.json -c ../../src/ui-svg/angular/tsconfig.json" ,
21
+ "build.angular" : " ng-packagr -p ../../src/ui-svg/angular/ng-package.json -c ../../src/ui-svg/angular/tsconfig.json && rm angular/.npmignore " ,
22
22
"readme" : " readme generate -c ../../tools/readme/blueprint.json" ,
23
23
"tsc" : " cpy '**/*.d.ts' '../../packages/ui-svg' --parents --cwd=../../src/ui-svg && tsc -skipLibCheck -d" ,
24
24
"clean" : " rimraf ./*.d.ts ./*.js ./*.js.map"
You can’t perform that action at this time.
0 commit comments