nx.js

Rendering Modes

Rendering modes for nx.js applications

nx.js applications can be rendered in two different modes: console rendering or canvas rendering.

Console Rendering

The console rendering mode is useful for applications that do not require complex graphics or animations.

To use the console rendering mode, simply use the functions available on the global console object to print text to the console:

console.log('Hello World');

Canvas Rendering

The canvas rendering mode is useful for applications that require complex graphics or animations. It allows you to draw to the screen using the Canvas API, which provides a powerful and flexible way to create visually stunning applications.

To use the canvas rendering mode, use the screen.getContext() function to get access to a canvas rendering context:

const ctx = screen.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(0, 0, 100, 100);

Currently only the "2d" rendering context is supported. The "webgl" context is planned for a future release (see #131).

On this page