Options
All
  • Public
  • Public/Protected
  • All
Menu

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

property

{DrawingsLayer} layer Each Drawing object belongs to the DrawingsLayer

property

{DrawingDocument} document Each Drawing object provides an interface for a DrawingDocument

Hierarchy

Index

Constructors

  • new Drawing(document: any): Drawing

Properties

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.

The drawing shape which is rendered as a PIXI.Graphics subclass in the PrimaryCanvasGroup.

_pendingText: any
texture: any
cursor: string
visible: any
hitArea: any
zIndex: Document
alpha: number
_onkeydown: any
_dragHandle: boolean
scene: Scene

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

document: Document

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

vision: { fov: Circle; los: PointSourcePolygon }

Track the field of vision for the placeable object. This is necessary to determine whether a player has line-of-sight towards a placeable object or vice-versa

Type declaration

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.

cullable: boolean
renderable: any
_preview: any
_dragPassthrough: boolean = false

Passthrough certain drag operations on locked objects.

_isHoverIn: boolean = false

Know if a placeable is in the hover-in state.

#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.

#bounds: Rectangle

The computed bounds of the Drawing.

#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?

#controlled: boolean = false
#hover: boolean = false
embeddedName: string = "Drawing"

Identify the official Document name for this PlaceableObject class

RENDER_FLAGS: { redraw: { propagate: string[] }; refresh: { propagate: string[]; alias: boolean }; refreshState: { propagate: string[] }; refreshShape: { propagate: string[] }; refreshFrame: {}; refreshText: {}; refreshMesh: {} } = ...
override

