What is Incisor?
Tutorials
Key Concepts
Reddit
Stack Overflow
Configuration Settings
Deprecation Schedule

Masking()

Object controlling the masking of a GraphicObject. Masking functionality enables selective rendering of portions of GraphicObjects. MaskGroups can be defined, and then GraphicObjects can be configured as 'mask', which add their shape to the area of the newly defined MaskGroup. Then, when other GraphicObjects are configured as 'masked', their rendering only occures within areas defined by the MaskGroup.

new Masking()

MEMBERS

enabled :boolean

Flag determining if masking functionality is enabled (for both 'mask' and 'masked').

Default Value:
  • false

inheritedTypes :object

Dictionary of type that this object inherits from.

invert :boolean

Boolean determining if the affect of masking on a 'masked' GraphicObject is inverted, meaning that the areas where it is masked and the areas where it is not masked are switched. When this value is false, the masked GraphicObject in question is only rendered in areas that 'mask' GraphicObjects also occupy. When this value is true, the masked GraphicObject in question is only rendered in areas that 'mask' GraphicObjects do not occupy. This setting only applies to GraphicObjects with the 'masked' type, 'mask' GraphicObjects are unaffected by this setting. This setting does nothing when 'GraphicObject.masking.enabled' is false.

Default Value:
  • false

type :string

String property that determines if this GraphicObject is a 'mask' or 'masked'. When masking functionality is enabled, a 'mask' contributes to the MaskGroup(s) it is associated with. When a GraphicObject is 'masked' it is only rendered in the areas determined by the MaskGroup(s) it is associated with. This setting does nothing when 'GraphicObject.masking.enabled' is false;

Default Value:
  • "masked"

METHODS

getMaskGroups() returns {Array.<MaskGroup>}

Gets the list of MaskGroups that this GraphicObject is associated with.

Returns:
Array.<MaskGroup>

makeMask(maskGroups)

Causes this GraphicObject to contribute to the given MaskGroup(s), adding its fully filled Geometry to the MaskGroups' areas.

Parameters:
Name Type Attributes Default Description
maskGroups MaskGroup | Array.<MaskGroup>    

The MaskGroup(s) that this GraphicObject's shape will be added to. For a list of available MaskGroups, see 'nc.maskGroups'.

Example:
// Objective: Use a mask to reveal only a portion of the phrase "Hello World."
// Expected Result: You will see the word "World." on screen.

// create a TextBox
let textBox = nc.addTextBox( nc.mainScene );
textBox.string = "Hello World."
textBox.makeMasked( nc.maskGroups.MainMaskGroup ); // mask it with "MainMaskGroup"

// create a GraphicObject rectangle and position it to cover the word "World."
this.masker = new GraphicObject( nc.graphicAssets.WhiteBox, nc.mainScene, "Masker" );
this.masker.scale.x = 2; // rectangle
this.masker.position.x = 75; // position
this.masker.makeMask( nc.maskGroups.MainMaskGroup ); // make it a masker for "MainMaskGroup"

makeMasked(maskGroups, invert (opt))

Causes this GraphicObject to only be rendered in the areas defined by the given MaskGroup(s).

Parameters:
Name Type Attributes Default Description
maskGroups MaskGroup | Array.<MaskGroup>  

The MaskGroup(s) that the rendering of this GraphicObject will be limited to. For a list of available MaskGroups, see 'nc.maskGroups'.

invert boolean <optional>
 

Inverts the effect of the masking, swapping the areas where this GraphicObject will and won't be rendered. [DEFAULT: false]

Example:
// Objective: Use a mask to reveal only a portion of the phrase "Hello World."
// Expected Result: You will see the word "World." on screen.

// create a TextBox
let textBox = nc.addTextBox( nc.mainScene );
textBox.string = "Hello World."
textBox.makeMasked( nc.maskGroups.MainMaskGroup ); // mask it with "MainMaskGroup"

// create a GraphicObject rectangle and position it to cover the word "World."
this.masker = new GraphicObject( nc.graphicAssets.WhiteBox, nc.mainScene, "Masker" );
this.masker.scale.x = 2; // rectangle
this.masker.position.x = 75; // position
this.masker.makeMask( nc.maskGroups.MainMaskGroup ); // make it a masker for "MainMaskGroup"

setMaskGroups(maskGroups)

Sets the MaskGroup or list of MaskGroups that this GraphicObject is associated with.

Parameters:
Name Type Attributes Default Description
maskGroups MaskGroup | Array.<MaskGroup>