Search this manual

WorldInstance script interface

The IWorldInstance script interface represents a single instance of an object type (represented by IObjectClass) that appears in a layout. It derives from the IInstance script interface.

Many objects return a more specific class deriving from IInstance or IWorldInstance to add APIs specific to the plugin. See the Plugin interfaces reference for more information.

WorldInstance APIs

layout

An ILayout interface representing the layout the instance is on.

layer

An ILayer interface representing the layer the instance is on.

x

y

The position of this instance, in layout co-ordinates.

zElevation

The Z elevation of the instance, relative to the layer it is on.

totalZElevation

A read-only value indicating the Z elevation of the instance including its layer's Z elevation.

width

height

The size of this instance, in layout co-ordinates.

angle

The angle of the instance in radians. If this is changed, angleDegrees updates accordingly.

angleDegrees

The angle of the instance in degrees. If this is changed, angle updates accordingly.

getBoundingBox()

Return a DOMRect representing the axis-aligned bounding box of the instance in layout co-ordinates.

getBoundingQuad()

Return a DOMQuad representing the bounding quad of the instance in layout co-ordinates. This is always a rectangle, but unlike the bounding box can represent rotation.

isVisible

A boolean indicating whether the instance is visible in the layout.

opacity

The opacity of the instance, as a floating point number in the range [0, 1], where 0 is fully transparent and 1 is fully opaque.

colorRgb

An array with 3 elements specifying the red, green and blue color filter of the instance, with color values as floats in the 0-1 range.

blendMode

A string indicating the current blend mode of the instance, controlling how it draws over the background. This must be one of "normal", "additive", "copy", "destination-over", "source-in", "destination-in", "source-out", "destination-out", "source-atop", "destination-atop".

effects

An array of IEffectInstance representing the effect parameters for each effect on the instance.

moveToTop()

moveToBottom()

Move the instance to the top or the bottom of its current layer in the Z order.

moveToLayer(layer)

Move the instance to the top of a different layer given by its ILayer.

moveAdjacentToInstance(other, isAfter)

Move the instance adjacent to other (another IWorldInstance) in the Z order. If necessary this also moves the instance to the same layer as other. If isAfter is true, it moves it just above the given instance, else just below.

containsPoint(x, y)

Test if a point intersects this instance, using its collision polygon if any, and return a boolean indicating if the point is inside the instance's collision area.

testOverlap(wi)

Test if this instance overlaps another world instance given by an IWorldInstance, returning true if they overlap, else false. This uses the object's collision polygons if any. If either instance has collisions disabled, this will always return false.

testOverlapSolid()

Test if this instance overlaps any instance with the Solid behavior. This returns the instance interface class for the first instance with the solid behavior that was found to overlap this instance, or null if none. This uses the object's collision polygons if any and respects solid collision filtering.

Construct 3 Manual 2020-04-27

On this page