Main

Tily. Main

new Main(canvas, optionsopt)

The main Tily object. Initialises a canvas element and starts drawing tiles.

Parameters
Name Type Attributes Description
canvas HTMLElement

The canvas element in which to draw tiles.

options TilyOptions <optional>

An optional object containing options for configuring this Tily instance.

Members

activeBuffer :Tily.BufferBase

The buffer currently being rendered.

(nullable) bufferTransition :Tily.BufferTransition

The currently running buffer transition or null if there is no currently running transition.

Default Value:
  • null

canvas :HTMLElement

The canvas element in which to draw tiles.

context :CanvasRenderingContext2D

The context on which to draw tiles.

frameCount :number

The number of frames rendered in the last second.

frameRate :number

The number of frames rendered per second.

frameTime :number

The number of milliseconds elapsed since the last framerate update.

height :number

The viewport height.

lastFrameTime :number

The unix epoch time of the last rendered frame.

loop :number

A request id returned from window.requestAnimationFrame that uniquely identifies the entry in the callback list for the main render loop.

options :TilyOptions

Options for configuring this Tily instance.

size :Size

The size of this Tily element measured in pixels.

width :number

The viewport width.

Methods

activateBuffer(buffer, optionsopt) → {Promise}

Activate a new buffer with an optional fade transition from the current buffer.

Parameters
Name Type Attributes Description
buffer Tily.Buffer

The new buffer to activate.

options TransitionOptions <optional>

An optional options object.

Returns

A promise instance for setting a transition finished callback.

Type
Promise

draw(elapsedTime)

Render the Tily instance onto the canvas.

Parameters
Name Type Description
elapsedTime number

The time elapsed in seconds since the last draw call.