Rendering modes for nx.js applications

There are two different rendering modes available for nx.js applications: console rendering or canvas rendering.

Console Rendering

The console rendering mode is useful for text-based applications, which 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 games and applications that require complex graphics or animations. It allows you to draw to the screen using the web Canvas API, which provides a low-level interface for drawing shapes, images, and text to the screen.

To use the canvas rendering mode, invoke 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