Type declaration

  • redraw: { propagate: string[] }
    • propagate: string[]
  • refresh: { propagate: string[]; alias: boolean }
    • propagate: string[]
    • alias: boolean
  • refreshState: { propagate: string[] }
    • propagate: string[]
  • refreshShape: { propagate: string[] }
    • propagate: string[]
  • refreshFrame: {}
    • refreshText: {}
      • refreshMesh: {}
        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

        • override

          Returns Rectangle

        • get center(): any
        • override

          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.

          see

          Drawing.SHAPE_TYPES

          Returns string

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

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

          • NONE: number
          • HOVER: number
          • CLICKED: 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

        • The field-of-vision polygon for the object, if it has been computed

          Returns Circle

        • Provide a reference to the CanvasLayer which contains this PlaceableObject.

          Returns PlaceablesLayer

        • The line-of-sight polygon for the object, if it has been computed

          Returns PointSourcePolygon

        • 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
        • set hover(state: boolean): void
        • An indicator for whether the object is currently a hover target

          Returns boolean

        • An indicator for whether the object is currently a hover target

          Parameters

          • state: boolean

          Returns void

        Methods

        • _destroy(options: any): void
        • The inner _destroy method which may optionally be defined by each PlaceableObject subclass.

          Parameters

          • options: any

          Returns void

        • _draw(options: any): Promise<void>
        • _applyRenderFlags(flags: any): void
        • _addPoint(position: Point, [options]?: { round: boolean; snap: boolean; temporary: boolean }): void
        • Add a new polygon point to the drawing, ensuring it differs from the last one

          internal

          Parameters

          • position: Point

            The drawing point to add

          • [options]: { round: boolean; snap: boolean; temporary: boolean } = {}

            Options which configure how the point is added

            • round: boolean
            • snap: boolean
            • temporary: boolean

          Returns void

        • _removePoint(): void
        • Remove the last fixed point from the polygon

          internal

          Returns void

        • _onControl(options: any): void
        • Additional events which trigger once control of the object is established

          Parameters

          • options: any

            Optional parameters which apply for specific implementations

          Returns void

        • _onRelease(options: any): any
        • Additional events which trigger once control of the object is released

          Parameters

          • options: any

            Options which modify the releasing workflow

          Returns any

        • _onDelete(options: any, userId: any): void
        • enableTextEditing(options?: any): void
        • Enable text editing for this drawing.

          Parameters

          • options: any = {}

          Returns void

        • _onUpdate(data: any, options: any, userId: any): any
        • activateListeners(): void
        • _canControl(user: any, event: any): any
        • _canConfigure(user: any, event: any): boolean
        • _onDragLeftStart(event: any): any
        • _onDragLeftMove(event: any): any
        • _onDragLeftDrop(event: any): Promise<any>
        • _onDragLeftCancel(event: any): any
        • Callback actions which occur on a mouse-move operation.

          Parameters

          • event: any

            The triggering mouse click event

          Returns any

        • applyRenderFlags(): void
        • destroy(options: any): any
        • Refresh all incremental render flags for the PlaceableObject. This method is no longer used by the core software but provided for backwards compatibility.

          Parameters

          • options: any = {}

          Returns PlaceableObject

          The refreshed object

        • _updateQuadtree(): void
        • control(options?: { releaseOthers: boolean }): boolean
        • 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(options?: any): boolean
        • Release control over a PlaceableObject, removing it from the controlled set

          Parameters

          • options: any = {}

            Options which modify the releasing workflow

          Returns boolean

          A Boolean flag confirming the object was released.

        • 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

        • 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

        • _updateRotation(options?: { angle: number; delta: number; snap: number }): number
        • 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
            • delta: number
            • snap: number

          Returns number

          The new rotation angle for the object

        • _getShiftedPosition(dx: number, dy: number): { x: number; y: number }
        • Obtain a shifted position for the Placeable Object

          Parameters

          • dx: number

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

          • dy: number

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

          Returns { x: number; y: number }

          The shifted target coordinates

          • x: number
          • y: number
        • can(user: User, action: string): boolean
        • 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?

        • _getTextStyle(): TextStyle
        • Prepare the text style used to instantiate a PIXI.Text or PreciseText instance for this Drawing document.

          Returns TextStyle

        • _onMouseDraw(event: FederatedEvent): void
        • Handle mouse movement which modifies the dimensions of the drawn shape.

          Parameters

          • event: FederatedEvent

          Returns void

        • _onHandleHoverIn(event: FederatedEvent): void
        • Handle mouse-over event on a control handle

          Parameters

          • event: FederatedEvent

            The mouseover event

          Returns void

        • _onHandleHoverOut(event: FederatedEvent): void
        • Handle mouse-out event on a control handle

          Parameters

          • event: FederatedEvent

            The mouseout event

          Returns void

        • _onHandleMouseDown(event: FederatedEvent): void
        • When clicking the resize handle, initialize the drag property.

          Parameters

          • event: FederatedEvent

            The mousedown event

          Returns void

        • _onHandleDragStart(event: FederatedEvent): void
        • Starting the resize handle drag event, initialize the original data.

          Parameters

          • event: FederatedEvent

            The mouse interaction event

          Returns void

        • _onHandleDragMove(event: FederatedEvent): void
        • Handle mousemove while dragging a tile scale handler

          Parameters

          • event: FederatedEvent

            The mouse interaction event

          Returns void

        • _onHandleDragDrop(event: FederatedEvent): any
        • Handle mouseup after dragging a tile scale handler

          Parameters

          • event: FederatedEvent

            The mouseup event

          Returns any

        • _onHandleDragCancel(event: PointerEvent): void
        • Handle cancellation of a drag event for one of the resizing handles

          Parameters

          • event: PointerEvent

            The drag cancellation event

          Returns void

        • _getTargetAlpha(): number
        • Get the target opacity that should be used for a Placeable Object depending on its preview state.

          Returns number

        • _onCreate(data: any, options: any, userId: string): void
        • Register pending canvas operations which should occur after a new PlaceableObject of this type is created

          Parameters

          • data: any
          • options: any
          • userId: string

          Returns void

        • _canHUD(user: User, event: any): boolean
        • Can the User access the HUD for this Placeable Object?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canView(user: User, event: any): boolean
        • Does the User have permission to view details of the Placeable Object?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canCreate(user: User, event: any): boolean
        • Does the User have permission to create the underlying Document?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canDrag(user: User, event: any): boolean
        • Does the User have permission to drag this Placeable Object?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canHover(user: User, event: any): boolean
        • Does the User have permission to hover on this Placeable Object?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canUpdate(user: User, event: any): boolean
        • Does the User have permission to update the underlying Document?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _canDelete(user: User, event: any): boolean
        • Does the User have permission to delete the underlying Document?

          Parameters

          • user: User

            The User performing the action.

          • event: any

            The event object.

          Returns boolean

          The returned status.

        • _onHoverIn(event: FederatedEvent, options?: { hoverOutOthers: boolean }): boolean
        • Actions that should be taken for this Placeable Object when a mouseover event occurs. Hover events on PlaceableObject instances allow event propagation by default.

          see

          MouseInteractionManager##handleMouseOver

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          • options: { hoverOutOthers: boolean } = {}

            Options which customize event handling

            • hoverOutOthers: boolean

          Returns boolean

          True if the event was handled, otherwise false

        • _onHoverOut(event: FederatedEvent): boolean
        • Actions that should be taken for this Placeable Object when a mouseout event occurs

          see

          MouseInteractionManager##handleMouseOut

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          Returns boolean

          True if the event was handled, otherwise false

        • _propagateLeftClick(event: FederatedEvent): boolean
        • _onClickLeft(event: FederatedEvent): void
        • Callback actions which occur on a single left-click event to assume control of the object

          see

          MouseInteractionManager##handleClickLeft

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          Returns void

        • _onClickLeft2(event: FederatedEvent): void
        • Callback actions which occur on a double left-click event to activate

          see

          MouseInteractionManager##handleClickLeft2

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          Returns void

        • _propagateRightClick(event: FederatedEvent): boolean
        • _onClickRight(event: FederatedEvent): void
        • Callback actions which occur on a single right-click event to configure properties of the object

          see

          MouseInteractionManager##handleClickRight

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          Returns void

        • _onClickRight2(event: FederatedEvent): void
        • Callback actions which occur on a double right-click event to configure properties of the object

          see

          MouseInteractionManager##handleClickRight2

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          Returns void

        • _onDragStart(): void
        • 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

        • _onDragEnd(): void
        • 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

        • _onLongPress(event: FederatedEvent, origin: Point): any
        • Callback action which occurs on a long press.

          see

          MouseInteractionManager##handleLongPress

          Parameters

          • event: FederatedEvent

            The triggering canvas interaction event

          • origin: Point

            The local canvas coordinates of the mousepress.

          Returns any

        • #drawFrame(): Container
        • Create elements for the Drawing border and handles

          Returns Container

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

          Returns PreciseText

        • #refreshMesh(): void
        • Refresh the primary canvas object bound to this drawing.

          Returns void

        • #refreshState(): void
        • Refresh the displayed state of the Drawing. Used to update aspects of the Drawing which change based on the user interaction state.

          Returns void

        • #refreshShape(): void
        • Refresh the displayed shape of the Drawing. This refresh occurs when the underlying shape of the drawing has been modified.

          Returns void

        • #refreshFrame(): void
        • Refresh the border frame that encloses the Drawing.

          Returns void

        • #refreshText(): void
        • Refresh the appearance of text displayed above the drawing. This refresh occurs when the shape is refreshed or the position or opacity of drawing text has changed.

          Returns void

        • #onDrawingTextKeydown(event: KeyboardEvent): any
        • Handle text entry in an active text tool

          Parameters

          • event: KeyboardEvent

          Returns any

        • rescaleDimensions(original: any, dx: number, dy: number): any
        • Get a vectorized rescaling transformation for drawing data and dimensions passed in parameter

          Parameters

          • original: any

            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 any

          The adjusted shape data

        • normalizeShape(data: any): any
        • Adjust the location, dimensions, and points of the Drawing before committing the change.

          Parameters

          • data: any

            The DrawingData pending update

          Returns any

          The adjusted data