API Docs for: 1.0.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
  • y
  • scaleX
  • scaleY
  • rotation
  • rotX
  • rotY
)
Transform

Parameters:

  • x Number

    x. X position of the transform.

  • y Number

    y. Y position of the transform.

  • scaleX Number

    scaleX. X scaling of the transform.

  • scaleY Number

    scaleY. Y scaling of the transform.

  • rotation Number

    rotation. Rotation of the transform in radians.

  • rotX Number

    rotX. rotationPoint offset on X axis.

  • rotY Number

    rotY. 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

    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.

getCameraY

(
  • camera
  • camera
)
Number

Return the x of this transform translated to a camera space

Parameters:

  • camera Object

    the camera

  • camera Object

    the camera

Returns:

Number:

y coordinate in the camera space

    public getCameraY ( camera:Camera ):number
    {
        var mat = this.getConcatenatedMatrix();
        mat.prependMatrix(camera.transform.getConcatenatedMatrix());
          return mat.ty;
   }

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 transforms 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:

The parent transform matrix.

getPostionPoint

() Kiwi.Geom.Point public

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

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:

scale

(
  • value
)
Kiwi.Geom.Transform public

Set the X and Y scale value of the transform.

Parameters:

  • value Number

Returns:

Kiwi.Geom.Transform:

This object.

setPosition

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

Set the X and Y values of the transform.

Parameters:

  • x Number

    x.

  • y Number

    y.

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
  • y
  • scaleX
  • scaleY
  • rotation
  • rotX
  • rotY
)
Kiwi.Geom.Transform public

Set the core properties of the transform

Parameters:

  • x Number

    x. X position of the transform.

  • y Number

    y. Y position of the transform.

  • scaleX Number

    scaleX. X scaling of the transform.

  • scaleY Number

    scaleY. Y scaling of the transform.

  • rotation Number

    rotation. Rotation of the transform in radians.

  • rotX Number

    rotX. Rotation offset on X axis.

  • rotY Number

    rotY. Rotation 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

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.

_matrix

Object protected

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

_rotation

Number private

Rotation of the transform in radians.

_rotPointX

Number private

Rotation offset on X axis.

_rotY

Number private

Rotation offset on Y axis.

_scaleX

Number private

X scaleof the transform

_scaleY

Number private

Y scale of the transform

_x

Number private

X position of the transform

_y

Number private

Y position of the transform

matrix

Unknown

Return the Matrix being used by this Transform

parent

Unknown public

Return the parent Transform, if any.

rotation

Unknown public

Return the rotation value of the transform in radians.

rotPointX

Unknown public

Return the Rotation value from the x axis.

scaleX

Number public

Return the X scale value of the transform.

scaleY

Number public

Return the Y scale value of the transform.

worldX

Unknown public

Return the x of this transform translated to world space.

worldY

Unknown public

Return the y of this transform translated to world space.

x

Number

Return the X value of the transform.

y

Number public

Return the Y value of the transform.