API Docs for: 1.4.0
Show:

Kiwi.Geom.Transform Class

Module: Geom
Parent Module: Kiwi

Represents position, scale, rotation and rotationPoint of an Entity.

  • Values can be transformed with a 3x3 affine transformation matrix, which each transform is assigned.
  • A tranform can be assigned a parent, which may in turn have it's own parent, thereby creating a tranform inheritence heirarchy
  • A concatenated transformation matrix, representing the combined matrices of the transform and its ancestors.

Constructor

Kiwi.Geom.Transform

(
  • [x=0]
  • [y=0]
  • [scaleX=1]
  • [scaleY=1]
  • [rotation=0]
  • [rotX=0]
  • [rotY=0]
)
Transform

Parameters:

  • [x=0] Number optional

    X position of the transform.

  • [y=0] Number optional

    Y position of the transform.

  • [scaleX=1] Number optional

    X scaling of the transform.

  • [scaleY=1] Number optional

    Y scaling of the transform.

  • [rotation=0] Number optional

    Rotation of the transform in radians.

  • [rotX=0] Number optional

    rotationPoint offset on X axis.

  • [rotY=0] Number optional

    rotationPoint offset on Y axis.

Returns:

Transform:

This object.

Methods

checkAncestor

(
  • transform
)
Boolean public

Recursively check that a transform does not appear as its own ancestor

Parameters:

Returns:

Boolean:

Returns true if the given transform is the same as this or an ancestor, otherwise false.

clone

(
  • [output]
)
Kiwi.Geom.Transform public

Return a clone of this transform.

Parameters:

  • [output] Kiwi.Geom.Transform optional

    A Transform to copy the clone in to. If none is given a new Transform object will be made.

Returns:

Kiwi.Geom.Transform:

A clone of this object.

copyFrom

(
  • transform
)
Kiwi.Geom.Transform public

Copy another transforms data to this transform. A clone of the source matrix is created for the matrix property.

Parameters:

Returns:

Kiwi.Geom.Transform:

This object.

copyTo

(
  • destination
)
Kiwi.Geom.Transform public

Copy this transforms data to the destination Transform. A clone of this transforms matrix is created in the destination Transform Matrix.

Parameters:

Returns:

Kiwi.Geom.Transform:

This object.

getConcatenatedMatrix

() Kiwi.Geom.Matrix public

Return the transformation matrix that concatenates this transform with all ancestor transforms. If there is no parent then this will return a matrix the same as this transform's matrix.

Returns:

Kiwi.Geom.Matrix:

The concatenated matrix.

getParentMatrix

() Kiwi.Geom.Matrix public

Return the parent matrix of the transform. If there is no parent then null is returned.

Returns:

Kiwi.Geom.Matrix:

Parent transform matrix

getPositionPoint

(
  • [output]
)
Kiwi.Geom.Point public

Return a Point representing the X and Y values of the transform. If no point is given a new Point objected will be created.

Parameters:

  • [output] Kiwi.Geom.Point optional

    The Point to output the coordinates into. Creates a new Point if none given.

Returns:

Kiwi.Geom.Point:

A point representing the X and Y values of the transform.

objType

() String public

The type of this object.

Returns:

String:

"Transform"

setPosition

(
  • x
  • y
)
Kiwi.Geom.Transform public

Set the X and Y values of the transform.

Parameters:

  • x Number
  • y Number

Returns:

Kiwi.Geom.Transform:

This object.

setPositionPoint

(
  • point
)
Kiwi.Geom.Transform public

Set the X and Y values of the transform from a point.

Parameters:

Returns:

Kiwi.Geom.Transform:

This object.

setTransform

(
  • [x=0]
  • [y=0]
  • [scaleX=1]
  • [scaleY=1]
  • [rotation=0]
  • [rotX=0]
  • [rotY=0]
)
Kiwi.Geom.Transform public

Set the core properties of the transform.

Parameters:

  • [x=0] Number optional

    X position of the transform.

  • [y=0] Number optional

    Y position of the transform.

  • [scaleX=1] Number optional

    X scaling of the transform.

  • [scaleY=1] Number optional

    Y scaling of the transform.

  • [rotation=0] Number optional

    Rotation of the transform in radians.

  • [rotX=0] Number optional

    rotationPoint offset on X axis.

  • [rotY=0] Number optional

    rotationPoint offset on Y axis.

Returns:

Kiwi.Geom.Transform:

This object.

toString

() String public

Return a string represention of this object.

Returns:

String:

A string represention of this object.

transformPoint

