-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation #24
Comments
Docs coming soon but you can get started with the canvas with the following ns plugin add @nativescript/canvas
Using Core {N} <canvas:Canvas id="canvas" width="100%" height="100%" ready="canvasReady"/> For all the other flavors you need to register the element Angular import { CanvasModule } from '@nativescript/canvas/angular';
@NgModule({
imports: [
CanvasModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
}) Vue import { Vue } from 'nativescript-vue';
import Canvas from '@nativescript/canvas/vue';
Vue.use(Canvas); Then you can use either the 2D or WebGL APIs 2D let ctx;
let canvas;
export function canvasReady(args) {
console.log('canvas ready');
canvas = args.object;
console.log(canvas);
ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 150, 100);
} WebGL let gl;
let canvas;
export function canvasReady(args) {
console.log('canvas ready');
canvas = args.object;
gl = canvas.getContext('webgl'); // 'webgl' || 'webgl2'
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
// Set the clear color to darkish green.
gl.clearColor(0.0, 0.5, 0.0, 1.0);
// Clear the context with the newly set color. This is
// the function call that actually does the drawing.
gl.clear(gl.COLOR_BUFFER_BIT);
} Using other libs is possible with the So one could get let's say babylonjs working by installing the Another example one could using There are a few libs that have been updated to help make thing much easier @nativescript/canvas-phaser-ce .. phaser-ce examples |
@triniwiz thanks for the effort team! |
in Angular there is no Page-Element? What's with Angular?
|
For angular it would be as follow import { CanvasModule } from '@nativescript/canvas/angular';
@NgModule({
imports: [
CanvasModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
}) <Canvas #canvas width="100%" height="100%" (ready)="canvasReady($event)"/> |
I've tried to start a canvas-phaser and a canvas-phaser-ce demo but I couldn't get what steps I have to perform in order to do that. I hope it will be clarified in the docs. |
Any documentation on how to use this plugin?
The text was updated successfully, but these errors were encountered: