Rendering
Rendering modes for nx.js applications
There are two different rendering modes available for nx.js applications: console rendering or canvas rendering.
Console Rendering
Console rendering mode is useful for text-based applications, which do not require complex graphics or animations.
To use console rendering mode, use the functions available on the global console object to print text to the console:
console.log('Hello World');Canvas Rendering
Canvas rendering mode is useful for graphical user interfaces and games. 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 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).