Skip to content

Titanium.UI.Matrix3D

The 3D Matrix is an object for holding values for a 3D affine transform.

The 3D Matrix is created by Titanium.UI.createMatrix3D. A 3D transform is used to rotate, scale, translate, or skew the objects in three-dimensional space. A 3D transform is represented by a 4 by 4 matrix.

You create an identity matrix by creating a 3D Matrix with an empty constructor.

Extends: Titanium.Proxy · Since: 8.0.0 · Platforms: iphone, ipad, macos

Properties #

apiName#

extended

Type: String

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button
returns Ti.UI.Button.

bubbleParent#

extended

Type: Boolean

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often
established by the add() method. For example, for a button added to a window, a
click event on the button would bubble up to the window. Other common parents are
table sections to their rows, table views to their sections, and scrollable views
to their views. Set this property to false to disable the bubbling to the proxy's parent.

lifecycleContainer#

extended

Type: Titanium.UI.Window, Titanium.UI.TabGroup

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks
will also be called on the proxy. Proxies that require the activity lifecycle will need this property set
to the appropriate containing Window or TabGroup.

m11#

Type: Number

The entry at position [1,1] in the matrix.

m12#

Type: Number

The entry at position [1,2] in the matrix.

m13#

Type: Number

The entry at position [1,3] in the matrix.

m14#

Type: Number

The entry at position [1,4] in the matrix.

m21#

Type: Number

The entry at position [2,1] in the matrix.

m22#

Type: Number

The entry at position [2,2] in the matrix.

m23#

Type: Number

The entry at position [2,3] in the matrix.

m24#

Type: Number

The entry at position [2,4] in the matrix.

m31#

Type: Number

The entry at position [3,1] in the matrix.

m32#

Type: Number

The entry at position [3,2] in the matrix.

m33#

Type: Number

The entry at position [3,3] in the matrix.

m34#

Type: Number

The entry at position [3,4] in the matrix.

m41#

Type: Number

The entry at position [4,1] in the matrix.

m42#

Type: Number

The entry at position [4,2] in the matrix.

m43#

Type: Number

The entry at position [4,3] in the matrix.

m44#

Type: Number

The entry at position [4,4] in the matrix.

Methods #

addEventListener #

extended

Adds the specified callback as an event listener for the named event.

Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
callbackCallback<Titanium.Event>Callback function to invoke when the event is fired.No

applyProperties #

extended

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that
myproxy[key] = value.

Parameters:
NameTypeSummaryOptional
propsDictionaryA dictionary of properties to apply.No

fireEvent #

extended

Fires a synthesized event to any registered listeners.

Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
eventDictionaryA dictionary of keys and values to add to the Titanium.Event object sent to the listeners.Yes

invert #

Returns a matrix constructed by inverting this matrix.

Returns: Titanium.UI.Matrix3D

multiply #

Returns a matrix constructed by combining two existing matrix.

The result of this function is the first matrix multiplied by the second matrix. You might perform
several multiplications in order to create a single matrix that contains the cumulative effects of
several transformations. Note that matrix operations are not commutative - the order in which
you concatenate matrices is important. That is, the result of multiplying matrix t1 by matrix t2
does not necessarily equal the result of multiplying matrix t2 by matrix t1.

Parameters:
NameTypeSummaryOptional
t2Titanium.UI.Matrix3DMatrix to concatenate to this matrix.No

Returns: Titanium.UI.Matrix3D

removeEventListener #

extended

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the
callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function
in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);
Parameters:
NameTypeSummaryOptional
nameStringName of the event.No
callbackCallback<Titanium.Event>Callback function to remove. Must be the same function passed to addEventListener.No

rotate #

Returns a matrix constructed by rotating this matrix.

Parameters:
NameTypeSummaryOptional
angleNumberThe angle, in degrees, by which to rotate the matrix. A positive value specifies counterclockwise rotation and a negative value specifies clockwise rotation.No
xNumberThe x part of the vector about which to rotate.No
yNumberThe y part of the vector about which to rotate.No
zNumberThe z part of the vector about which to rotate.No

Returns: Titanium.UI.Matrix3D

scale #

Returns a matrix constructed by scaling this matrix.

Parameters:
NameTypeSummaryOptional
sxNumberThe value by which to scale x values of the matrix.No
syNumberThe value by which to scale y values of the matrix.No
szNumberThe value by which to scale z values of the matrix.No

Returns: Titanium.UI.Matrix3D

translate #

Returns a matrix constructed by translating an existing matrix.

Parameters:
NameTypeSummaryOptional
txNumberThe value by which to move x values with the matrix.No
tyNumberThe value by which to move y values with the matrix.No
tzNumberThe value by which to move z values with the matrix.No

Returns: Titanium.UI.Matrix3D

Examples #

Apply a 3D Matrix to a Label

Move a label through a translation that repositions it from 100px to 200px from the top of the display.

var win = Ti.UI.createWindow();

var label = Ti.UI.createLabel({
  font: { fontSize : 50 },
  text: 'Titanium',
  textAlign: 'center',
  top: 100
});
win.add(label);

var button = Ti.UI.createButton({
  title: 'Animate',
  bottom: 20,
  width: 200,
  height: 40
});
win.add(button);

button.addEventListener('click', function() {
  var t1 = Ti.UI.createMatrix3D();
  t1 = t1.translate(0, 100, 200);
  t1.m34 = 1.0 / -90.0;
  var a1 = Ti.UI.createAnimation();
  a1.transform = t1;
  a1.duration = 800;
  label.animate(a1);
});
win.open();

Titanium SDK Documentation