Drawing

Drawing

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

Constructor

new Drawing()

Source:
Example
Drawing.create({
  type: CONST.DRAWING_TYPES.RECTANGLE,
  author: game.user._id,
  x: 1000,
  y: 1000,
  width: 800,
  height: 600,
  fillType: CONST.DRAWING_FILL_TYPES.SOLID,
  fillColor: "#0000FF",
  fillAlpha: 0.5,
  strokeWidth: 4,
  strokeColor: "#FF0000",
  strokeAlpha: 0.75,
  texture: "ui/parchment.jpg",
  textureAlpha: 0.5,
  text: "HELLO DRAWINGS!",
  fontSize: 48,
  textColor: "#00FF00",
  points: []
});

Extends

Members

(static) layer :PlaceablesLayer

Source:

Provide a reference to the canvas layer which contains placeable objects of this type

Type:

author :User

Source:

A reference to the User who created the Drawing object

Type:

center

Source:
Overrides:

The central coordinate pair of a Tile

controlIcon :ControlIcon

Source:
Overrides:

A control icon for interacting with the object

Type:

coords :Array

Source:
Overrides:

The [x,y] coordinates of the placeable object within the Scene container

Type:

data :Object

Source:
Overrides:

The underlying data object which provides the basis for this placeable object

Type:
  • Object

drawing :PIXI.Container

Source:

The inner drawing container

Type:
  • PIXI.Container

fov :PIXI.Polygon

Source:
Overrides:

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:
  • PIXI.Polygon

frame :PIXI.Container

Source:

The Graphics outer frame and handles

Type:
  • PIXI.Container

id :string

Source:
Overrides:

The EmbeddedDocument id of the underlying data object

Type:
  • string

isPolygon

Source:

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

isTiled :Boolean

Source:

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

Type:
  • Boolean

layer :PlaceablesLayer

Source:
Overrides:

Return a reference to the singleton layer instance which contains placeables of this type

Type:

owner :Boolean

Source:
Overrides:

A Boolean flag for whether the current game User has permission to control this token

Type:
  • Boolean

scene :Scene

Source:
Overrides:

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

Type:

shape :PIXI.Graphics

Source:

The primary drawing shape

Type:
  • PIXI.Graphics

sheet :DrawingConfig

Source:
Overrides:

Provide a reference to the DrawingConfig sheet used to configure this Drawing instance

Type:

text :PIXI.Text

Source:

Text content, if included

Type:
  • PIXI.Text

uuid :string

Source:
Overrides:

A Universally Unique Identifier (uuid) for this Embedded Entity instance

Type:
  • string

Methods

(async, static) create()

Source:

_onUpdate()

Source:
Overrides:
  • PlaceableObject#_onUpdate

clear()

Source:
Overrides:

Clear the display of the existing object

clone() → {PlaceableObject}

Source:
Overrides:

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:

A new object with identical data

Type
PlaceableObject

control(releaseOthers) → {Boolean}

Source:
Overrides:

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

Parameters:
Name Type Description
releaseOthers Boolean

Release any other controlled objects first

Returns:

A Boolean flag denoting whether or not control was successful.

Type
Boolean

(async) delete()

Source:
Overrides:

displayToFront()

Source:
Overrides:

Shift the display of the PlaceableObject to the top of the rendering stack, above all other siblings

(async) draw() → {Promise}

Source:
Overrides:

Draw the elements of the Drawing instance

Returns:
Type
Promise

getFlag(scope, key) → {*}

Source:
Overrides:

Get the value of a "flag" for this PlaceableObject See the setFlag method for more details on flags

Parameters:
Name Type Description
scope String

The flag scope which namespaces the key

key String

The flag key

Returns:

The flag value

Type
*

refresh()

Source:
Overrides:

Repaint the drawing, updating in real time the shape, texture, text and more

release() → {Boolean}

Source:
Overrides:

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

Returns:

A Boolean flag confirming the object was released.

Type
Boolean

(async) rotate(angle, snap) → {Promise}

Source:
Overrides:

Rotate the PlaceableObject to a certain angle of facing

Parameters:
Name Type Description
angle number

The desired angle of rotation

snap number

Snap the angle of rotation to a certain target degree increment

Returns:

A Promise which resolves once the rotation has completed

Type
Promise

(async) setFlag(scope, key, value) → {Promise}

Source:
Overrides:

Assign a "flag" to this Entity. Flags represent key-value type data which can be used to store flexible or arbitrary data required by either the core software, game systems, or user-created modules.

Each flag should be set using a scope which provides a namespace for the flag to help prevent collisions.

Flags set by the core software use the "core" scope. Flags set by game systems or modules should use the canonical name attribute for the module Flags set by an individual world should "world" as the scope.

Flag values can assume almost any data type. Setting a flag value to null will delete that flag.

Parameters:
Name Type Description
scope String

The flag scope which namespaces the key

key String

The flag key

value *

The flag value

Returns:

A Promise resolving to the updated PlaceableObject

Type
Promise

sortToBack()

Source:
Overrides:

Sort the PlaceableObject to the back of the rendering stack, behind all other siblings. Update the database with the new minimal Z-index

sortToFront()

Source:
Overrides:

Sort the PlaceableObject to the front of the rendering stack, above all other siblings. Update the database with the new maximal Z-index

(async) unsetFlag(scope, key) → {Promise}

Source:
Overrides:

Remove a flag assigned to the Entity

Parameters:
Name Type Description
scope string

The flag scope which namespaces the key

key string

The flag key

Returns:

A Promise resolving to the updated Entity

Type
Promise

(async) update()

Source:
Overrides: