A CanvasLayer responsible for drawing a square grid

Hierarchy (view full)

Properties

mesh: GridMesh

The grid mesh.

highlight: Container

The Grid Highlight container

highlightLayers: Record<string, GridHighlight> = {}

Map named highlight layers

options: {
    name: string;
} = ...

Options for this layer instance.

Type declaration

  • name: string
#drawing: Promise<CanvasLayer> = ...

An internal reference to a Promise in-progress to draw the CanvasLayer.

#drawn: boolean = false

Is the layer drawn?

Accessors

  • 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

    Example

    canvas.lighting.name -> "LightingLayer"
    
  • 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 layerOptions(): object
  • Customize behaviors of this CanvasLayer by modifying some behaviors at a class level.

    Returns object

  • get instance(): CanvasLayer
  • Return a reference to the active instance of this canvas layer

    Returns CanvasLayer

Methods

  • Parameters

    • options: any

    Returns Promise<void>

  • Initialize the grid mesh appearance and configure the grid shader.

    Parameters

    • options: {
          style: string;
          thickness: number;
          color: string;
          alpha: number;
      }
      • style: string

        The grid style

      • thickness: number

        The grid thickness

      • color: string

        The grid color

      • alpha: number

        The grid alpha

    Returns void

  • Define a new Highlight graphic

    Parameters

    • name: string

      The name for the referenced highlight layer

    Returns GridHighlight

  • Clear a specific Highlight graphic

    Parameters

    • name: string

      The name for the referenced highlight layer

    Returns void

  • Destroy a specific Highlight graphic

    Parameters

    • name: string

      The name for the referenced highlight layer

    Returns void

  • Obtain the highlight layer graphic by name

    Parameters

    • name: string

      The name for the referenced highlight layer

    Returns GridHighlight

  • Add highlighting for a specific grid position to a named highlight graphic

    Parameters

    • name: string

      The name for the referenced highlight layer

    • Optional options: {
          x: number;
          y: number;
          color: ColorSource;
          border: any;
          alpha: number;
          shape: Polygon;
      }

      Options for the grid position that should be highlighted

      • x: number

        The x-coordinate of the highlighted position

      • y: number

        The y-coordinate of the highlighted position

      • color: ColorSource

        The fill color of the highlight

      • border: any

        The border color of the highlight

      • alpha: number

        The opacity of the highlight

      • shape: Polygon

        A predefined shape to highlight

    Returns 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

    • Optional options: object = {}

      Options which configure how the layer is drawn

    Returns Promise<CanvasLayer>

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

    Parameters

    • Optional options: object = {}

      Options which configure how the layer is deconstructed

    Returns Promise<CanvasLayer>

  • Protected

    Creates the grid mesh.

    Returns Promise<GridMesh>

  • Protected

    The inner _tearDown method which may be customized by each CanvasLayer subclass.

    Parameters

    • options: object

      Options which configure how the layer is deconstructed

    Returns Promise<void>