(
  • point
)
Kiwi.Geom.Point public

Apply this matrix to a an object with x and y properties representing a point and return the transformed point.

Parameters:

Returns:

translatePositionFromPoint

(
  • point
)
Kiwi.Geom.Transform public

Translate the X and Y value of the transform by point components.

Parameters:

Returns:

Kiwi.Geom.Transform:

This object.

Properties

_cachedConcatenatedMatrix

Kiwi.Geom.Matrix private

The most recently calculated matrix from getConcatenatedMatrix.

_dirty

Boolean private

Defined in src\geom\Transform.ts:450

Available since 1.3.1

Whether the transform has been altered since the last time it was used to create a matrix. Used to determine whether to rebuild the matrix or not.

Default: true

_ignoreChild

Boolean private

Defined in src\geom\Transform.ts:410

Available since 1.3.1

Private copy. Whether to prevent children from acquiring this as a parent when concatenating matrices. This can save computation, but prevents it from passing any transform data to children.

Use this to save some processor cycles if this is a Group that does not control its children, and the state does not transform.

Default: false

_ignoreParent

Boolean private

Defined in src\geom\Transform.ts:371

Available since 1.2.0

Private copy. Whether to ignore its parent when concatenating matrices. If true, it won't compute parent matrices. This can save computation, but prevents it from following its parent's transforms. Use this to save some processor cycles if the transform isn't following a parent and the state does not transform.

Default: false

_locked

Boolean private

Defined in src\geom\Transform.ts:331

Available since 1.2.0

Private copy. Whether the Transform is locked. In locked mode, the Transform will not update its matrix, saving on computation. However, it will still follow its parent.

Default: false

_matrix

Kiwi.Geom.Matrix private

A 3x3 transformation matrix object that can be use this tranform to manipulate points or the context transformation.

_parent

Kiwi.Geom.Transform private

The parent transform. If set to null there is no parent. Otherwise this is used by getConcatenatedMatrix to offset the current transforms by the another matrix

Default: null

_rotation

Number private

Rotation of the transform in radians.

Default: 0

_rotPointX

Number private

Rotation offset on X axis.

Default: 0

_rotPointY

Number private

Rotation offset on Y axis.

Default: 0

_scaleX

Number private

X scaleof the transform

Default: 1

_scaleY

Number private

Y scale of the transform

Default: 1

_x

Number private

X position of the transform

Default: 0

_y

Number private

Y position of the transform

Default: 0

anchorPointX

Number public

Defined in src\geom\Transform.ts:218

Available since 1.1.0

Return the anchor point value from the X axis. (Aliases to rotPointX.)

anchorPointY

Number public

Defined in src\geom\Transform.ts:232

Available since 1.1.0

Return the anchor point value from the Y axis. (Aliases to rotPointY.)

ignoreChild

Boolean public

Defined in src\geom\Transform.ts:428

Available since 1.3.1

Whether to prevent children from acquiring this as a parent when concatenating matrices. This can save computation, but prevents it from passing any transform data to children.

Use this to save some processor cycles if this is a Group that does not control its children, and the state does not transform.

Default: false

ignoreParent

Boolean public

Defined in src\geom\Transform.ts:387

Available since 1.2.0

Whether to ignore its parent when concatenating matrices. If true, it won't compute parent matrices. This can save computation, but prevents it from following its parent's transforms.

Use this to save some processor cycles if the transform isn't following a parent and the state does not transform.

Default: false

locked

Boolean public

Defined in src\geom\Transform.ts:344

Available since 1.2.0

Whether the Transform is locked. In locked mode, the Transform will not update its matrix, saving on computation. However, it will still follow its parent. When locked is set to true, it will set the matrix according to current transform values.

Default: false

matrix

Kiwi.Geom.Matrix public

Return the Matrix being used by this Transform

parent

Kiwi.Geom.Transform public

Return the parent Transform. If the transform does not have a parent this null is returned.

Default: null

rotation

Number public

Return the rotation value of the transform in radians.

rotPointX

Number public

Return the rotation offset from the x axis.

Default: 0

rotPointY

Number public

Return the rotation offset from the y axis.

scale

Number public

Set the X and Y scale value of the transform. This property is set only. In the future this will be looked into and updated as needed.

scaleX

Number public

Return the X scale value of the transform.

scaleY

Number public

Return the Y scale value of the transform.

worldX

Number public

Return the x of this transform translated to world space.

worldY

Number public

Return the y of this transform translated to world space.

x

Number public

Return the X value of the transform.

y

Number public

Return the Y value of the transform.