APIs

All Lands programs start with a sole global object Lan, we use this object to initialize the canvas and do animations.

1. Canvas Initialization2. Other APIs1. Canvas Initialization

We usually use Lan.canvas** to initialize the canvas before we start to render.

Lan.canvas([width, height])

This method returns a Raw canvas object. You can then get a rendering context of the canvas as you wish.

Lan.canvas2d([width, height, options])

This method returns a 2D canvas object.

Lan.canvas3d([width, height, options, type])

This method returns a WebGL canvas object.

Lan.canvasps([width, height, options])

This method returns a Pixel Shader canvas object.

async Lan.canvasfs([width, height, options])

This method returns a Fragment Shader canvas object. You can then write GLSL shader programs to render.

async Lan.canvascs([width, height, options])

This method returns a Compute Shader canvas object. It's based on WebGPU, and you just write Compute Shaders to render.

After the canvas is initialized, the returned canvas object has these possible properties:

2. Other APIs async Lan.loop(callback, [finish])

This method is usually used for repeated jobs, such as animation. After the loop is ended, we call finish (if provided).

async Lan.import(lib)

We can import third-party JS libraries to Lands. For example, Lan.import('three') would import the three.js library.

Lan.log(msg, [color])

We use this method to write runtime logs.