module:Container

module:Container

Container class

Constructor

# new module:Container(positionDefinitionopt, optionsopt)

Container constructor

Parameters:
Name Type Attributes Description
positionDefinition PositionDefinition <optional>

Position in its container

options ContainerOptions <optional>

Specific options

Extends

Members

# (static) defaultOptions :ContainerOptions

Type:
  • ContainerOptions

# (static) events :ContainerEvent

Type:
  • ContainerEvent

# children :Array.<Container>

Type:
  • Array.<Container>

# frameCount :Number

Type:
  • Number

# options :ContainerOptions

Type:
  • ContainerOptions

# parent :Container

Type:
  • Container

# position :Position

Type:
  • Position

Methods

# (static) from(definition) → {Container}

Return an instance from a generic object

Parameters:
Name Type Description
definition Object

Container definition

Returns:
Type
Container

# (static) setOpacity(ctx, opacity)

Define context opacity

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Drawing context

opacity Number

Opacity value

# add(…child) → {Container}

Add another container as a child

Parameters:
Name Type Attributes Description
child Container <repeatable>

Another container

Returns:

Itself

Type
Container

# climbAncestry(callback, untilopt)

Execute an action on every ancestor of this

Parameters:
Name Type Attributes Default Description
callback ancestryCallback

Function to execute on each ancestor

until Container <optional>
null

Define a ancestor where to stop the climbing

# clone() → {Container}

Create a copy of any descendant of Container

Returns:
Type
Container

# delete() → {Container}

Remove itself from its parent

Returns:

Itself

Type
Container

# empty() → {Container}

Remove all its children

Returns:

Itself

Type
Container

# fire(event) → {Container}

Bubble the event to its parent

Parameters:
Name Type Description
event BaseEvent

Event to fire

Returns:

Itself

Type
Container

# getAbsolutePosition() → {Position}

Get this container's absolute position (up to it's utmost parent)

Returns:
Type
Position

# getRoot() → {Container}

Return its highest parent

Returns:

Itself

Type
Container

# getScene() → {Promise.<Scene>}

Return a promise for the associated scene

Returns:
Type
Promise.<Scene>

# getTarget(position, ctx) → {Container}

Find the target at a position

Parameters:
Name Type Description
position Position

Any position

ctx CanvasRenderingContext2D

Drawing context to apply paths

Returns:

Itself

Type
Container

# hide() → {Container}

Hide it

Returns:

Itself

Type
Container

# isAncestorOf(container) → {Boolean}

Define if this is an ancestor of another container

Parameters:
Name Type Description
container Container

Any container

Returns:
Type
Boolean

# isHover() → {Boolean}

Container can't be hovered

Returns:
Type
Boolean

# makePath() → {Container}

Do nothing on Container, override it to add behavior

Returns:

Itself

Type
Container

# remove(…child) → {Container}

Remove a child from the list

Parameters:
Name Type Attributes Description
child Container <repeatable>

Child to remove

Returns:

Itself

Type
Container

# render(ctx) → {Container}

Call the render method of all children

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Drawing context

Returns:

Itself

Type
Container

# setContext(ctx) → {Container}

Set variables of the context according to specified options

Parameters:
Name Type Description
ctx CanvasRenderingContext2D

Drawing context

Returns:

Itself

Type
Container

# setOptions(optionsopt) → {Container}

Define options for this container

Parameters:
Name Type Attributes Default Description
options ContainerOptions <optional>
{}

Options to override

Returns:

Itself

Type
Container

# show() → {Container}

Display it

Returns:

Itself

Type
Container

# toJSON() → {Object}

Return a json ready object

Returns:
Type
Object

Type Definitions

# ancestryCallback(ancestor)

Parameters:
Name Type Description
ancestor Container

# ContainerEvent

Type:
  • Object
Properties
Name Type Description
attach String

Container is append to a new parent

detach String

Container remove from it's parent

draw String

Container is drawn

hide String
show String

# ContainerOptions

Type:
  • Object
Properties
Name Type Attributes Default Description
shown Boolean <optional>
true

Is shown

opacity Number <optional>
null

Opacity level from 0 to 1 (null mean inherited from parent)

rotation Number <optional>
0

Rotation ratio from 0 to 1 (clockwise)

rotationCenter PositionDefinition <optional>
new Position()

Center of rotation relative to this position

scale Number | PositionDefinition <optional>
1

Scaling ratio or a pair of value for horizontal and vertical scaling

zIndex Number <optional>
1

Depth ordering

clip Component <optional>
null

Other component used to clip the rendering