npm.nicfv.com
    Preparing search index...

    Class Canvas

    Represents a canvas for drawing and animating

    Index

    Constructors

    • Create a new canvas with the provided options

      Parameters

      • options: Partial<Options> = {}

        Configuration options

      Returns Canvas

    Properties

    height: number

    The height of the canvas, in pixels

    width: number

    The width of the canvas, in pixels

    Methods

    • Completely clears the canvas.

      Parameters

      • layer: number = -1

        The zero-indexed layer to clear, if unset, will clear all layers

      Returns void

    • Draw an object onto the canvas.

      Parameters

      • drawable: Drawable

        Any drawable object

      • layer: number = 0

        The zero-indexed layer to draw to

      Returns void

    • Get the current cursor position.

      Returns [number, number]

      Cursor position as [x, y]

    • Determine whether a key is currently pressed.

      Parameters

      • key: string

        The key to check

      Returns boolean

      True if key is down

    • Determine whether a mouse button is currently pressed.

      Parameters

      • button: number

        The button ID

      Returns boolean

      True if button is down

    • Determines whether audio is muted

      Returns boolean

      True if currently muted

    • Determines whether the media recorder is active

      Returns boolean

      True if currently recording

    • Mute all audio

      Returns void

    • Play an audio file

      Parameters

      • src: string

        The path of the audio file

      • loop: boolean = false

        Whether to play the audio on loop

      • volume: number = 1

        The normalized [0-1] volume

      • track: number = 0

        The track number to play on

      Returns void

    • Take a screenshot of the canvas contents and save to a .png file.

      Parameters

      • name: string = 'screenshot'

        The file name of the screenshot

      Returns void

    • Start recording all layers on the canvas

      Returns void

    • Stop all audio tracks from playing

      Parameters

      • track: number = -1

      Returns void

    • Stop recording and download screen capture

      Returns void

    • Unmute all audio

      Returns void