Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    A CanvasLayer for displaying UI controls which are overlayed on top of other layers.

    We track three types of events:

    1. Cursor movement
    2. Ruler measurement
    3. Map pings

    Hierarchy (View Summary)

    Index

    Properties

    _rulerPaths: Container<DisplayObject>

    The ruler paths.

    A container of cursor interaction elements not bound to stage transforms. Contains cursors elements.

    debug: Graphics

    A graphics instance used for drawing debugging visualization

    doors: Container<DisplayObject>

    A container of DoorControl instances

    options: { name: string } = ...

    Options for this layer instance.

    pings: Container<DisplayObject>

    A container of pings interaction elements. Contains pings elements.

    select: Graphics

    The Canvas selection rectangle

    Accessors

    • get hookName(): string

      The name used by hooks to construct their hook string. Note: You should override this getter if hookName should not return the class constructor name.

      Returns string

    • get name(): string

      The canonical name of the CanvasLayer is the name of the constructor that is the immediate child of the defined baseClass for the layer type.

      Returns string

      canvas.lighting.name -> "LightingLayer"
      
    • get ruler(): BaseRuler

      A convenience accessor to the Ruler for the active game user

      Returns BaseRuler

    • get instance(): CanvasLayer

      Return a reference to the active instance of this canvas layer

      Returns CanvasLayer

    • get layerOptions(): object

      Returns object

    Methods

    • Returns void

    • The inner _draw method which must be defined by each CanvasLayer subclass.

      Parameters

      • options: any

        Options which configure how the layer is drawn

      Returns Promise<void>

    • Internal

      Handle mousemove events on the game canvas to broadcast activity. With SHOW_CURSOR permission enabled, the user's cursor position is transmitted.

      Parameters

      • currentPos: Point

      Returns void

    • Parameters

      • options: any

      Returns Promise<void>

    • Draw the canvas layer, rendering its internal components and returning a Promise. The Promise resolves to the drawn layer once its contents are successfully rendered.

      Parameters

      • Optionaloptions: object = {}

        Options which configure how the layer is drawn

      Returns Promise<CanvasLayer>

    • Create and draw the Cursor object for a given User.

      Parameters

      • user: documents.User

        The User document for whom to draw the cursor Container

      Returns Cursor

    • Draw the cursors container

      Returns void

    • Draw door control icons to the doors container.

      Returns void

    • Draw a ping at the edge of the viewport, pointing to the location of an off-screen ping.

      Parameters

      • position: Point

        The coordinates of the off-screen ping.

      • Optionaloptions: any = {}

        Additional options to configure how the ping is drawn.

      Returns Promise<boolean>

      A promise which resolves once the Ping has been drawn and animated.

    • Draw a ping on the canvas.

      Parameters

      • position: Point

        The position on the canvas that was pinged.

      • Optionaloptions: any = {}

        Additional options to configure how the ping is drawn.

      Returns Promise<boolean>

      A promise which resolves once the Ping has been drawn and animated.

    • Create and draw the Ruler object for a given User.

      Parameters

      • user: documents.User

        The User document for whom to draw the Ruler

      Returns Promise<BaseRuler>

      The Ruler instance

    • Create and add Ruler instances for every game User.

      Returns Promise<void>

    • Draw the select rectangle given an event originated within the base canvas layer

      Parameters

      Returns void

    • Get the Cursor instance for a specific User ID.

      Parameters

      • userId: string

        The User ID

      Returns Cursor | null

    • Get the Ruler instance for a specific User ID.

      Parameters

      • userId: string

        The User ID

      Returns BaseRuler | null

    • Get the zIndex that should be used for ordering this layer vertically relative to others in the same Container.

      Returns number

    • Handle a broadcast ping.

      Parameters

      • user: documents.User

        The user who pinged.

      • position: Point

        The position on the canvas that was pinged.

      • Optionaldata: PingData = {}

        The broadcast ping data.

      Returns Promise<boolean>

      A promise which resolves once the Ping has been drawn and animated

    • Deconstruct data used in the current layer in preparation to re-draw the canvas

      Parameters

      • Optionaloptions: object = {}

        Options which configure how the layer is deconstructed

      Returns Promise<CanvasLayer>

    • Update the cursor when the user moves to a new position

      Parameters

      • user: documents.User

        The User for whom to update the cursor

      • position: Point

        The new cursor position

      Returns void

    • Update the Ruler for a User given the provided path.

      Parameters

      • user: documents.User

        The User for whom to update the Ruler

      • data: { hidden: boolean; path: ElevatedPoint[] } | null

        The path and hidden state of the Ruler

      Returns Promise<void>

    • Protected

      Handle the canvas panning to a new view.

      Returns void

    • Protected

      Handle pinging the canvas.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event.

      • origin: Point

        The local canvas coordinates of the mousepress.

      Returns Promise<boolean> | undefined