Manages the HTML <canvas> element used for WebGL rendering, handles resizing, and provides viewport information. Accessed via micrio.canvas.

Constructors

Properties

Accessors

Methods

Constructors

  • Creates a Canvas controller instance.

    Parameters

    Returns Canvas

Properties

element: HTMLCanvasElement = ...

The main WebGL rendering <canvas> element.

isMobile: Writable<boolean> = ...

Writable Svelte store indicating if the client is likely a mobile device.

viewport: ViewRect = ...

Object containing current viewport dimensions, position, and ratios.

Accessors

  • get $isMobile(): boolean
  • Getter for the current value of the isMobile store.

    Returns boolean

Methods

  • Gets the appropriate device pixel ratio for rendering. Clamped between 1 and 2, disabled on iOS and if noRetina setting is true.

    Parameters

    • s: Partial<Settings> = ...

      Optional image settings object to check for noRetina.

    Returns number

    The calculated device pixel ratio.

  • Sets virtual offset margins in the Wasm controller. This likely affects how viewports are calculated or limited.

    Parameters

    • width: number

      The horizontal offset margin in pixels.

    • height: number

      The vertical offset margin in pixels.

    Returns void