|
48 | 48 | * [XML](#xml)
|
49 | 49 | * [NativeScript + Angular](#nativescript--angular)
|
50 | 50 | * [NativeScript + Vue](#nativescript--vue)
|
| 51 | +* [NativeScript + Svelte](#nativescript--svelte) |
51 | 52 | * [Draw Method ](#draw-method-)
|
52 | 53 | * [Examples:](#examples)
|
53 | 54 | * [Demos and Development](#demos-and-development)
|
@@ -136,14 +137,41 @@ Vue.use(CanvasPlugin);
|
136 | 137 | ```
|
137 | 138 |
|
138 | 139 |
|
| 140 | +[](#nativescript--svelte) |
| 141 | +
|
| 142 | +
|
| 143 | +[](#nativescript--svelte) |
| 144 | +
|
| 145 | +## NativeScript + Svelte |
| 146 | +
|
| 147 | +```ts |
| 148 | +// app/app.ts |
| 149 | +import { registerNativeViewElement } from 'svelte-native/dom'; |
| 150 | +registerNativeViewElement('canvasView', () => require('@nativescript-community/ui-canvas').CanvasView); |
| 151 | +``` |
| 152 | +
|
| 153 | +```svelte |
| 154 | +<!-- app/components/Foo.svelte --> |
| 155 | +<stackLayout> |
| 156 | + <canvasView width="300" height="300" on:draw={draw} /> |
| 157 | +</stackLayout> |
| 158 | +``` |
| 159 | +
|
| 160 | +
|
139 | 161 | [](#draw-method-)
|
140 | 162 |
|
141 | 163 |
|
142 | 164 | [](#draw-method-)
|
143 | 165 |
|
144 | 166 | ## Draw Method
|
145 |
| -```typescript |
| 167 | +
|
| 168 | +```ts |
| 169 | +import type { Canvas } from '@nativescript-community/ui-canvas'; |
| 170 | +import { Paint, createRect } from '@nativescript-community/ui-canvas'; |
| 171 | +import { Color } from '@nativescript/core'; |
| 172 | +
|
146 | 173 | function draw(event: { canvas: Canvas }) {
|
| 174 | + const canvas = event.canvas; |
147 | 175 | const paint = new Paint();
|
148 | 176 | paint.setColor(new Color('black'));
|
149 | 177 | paint.strokeWidth = 10;
|
@@ -271,6 +299,7 @@ One easy solution is t modify `~/.gitconfig` and add
|
271 | 299 | ## Questions
|
272 | 300 |
|
273 | 301 | If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|
| 302 | +
|
274 | 303 | </details><details>
|
275 | 304 | <summary><b>ui-canvaslabel</b></summary>
|
276 | 305 | <!-- ⚠️ This README has been generated from the file(s) "blueprint.md" ⚠️-->
|
@@ -575,6 +604,8 @@ If you have any questions/issues/comments please feel free to create an issue or
|
575 | 604 |
|
576 | 605 | * [Installation](#installation)
|
577 | 606 | * [Configuration](#configuration)
|
| 607 | + * [NativeScript + Vue](#nativescript--vue) |
| 608 | + * [NativeScript + Svelte](#nativescript--svelte) |
578 | 609 | * [Examples:](#examples)
|
579 | 610 | * [Demos and Development](#demos-and-development)
|
580 | 611 | * [Repo Setup](#repo-setup)
|
@@ -609,6 +640,8 @@ Run the following command from the root of your project:
|
609 | 640 |
|
610 | 641 | For now only `vue` (and core) is supported.
|
611 | 642 |
|
| 643 | +### NativeScript + Vue |
| 644 | +
|
612 | 645 | ```ts
|
613 | 646 | import CanvasSVG from '@nativescript-community/ui-svg/vue';
|
614 | 647 | Vue.use(CanvasSVG);
|
@@ -642,6 +675,19 @@ Or within and Canvas View extending `CanvasView` like `CanvasLabel`
|
642 | 675 | </CanvasSVG>
|
643 | 676 | ```
|
644 | 677 |
|
| 678 | +### NativeScript + Svelte |
| 679 | +
|
| 680 | +```ts |
| 681 | +// app/app.ts |
| 682 | +import { registerNativeViewElement } from 'svelte-native/dom'; |
| 683 | +registerNativeViewElement('svgView', () => require('@nativescript-community/ui-svg').SVGView); |
| 684 | +``` |
| 685 | +
|
| 686 | +```svelte |
| 687 | +<!-- app/components/Foo.svelte --> |
| 688 | +<svgView src="~/assets/foo.svg" aspectFit="stretch" /> |
| 689 | +``` |
| 690 | +
|
645 | 691 | ### Examples:
|
646 | 692 |
|
647 | 693 | - [Basic](demo-snippets/vue/SVG.vue)
|
@@ -754,6 +800,7 @@ One easy solution is t modify `~/.gitconfig` and add
|
754 | 800 | ## Questions
|
755 | 801 |
|
756 | 802 | If you have any questions/issues/comments please feel free to create an issue or start a conversation in the [NativeScript Community Discord](https://nativescript.org/discord).
|
| 803 | +
|
757 | 804 | </details>
|
758 | 805 |
|
759 | 806 | [](#demos-and-development)
|
|
0 commit comments