Kiwi.Geom.Transform Class
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]
Parameters:
-
[x=0]
Number optionalX position of the transform.
-
[y=0]
Number optionalY position of the transform.
-
[scaleX=1]
Number optionalX scaling of the transform.
-
[scaleY=1]
Number optionalY scaling of the transform.
-
[rotation=0]
Number optionalRotation of the transform in radians.
-
[rotX=0]
Number optionalrotationPoint offset on X axis.
-
[rotY=0]
Number optionalrotationPoint offset on Y axis.
Returns:
This object.
Item Index
Methods
Methods
checkAncestor
-
transform
Recursively check that a transform does not appear as its own ancestor
Parameters:
-
transform
Kiwi.Geom.TransformThe Transform to check.
Returns:
Returns true if the given transform is the same as this or an ancestor, otherwise false.
clone
-
[output]
Return a clone of this transform.
Parameters:
-
[output]
Kiwi.Geom.Transform optionalA Transform to copy the clone in to. If none is given a new Transform object will be made.
Returns:
A clone of this object.
copyFrom
-
transform
Copy another transforms data to this transform. A clone of the source matrix is created for the matrix property.
Parameters:
-
transform
Kiwi.Geom.Transformtransform. The tranform to be copied from.
Returns:
This object.
copyTo
-
destination
Copy this transforms data to the destination Transform. A clone of this transforms matrix is created in the destination Transform Matrix.
Parameters:
-
destination
Kiwi.Geom.TransformThe tranform to copy to.
Returns:
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:
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:
Parent transform matrix
getPositionPoint
-
[output]
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 optionalThe Point to output the coordinates into. Creates a new Point if none given.
Returns:
A point representing the X and Y values of the transform.
objType
()
String
public
The type of this object.
Returns:
"Transform"
setPosition
-
x
-
y
Set the X and Y values of the transform.
Parameters:
-
x
Number -
y
Number
Returns:
This object.
setPositionPoint
-
point
Set the X and Y values of the transform from a point.
Parameters:
-
point
Kiwi.Geom.Pointpoint.
Returns:
This object.
setTransform
-
[x=0]
-
[y=0]
-
[scaleX=1]
-
[scaleY=1]
-
[rotation=0]
-
[rotX=0]
-
[rotY=0]
Set the core properties of the transform.
Parameters:
-
[x=0]
Number optionalX position of the transform.
-
[y=0]
Number optionalY position of the transform.
-
[scaleX=1]
Number optionalX scaling of the transform.
-
[scaleY=1]
Number optionalY scaling of the transform.
-
[rotation=0]
Number optionalRotation of the transform in radians.
-
[rotX=0]
Number optionalrotationPoint offset on X axis.
-
[rotY=0]
Number optionalrotationPoint offset on Y axis.
Returns:
This object.
toString
()
String
public
Return a string represention of this object.
Returns:
A string represention of this object.
transformPoint
-
point
Apply this matrix to a an object with x and y properties representing a point and return the transformed point.
Parameters:
-
point
Kiwi.Geom.Point
Returns:
translatePositionFromPoint
-
point
Translate the X and Y value of the transform by point components.
Parameters:
-
point
Kiwi.Geom.Pointpoint.
Returns:
This object.
Properties
_cachedConcatenatedMatrix
Kiwi.Geom.Matrix
private
The most recently calculated matrix from getConcatenatedMatrix.
_dirty
Boolean
private
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
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
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
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
Return the anchor point value from the X axis. (Aliases to rotPointX.)
anchorPointY
Number
public
Return the anchor point value from the Y axis. (Aliases to rotPointY.)
ignoreChild
Boolean
public
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
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
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
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.