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

    The Drawing object is an implementation of the PlaceableObject container. Each Drawing is a placeable object in the DrawingsLayer.

    Index

    Constructors

    Properties

    Accessors

    Methods

    Constructors

    • Parameters

      • document: CanvasDocument

        The Document instance represented by this object

      Returns canvas.placeables.Drawing

    Properties

    _hoveredHandle: ShapeControlsHandle | null = null
    _onkeydown: Function | null = null

    The registered keydown listener.

    _pendingText: string

    The pending text.

    _previewType:
        | "wheel"
        | "controls"
        | "dragging"
        | "creation"
        | "config"
        | "api"
        | null

    The preview type, if any.

    controlIcon: ControlIcon | null

    A control icon for interacting with the object

    controls: Container<DisplayObject>

    The shape controls of this Drawing.

    document: CanvasDocument

    A reference to the Scene embedded Document instance which this object represents

    frame: Container<DisplayObject>

    The border frame and resizing handles for the drawing.

    mouseInteractionManager: MouseInteractionManager | null

    A mouse interaction manager instance which handles mouse workflows related to this object.

    renderFlags: RenderFlags

    Status flags which are applied at render-time to update the PlaceableObject. If an object defines RenderFlags, it should at least include flags for "redraw" and "refresh".

    Retain a reference to the Scene within which this Placeable Object resides

    shape: any

    The drawing shape which is rendered as a PIXI.Graphics in the interface or a PrimaryGraphics in the Primary Group.

    text: PreciseText | null = null

    A text label that may be displayed as part of the interface layer for the Drawing.

    texture: Texture<Resource> | null = null

    The texture that is used to fill this Drawing, if any.

    _measurementDashLineStyle: ILineStyleOptions

    The dashed measurement line style.

    _measurementLabels: Container<DisplayObject>

    The measurement labels.

    _measurementLines: Graphics

    The measurement lines.

    _measurementSolidLineStyle: ILineStyleOptions

    The solid measurement line style.

    embeddedName: string = "Drawing"
    FREEHAND_SAMPLE_RATE: number = 75

    The rate at which points are sampled (in milliseconds) during a freehand drawing workflow

    RENDER_FLAG_PRIORITY: string = "OBJECTS"

    The ticker priority when RenderFlags of this class are handled. Valid values are OBJECTS or PERCEPTION.

    RENDER_FLAGS: {
        redraw: { propagate: string[] };
        refresh: { alias: boolean; propagate: string[] };
        refreshElevation: {};
        refreshFrame: {
            alias: boolean;
            deprecated: { since: number; until: number };
        };
        refreshPosition: {};
        refreshRotation: {};
        refreshShape: {};
        refreshSize: { propagate: string[] };
        refreshState: { propagate: string[] };
        refreshText: {};
        refreshTransform: { alias: boolean; propagate: string[] };
        refreshVisibility: {};
    } = ...

    Type Declaration

    • redraw: { propagate: string[] }
    • refresh: { alias: boolean; propagate: string[] }
    • refreshElevation: {}
    • refreshFrame: { alias: boolean; deprecated: { since: number; until: number } }

      since v14

    • refreshPosition: {}
    • refreshRotation: {}
    • refreshShape: {}
    • refreshSize: { propagate: string[] }
    • refreshState: { propagate: string[] }
    • refreshText: {}
    • refreshTransform: { alias: boolean; propagate: string[] }
    • refreshVisibility: {}
    SHAPE_TYPES: {
        CIRCLE: string;
        ELLIPSE: string;
        POLYGON: string;
        RECTANGLE: string;
    } = ShapeData.TYPES

    A convenience reference to the possible shape types.

    Accessors

    • get _original(): PlaceableObject | undefined

      The object that this object is a preview of if this object is a preview.

      Returns PlaceableObject | undefined

    • get bounds(): any

      Returns any

    • get center(): Point

      Returns Point

    • get controlled(): boolean

      An indicator for whether the object is currently controlled

      Returns boolean

    • get hasActiveHUD(): boolean

      Is the HUD display active for this Placeable?

      Returns boolean

    • get hasPreview(): boolean

      Does there exist a temporary preview of this placeable object?

      Returns boolean

    • get hasText(): boolean

      Does the Drawing have text that is displayed?

      Returns boolean

    • get hover(): boolean

      An indicator for whether the object is currently a hover target

      Returns boolean

    • get hoveredHandle(): ShapeControlsHandle | null

      The controls handle that is currently hovered, if any.

      Returns ShapeControlsHandle | null

    • get id(): string

      The id of the corresponding Document which this PlaceableObject represents.

      Returns string

    • get interactionState(): | {
          CLICKED: number;
          DRAG: number;
          DROP: number;
          GRABBED: number;
          HOVER: number;
          NONE: number;
      }
      | undefined

      The mouse interaction state of this placeable.

      Returns
          | {
              CLICKED: number;
              DRAG: number;
              DROP: number;
              GRABBED: number;
              HOVER: number;
              NONE: number;
          }
          | undefined

    • get isAuthor(): boolean

      A convenient reference for whether the current User is the author of the Drawing document.

      Returns boolean

    • get isInteractable(): boolean

      Returns boolean

    • get isOwner(): boolean

      A convenient reference for whether the current User has full control over the document.

      Returns boolean

    • get isPolygon(): boolean

      A Boolean flag for whether the Drawing is a Polygon type (either linear or freehand)?

      Returns boolean

    • get isPreview(): boolean

      Is this placeable object a temporary preview?

      Returns boolean

    • get isTiled(): boolean

      A Boolean flag for whether the Drawing utilizes a tiled texture background?

      Returns boolean

    • get isVisible(): boolean

      Is this placeable currently visible?

      Returns boolean

    • get layer(): PlaceablesLayer

      Provide a reference to the CanvasLayer which contains this PlaceableObject.

      Returns PlaceablesLayer

    • get objectId(): string

      A unique identifier which is used to uniquely identify elements on the canvas related to this object.

      Returns string

    • get previewType(): "dragging" | "controls|"

      The preview type, if any.

      Returns "dragging" | "controls|"

    • get sheet(): DocumentSheetV2

      A document sheet used to configure the properties of this Placeable Object or the Document it represents.

      Returns DocumentSheetV2

    • get sourceId(): string

      The named identified for the source object associated with this PlaceableObject. This differs from the objectId because the sourceId is the same for preview objects as for the original.

      Returns string

    • get type(): string

      The shape type that this Drawing represents. A value in Drawing.SHAPE_TYPES.

      Returns string

    • get implementation(): typeof PlaceableObject

      Return a reference to the configured subclass of this base PlaceableObject type.

      Returns typeof PlaceableObject

    Methods

    • Parameters

      • flags: any

      Returns void

    • Parameters

      • user: any
      • event: any
      • options: any

      Returns any

    • Returns void

    • Parameters

      • options: any

      Returns void

    • Parameters

      • options: any

      Returns Promise<void>

    • Parameters

      • event: any

      Returns void

    • Internal

      Obtain a shifted position for the Placeable Object.

      Parameters

      • dx: -1 | 0 | 1

        The number of grid units to shift along the X-axis

      • dy: -1 | 0 | 1

        The number of grid units to shift along the Y-axis

      • dz: -1 | 0 | 1

        The number of grid units to shift along the Z-axis

      Returns object

      The shifted target coordinates

    • Returns number

    • Parameters

      • event: any

      Returns void

    • Parameters

      • event: any

      Returns any

    • Parameters

      • event: any

      Returns false | undefined

    • Parameters

      • event: any

      Returns any

    • Parameters

      • options: any

      Returns void

    • Parameters

      • options: any
      • userId: any

      Returns void

    • Parameters

      • event: any

      Returns any

    • Parameters

      • event: any

      Returns any

    • Parameters

      • event: any

      Returns any

    • Parameters

      • event: any

      Returns any

    • Parameters

      • options: any

      Returns void

    • Parameters

      • changed: any
      • options: any
      • userId: any

      Returns void

    • Parameters

      • rectangle: any

      Returns boolean

    • Internal

      Execute a partial draw.

      Parameters

      • fn: () => Promise<void>

        The draw function

      Returns Promise<PlaceableObject>

      The drawn object

    • Internal

      Get the data of the copied object pasted at the position given by the offset. Called by foundry.canvas.layers.PlaceablesLayer#pasteObjects for each copied object.

      Parameters

      • offset: Point

        The offset relative from the current position to the destination

      • Optionaloptions: { cut?: boolean; hidden?: boolean; snap?: boolean } = {}
        • Optionalcut?: boolean

          Is cut operation?

        • Optionalhidden?: boolean

          Paste in a hidden state, if applicable. Default is false.

        • Optionalsnap?: boolean

          Snap to the grid. Default is true.

      Returns object

      The create or update data

    • Parameters

      • event: any

      Returns { _id: any; x: any; y: any }[]

    • Returns void

    • Returns void

    • Parameters

      • event: any

      Returns void

    • Internal

      Update the quadtree.

      Returns void

    • Internal

      Determine a new angle of rotation for a PlaceableObject either from an explicit angle or from a delta offset.

      Parameters

      • options: { angle?: number; delta?: number; snap?: number } = {}

        An object which defines the rotation update parameters

        • Optionalangle?: number

          An explicit angle, either this or delta must be provided

        • Optionaldelta?: number

          A relative angle delta, either this or the angle must be provided

        • Optionalsnap?: number

          A precision (in degrees) to which the resulting angle should snap. Default is 0.

      Returns number

      The new rotation angle for the object

    • Activate interactivity for the Placeable Object

      Returns void

    • Returns void

    • Test whether a user can perform a certain interaction regarding a Placeable Object

      Parameters

      • user: documents.User

        The User performing the action. Must be equal to game.user.

      • action:
            | "view"
            | "create"
            | "update"
            | "delete"
            | "control"
            | "hover"
            | "drag"
            | "configure"
            | "HUD"

        The named action being attempted

      Returns boolean

      Does the User have rights to perform the action?

    • Assume control over a PlaceableObject, flagging it as controlled and enabling downstream behaviors

      Parameters

      • Optionaloptions: {
            force?: boolean;
            isNew?: boolean;
            releaseOthers?: boolean;
            renderSidebar?: boolean;
        } = {}

        Additional options which modify the control request

        • Optionalforce?: boolean

          Control the object even if it is not interactable?

        • OptionalisNew?: boolean

          Was this object just created?

        • OptionalreleaseOthers?: boolean

          Release any other controlled objects first

        • OptionalrenderSidebar?: boolean

          Re-render the sidebar.

      Returns boolean

      A flag denoting whether control was successful

    • Parameters

      • options: any

      Returns any

    • Draw the placeable object into its parent container

      Parameters

      • Optionaloptions: object = {}

        Options which may modify the draw and refresh workflow

      Returns Promise<PlaceableObject>

      The drawn object

    • Enable text editing for this drawing.

      Parameters

      • Optionaloptions: object = {}

      Returns void

    • Get the snapped position for a given position or the current position.

      Parameters

      • Optionalposition: any

        The position to be used instead of the current position

      Returns Point

      The snapped position

    • Refresh all incremental render flags for the PlaceableObject. This method is no longer used by the core software but provided for backwards compatibility.

      Parameters

      • Optionaloptions: object = {}

        Options which may modify the refresh workflow

      Returns PlaceableObject

      The refreshed object

    • Release control over a PlaceableObject, removing it from the controlled set

      Parameters

      • options: { renderSidebar?: boolean } = {}

        Options which modify the releasing workflow

        • OptionalrenderSidebar?: boolean

          Re-render the sidebar.

      Returns boolean

      A Boolean flag confirming the object was released.

    • Rotate the PlaceableObject to a certain angle of facing

      Parameters

      • angle: number

        The desired angle of rotation

      • snap: number

        Snap the angle of rotation to a certain target degree increment

      Returns Promise<PlaceableObject>

      The rotated object

    • Protected

      Does the User have permission to configure the Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to control the Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to create the underlying Document?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to delete the underlying Document?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to drag this Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to hover on this Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Can the User access the HUD for this Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to update the underlying Document?

      Parameters

      Returns boolean

    • Protected

      Does the User have permission to view details of the Placeable Object?

      Parameters

      Returns boolean

    • Protected

      Create a standard MouseInteractionManager for the PlaceableObject

      Returns MouseInteractionManager | null

    • Protected

      Finalize the right-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering mouse click event

      Returns void

    • Protected

      Format a distance that is displayed in a measurement label.

      Parameters

      • distance: number

        The distance

      Returns string

      The distance label

    • Protected

      Get the fill style used for drawing the shape of this Drawing.

      Returns object

      The fill style options (PIXI.IFillStyleOptions).

    • Protected

      Get the line style used for drawing the shape of this Drawing.

      Returns object

      The line style options (PIXI.ILineStyleOptions).

    • Protected

      Get the shape that should be measured.

      Returns BaseShapeData[]

    • Protected

      Define a PIXI TextStyle object which is used for the measurement labels.

      Returns TextStyle

    • Protected

      Prepare the text style used to instantiate a PIXI.Text or PreciseText instance for this Drawing document.

      Returns TextStyle

    • Protected

      Initialize the right-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Callback actions which occur on a single right-click event to configure properties of the object

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Callback actions which occur on a double right-click event to configure properties of the object

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Register pending canvas operations which should occur after a new PlaceableObject of this type is created

      Parameters

      • data: object
      • options: object
      • userId: string

      Returns void

    • Protected

      Conclude a drag operation from the perspective of the preview clone. Modify the appearance of both the clone (this) and the original (_original) object.

      Returns void

    • Protected

      Callback actions which occur on a right mouse-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering mouse click event

      Returns boolean | void

      If false, the cancellation is prevented

    • Protected

      Callback actions which occur on a right mouse-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Callback actions which occur on a right mouse-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Callback actions which occur on a right mouse-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering mouse click event

      Returns false | void

      If false, the start if prevented

    • Protected

      Begin a drag operation from the perspective of the preview clone. Modify the appearance of both the clone (this) and the original (_original) object.

      Returns void

    • Protected

      Actions that should be taken for this Placeable Object when a mouseover event occurs. Hover events on PlaceableObject instances allow event propagation by default.

      Parameters

      • event: Event | FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas or DOM interaction event

      • Optionaloptions: { hoverOutOthers?: boolean; updateLegend?: boolean } = {}

        Options which customize event handling

        • OptionalhoverOutOthers?: boolean

          Trigger hover-out behavior on sibling objects

        • OptionalupdateLegend?: boolean

          Highlight corresponding entry in the sidebar legend.

      Returns boolean | void

    • Protected

      Actions that should be taken for this Placeable Object when a mouseout event occurs

      Parameters

      • event: Event | FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas or DOM interaction event

      • Optionaloptions: { updateLegend?: boolean } = {}

        Options which customize event handling

        • OptionalupdateLegend?: boolean

          Highlight corresponding entry in the sidebar legend.

      Returns void

    • Protected

      Callback action which occurs on a long press.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      • origin: Point

        The local canvas coordinates of the mousepress.

      Returns any

    • Protected

      Callback actions which occur on a single left-unclick event to assume control of the object

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Callback actions which occur on a single right-unclick event

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering canvas interaction event

      Returns void

    • Protected

      Should the placeable propagate left click downstream?

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

      Returns boolean

    • Protected

      Should the placeable propagate right click downstream?

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

      Returns boolean

    • Protected

      Update sorting of this Drawing relative to other PrimaryCanvasGroup siblings. Called when the elevation or sort order for the Drawing changes.

      Returns void

    • Protected

      Refresh the measurements.

      Returns void

    • Protected

      Refresh the position.

      Returns void

    • Protected

      Refresh the rotation.

      Returns void

    • Protected

      Clear and then draw the shape.

      Returns void

    • Protected

      Refresh the content and appearance of text.

      Returns void

    • Protected

      Callback actions which occur on a right mouse-drag operation.

      Parameters

      • event: FederatedEvent<UIEvent | PixiTouch>

        The triggering mouse click event

      Returns false | void

      If false, the start if prevented

    • Internal

      Get the origin used for pasting the copied objects.

      Parameters

      Returns Point

      The offset

    • Internal

      Obtain the shifted position.

      Parameters

      • dx: -1 | 0 | 1

        The number of grid units to shift along the X-axis

      • dy: -1 | 0 | 1

        The number of grid units to shift along the Y-axis

      • dz: -1 | 0 | 1

        The number of grid units to shift along the Z-axis

      • position: ElevatedPoint

        The unsnapped position

      • snapped: ElevatedPoint

        The snapped position

      • grid: BaseGrid<GridCoordinates2D, GridCoordinates3D>

        The grid

      Returns ElevatedPoint

      The shifted target coordinates

    • Adjust the location, dimensions, and points of the Drawing before committing the change.

      Parameters

      • data: object

        The DrawingData pending update

      Returns object

      The adjusted data

    • Get a vectorized rescaling transformation for drawing data and dimensions passed in parameter

      Parameters

      • original: Object

        The original drawing data

      • dx: number

        The pixel distance dragged in the horizontal direction

      • dy: number

        The pixel distance dragged in the vertical direction

      Returns object

      The adjusted shape data