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

Hierarchy (view full)

Properties

Accessors

Methods

Properties

texture: Texture

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

frame: Container

The border frame and resizing handles for the drawing.

text: PreciseText = null

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

shape: Graphics | PrimaryGraphics

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

_pendingText: string

The pending text.

_onkeydown: Function = null

The registered keydown listener.

scene: Scene

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

document: Document

Each Drawing object provides an interface for a DrawingDocument

controlIcon: ControlIcon

A control icon for interacting with the object

mouseInteractionManager: MouseInteractionManager

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

#drawTime: number = 0

An internal timestamp for the previous freehand draw time, to limit sampling.

#fixedPoints: number[] = ...

An internal flag for the permanent points of the polygon.

#deleteIfEmptyText: boolean = false

Delete the Drawing if the text is empty once text editing ends?

#original: PlaceableObject

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

#lastQuadtreeBounds: Rectangle

The bounds that the placeable was added to the quadtree with.

#drawing: Promise<PlaceableObject> = ...

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

#drawn: boolean = false

Has this Placeable Object been drawn and is there no drawing in progress?

embeddedName: string = "Drawing"

Identify the official Document name for this PlaceableObject class

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

Type declaration

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

                Deprecated

                since v12

                • propagate: string[]
                • deprecated: {
                      since: number;
                      until: number;
                      alias: boolean;
                  }
                  • since: number
                  • until: number
                  • alias: boolean
              FREEHAND_SAMPLE_RATE: number = 75

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

              SHAPE_TYPES: {
                  RECTANGLE: string;
                  CIRCLE: string;
                  ELLIPSE: string;
                  POLYGON: string;
              } = foundry.data.ShapeData.TYPES

              A convenience reference to the possible shape types.

              Type declaration

              • RECTANGLE: string
              • CIRCLE: string
              • ELLIPSE: string
              • POLYGON: string

              Accessors

              • get isAuthor(): boolean
              • A convenient reference for whether the current User is the author of the Drawing document.

                Returns boolean

              • get isVisible(): boolean
              • Is this Drawing currently visible on the Canvas?

                Returns boolean

              • get bounds(): Rectangle
              • Returns Rectangle

              • get center(): any
              • Returns any

              • get isTiled(): boolean
              • A Boolean flag for whether the Drawing utilizes a tiled texture background?

                Returns boolean

              • get isPolygon(): boolean
              • A Boolean flag for whether the Drawing is a Polygon type (either linear or freehand)?

                Returns boolean

              • get hasText(): boolean
              • Does the Drawing have text that is displayed?

                Returns boolean

              • get type(): string
              • The shape type that this Drawing represents. A value in Drawing.SHAPE_TYPES.

                Returns string

              • get _original(): PlaceableObject
              • The object that this object is a preview of if this object is a preview.

                Returns PlaceableObject

              • get isOwner(): boolean
              • A convenient reference for whether the current User has full control over the document.

                Returns boolean

              • get interactionState(): {
                    NONE: number;
                    HOVER: number;
                    CLICKED: number;
                    GRABBED: number;
                    DRAG: number;
                    DROP: number;
                }
              • The mouse interaction state of this placeable.

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

                • NONE: number
                • HOVER: number
                • CLICKED: number
                • GRABBED: number
                • DRAG: number
                • DROP: number
              • get id(): string
              • The id of the corresponding Document which this PlaceableObject represents.

                Returns string

              • get objectId(): string
              • A unique identifier which is used to uniquely identify elements on the canvas related to this object.

                Returns string

              • 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 isPreview(): boolean
              • Is this placeable object a temporary preview?

                Returns boolean

              • get hasPreview(): boolean
              • Does there exist a temporary preview of this placeable object?

                Returns boolean

              • get layer(): PlaceablesLayer
              • Provide a reference to the CanvasLayer which contains this PlaceableObject.

                Returns PlaceablesLayer

              • get sheet(): FormApplication
              • A Form Application which is used to configure the properties of this Placeable Object or the Document it represents.

                Returns FormApplication

              • get controlled(): boolean
              • An indicator for whether the object is currently controlled

                Returns boolean

              • get hover(): boolean
              • An indicator for whether the object is currently a hover target

                Returns boolean

              • get hasActiveHUD(): boolean
              • Is the HUD display active for this Placeable?

                Returns boolean

              Methods

              • The inner _destroy method which may optionally be defined by each PlaceableObject subclass.

                Parameters

                • options: any

                  Options passed to the initial destroy call

                Returns void

              • Parameters

                • options: any

                Returns Promise<void>

              • Clone the placeable object, returning a new object with identical attributes. The returned object is non-interactive, and has no assigned ID. If you plan to use it permanently you should call the create method.

                Returns PlaceableObject

                A new object with identical data

              • Internal

                Add a new polygon point to the drawing, ensuring it differs from the last one

                Parameters

                • position: Point

                  The drawing point to add

                • Optional options: {
                      round: boolean;
                      snap: boolean;
                      temporary: boolean;
                  } = {}

                  Options which configure how the point is added

                  • round: boolean

                    Should the point be rounded to integer coordinates?

                  • snap: boolean

                    Should the point be snapped to grid precision?

                  • temporary: boolean

                    Is this a temporary control point?

                Returns void

              • Internal

                Remove the last fixed point from the polygon

                Returns void

              • Additional events which trigger once control of the object is established

                Parameters

                • options: any

                  Optional parameters which apply for specific implementations

                Returns void

              • Additional events which trigger once control of the object is released

                Parameters

                • options: any

                  Options which modify the releasing workflow

                Returns void

              • Enable text editing for this drawing.

                Parameters

                • Optional options: object = {}

                Returns void

              • Define additional steps taken when an existing placeable object of this type is updated with new data

                Parameters

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

                Returns void

              • Define additional steps taken when an existing placeable object of this type is deleted

                Parameters

                • options: any
                • userId: any

                Returns void

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

                Parameters

                • event: any

                  The triggering canvas interaction event

                Returns void

                See

                MouseInteractionManager##handleClickLeft

              • Callback actions which occur on a mouse-move operation.

                Parameters

                • event: any

                  The triggering mouse click event

                Returns void

                See

                MouseInteractionManager##handleDragCancel

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

                Parameters

                • Optional position: Point

                  The position to be used instead of the current position

                Returns Point

                The snapped position

              • Draw the placeable object into its parent container

                Parameters

                • Optional options: object = {}

                  Options which may modify the draw and refresh workflow

                Returns Promise<PlaceableObject>

                The drawn object

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

                Parameters

                • Optional options: object = {}

                  Options which may modify the refresh workflow

                Returns PlaceableObject

                The refreshed object

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

                Parameters

                • options: {
                      releaseOthers: boolean;
                  } = {}

                  Additional options which modify the control request

                  • releaseOthers: boolean

                    Release any other controlled objects first

                Returns boolean

                A flag denoting whether control was successful

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

                Parameters

                • options: object = {}

                  Options which modify the releasing workflow

                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

              • 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

                  • angle: number

                    An explicit angle, either this or delta must be provided

                  • delta: number

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

                  • snap: number

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

                Returns number

                The new rotation angle for the object

              • 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

                Returns Point

                The shifted target coordinates

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

                Parameters

                • user: User

                  The User performing the action

                • action: string

                  The named action being attempted

                Returns boolean

                Does the User have rights to perform the action?

              • Perform the database updates that should occur as the result of a drag-left-drop operation.

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns object[]

                An array of database updates to perform for documents in this collection

              • Protected

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

                Returns object

                The line style options (PIXI.ILineStyleOptions).

              • Protected

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

                Returns object

                The fill style options (PIXI.IFillStyleOptions).

              • Protected

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

                Returns TextStyle

              • Protected

                Refresh the position.

                Returns void

              • Protected

                Refresh the rotation.

                Returns void

              • Protected

                Refresh the displayed state of the Drawing. Used to update aspects of the Drawing which change based on the user interaction state.

                Returns void

              • Protected

                Clear and then draw the shape.

                Returns void

              • 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 border frame that encloses the Drawing.

                Returns void

              • Protected

                Refresh the content and appearance of text.

                Returns void

              • Protected

                Handle mouse movement which modifies the dimensions of the drawn shape.

                Parameters

                • event: FederatedEvent

                Returns void

              • Protected

                Handle mouse-over event on a control handle

                Parameters

                • event: FederatedEvent

                  The mouseover event

                Returns void

              • Protected

                Handle mouse-out event on a control handle

                Parameters

                • event: FederatedEvent

                  The mouseout event

                Returns void

              • Protected

                Starting the resize handle drag event, initialize the original data.

                Parameters

                • event: FederatedEvent

                  The mouse interaction event

                Returns void

              • Protected

                Handle mousemove while dragging a tile scale handler

                Parameters

                • event: FederatedEvent

                  The mouse interaction event

                Returns void

              • Protected

                Handle mouseup after dragging a tile scale handler

                Parameters

                • event: FederatedEvent

                  The mouseup event

                Returns void

              • Protected

                Handle cancellation of a drag event for one of the resizing handles

                Parameters

                • event: PointerEvent

                  The drag cancellation event

                Returns void

              • Protected

                Get the target opacity that should be used for a Placeable Object depending on its preview state.

                Returns number

              • 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

                Can the User access the HUD for this Placeable Object?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

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

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

                Does the User have permission to create the underlying Document?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

                Does the User have permission to drag this Placeable Object?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

                Does the User have permission to left-click drag this Placeable Object?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

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

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

                Does the User have permission to update the underlying Document?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • Protected

                Does the User have permission to delete the underlying Document?

                Parameters

                • user: User

                  The User performing the action.

                • event: object

                  The event object.

                Returns boolean

                The returned status.

              • 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: FederatedEvent

                  The triggering canvas interaction event

                • options: {
                      hoverOutOthers: boolean;
                  } = {}

                  Options which customize event handling

                  • hoverOutOthers: boolean

                    Trigger hover-out behavior on sibling objects

                Returns void

                See

                MouseInteractionManager##handlePointerOver

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns void

                See

                MouseInteractionManager##handlePointerOut

              • Protected

                Should the placeable propagate left click downstream?

                Parameters

                • event: FederatedEvent

                Returns boolean

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns void

              • Protected

                Callback actions which occur on a double left-click event to activate

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns void

                See

                MouseInteractionManager##handleClickLeft2

              • Protected

                Should the placeable propagate right click downstream?

                Parameters

                • event: FederatedEvent

                Returns boolean

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns void

                See

                MouseInteractionManager##handleClickRight

              • Protected

                Callback actions which occur on a single right-unclick event

                Parameters

                • event: FederatedEvent

                  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

                  The triggering canvas interaction event

                Returns void

                See

                MouseInteractionManager##handleClickRight2

              • 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

                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

                  The triggering mouse click event

                Returns any

                See

                MouseInteractionManager##handleDragStart

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns any

                See

                MouseInteractionManager##handleDragMove

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                Returns Promise<any>

                See

                MouseInteractionManager##handleDragDrop

              • Protected

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

                Parameters

                • event: FederatedEvent

                  The triggering mouse click event

                Returns any

                See

                MouseInteractionManager##handleDragCancel

              • Protected

                Callback action which occurs on a long press.

                Parameters

                • event: FederatedEvent

                  The triggering canvas interaction event

                • origin: Point

                  The local canvas coordinates of the mousepress.

                Returns any

                See

                MouseInteractionManager##handleLongPress

              • Remove a drawing object.

                Returns void

              • Create elements for the Drawing border and handles

                Returns Container

              • Create a PreciseText element to be displayed as part of this drawing.

                Returns PreciseText

              • Handle text entry in an active text tool

                Parameters

                • event: KeyboardEvent

                Returns void

              • Perform database updates using the result of a drag-left-drop operation.

                Parameters

                • updates: object[]

                  The database updates for documents in this collection

                Returns Promise<void>

              • 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

              • 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