A Mask describes a geometric shape to show only a portion of a DisplayObject. Pixels inside of the shape are visible and pixels outside of the shape are invisible.

The mask is placed relative to the DisplayObject where it is applied to. However, you can set the relativeToParent property to true to placed the mask relativ to the DisplayObjects parent.

Example:

var rifleScope = new Sprite();
rifleScope.mask = new Mask.circle(0, 0, 50);
rifleScope.addChild(world);
Implements
  • RenderMask

Constructors

Mask()

Mask.circle(num x, num y, num radius)

Create a circular mask.

factory
Mask.custom(List<Point<num>> points)

Create a custom mask with a polygonal shape defined by points.

factory
Mask.graphics(Graphics graphics)

Create a custom mask defined by a Graphics object.

factory
Mask.rectangle(num x, num y, num width, num height)

Create a rectangular mask.

factory
Mask.shape(Shape shape)

Create a custom mask defined by a Shape object.

factory

Properties

border → bool

read / write
borderColor → int

read / write
borderWidth → int

read / write
hashCode → int

Get a hash code for this object.

read-only, inherited
relativeToParent → bool

Set to true to place the Mask relative to the DisplayObjects parent. The default value is false and therefore the mask is placed relative to the DisplayObject where it is applied to.

read / write
runtimeType → Type

A representation of the runtime type of the object.

read-only, inherited
transformationMatrix Matrix

You can use the transformationMatrix to change the size, position, scale, rotation etc. from the Mask.

read-only

Operators

operator ==(other) → bool

The equality operator.

inherited

Methods

hitTest(num x, num y) → bool

noSuchMethod(Invocation invocation) → dynamic

Invoked when a non-existent method or property is accessed.

inherited
renderMask(RenderState renderState) → void

toString() → String

Returns a string representation of this object.

inherited