Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 678437 of DOMMatrixReadOnly

  • Revision slug: Web/API/DOMMatrixReadOnly
  • Revision title: DOMMatrixReadOnly
  • Revision id: 678437
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{APIRef}}{{SeeCompatTable}}

The DOMMatrixReadOnly interface represents 4x4 matrices, suitable for 2D and 3D operations. If this interface defines only read-only matrices, the {{domxref("DOMMatrix")}} interface which inherits from it, add all the properties and the methods to allow to have modifiable matrices.

A 4x4 matrix is suitable to describe any rotation and translation in 3D.

This interface should be available inside Web workers, though some implementations doesn't allow it yet.

Properties

This interface doesn't inherit any other property.

m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44 {{ReadonlyInline}}
Are double representing each component of a 4x4 matrix. They are read-only, but their counterpart, with the same name, in {{domxref("DOMMatrix")}} aren't.
a, b, c, d, e, f {{ReadOnlyInline}}
Are double representing each component of a 4x4 matrix needed for 2D rotations and translations. They are aliases for some components of the 4x4 matrix:
2D 3D equivalent
a m11
b m12
c m21
d m22
e m41
f m42
They are read-only, but their counterpart, with the same name, in {{domxref("DOMMatrix")}} aren't.
{{domxref("DOMMatrixReadOnly.is2D")}} {{ReadOnlyInline}}
Is a {{jsxref("Boolean")}} indicating if the matrix contains a 2D matrix and only accept 2D transformations.
{{domxref("DOMMatrixReadOnly.isIdentity")}} {{ReadOnlyInline}}
Is a {{jsxref("Boolean")}} indincating if the matrix identity, that is a matrix with 1 on the components of its diagonal, and 0 elsewhere.

Methods

This interface doesn't inherit any method.

{{domxref("DOMMatrixReadOnly.translate()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix being translated by the given vector. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.scale()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x and y dimensions being scaled by the given factor, centered on the origin given. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.scale3d()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x, y and z dimension being scaled by the given factor, centered on the origin given. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.scaleNonUniform()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x, y and z dimension being scaled by the given factor for each dimension, centered on the origin given. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.rotate()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the given angle, with the rotation centered on the origin given. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.rotateFromVector()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the angle between the given vector and (1,0), centered on the origin given. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.rotateAxisAngle()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the given angle and the give vector. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.skewX()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being skewed along the x-axis by the given factor. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.skewY()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being skewed along the y-axis by the given factor. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.multiply()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being multiply by the given {{domxref("DOMMatrix")}}. The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.flipX()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being flipped around the x-axis, that is multiplied by the DOMMatrix(-1, 0, 0, 1, 0, 0). The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.flipY()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being flipped around the y-axis, that is multiplied by the DOMMatrix(1, 0, 0, -1, 0, 0). The original matrix is not modified.
{{domxref("DOMMatrixReadOnly.invert()")}}
Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being inverted. The original matrix is not modified. If the matrix cannot be inverted, all its components are set to NaN and is2D() returns false.
{{domxref("DOMMatrixReadOnly.transformPoint()")}}
Returns a {{domxref("DOMPoint")}} that is the point given in parameter multiplied by the matrix. Bot the original point and the matrix aren't modified.
{{domxref("DOMMatrixReadOnly.toFloat32Array()")}}
Returns a {{jsxref("Float32Array")}} containing the 6 components (a, b, c, d, e, f) in the case of a 2D matrix or the 16 components (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) for a 3D matrix.
{{domxref("DOMMatrixReadOnly.toFloat64Array()")}}
Returns a {{jsxref("Float64Array")}} containing the 6 components (a, b, c, d, e, f) in the case of a 2D matrix or the 16 components (m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44) for a 3D matrix.
{{domxref("DOMMatrixReadOnly.toString()")}}
Returns a {{domxref("DOMString")}} containing the 6 components separated by a ',' and prefixed by the CSS matrix functional notation, as 'matrix (a, b, c, d, e, f)', in the case of a 2D matrix or matrix3d functional notation and the 16 components,'matrix3d(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)', for a 3D matrix.

Specifications

Specification Status Comment
{{ SpecName('Geometry Interfaces', '#dom-dommatrixreadonly', 'DOMMatrixReadOnly') }} {{ Spec2('Geometry Interfaces') }} Initial definition

Browser compatibility

{{CompatibilityTable}}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{CompatGeckoDesktop(33)}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}
Availability on Web workers {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}
Feature Firefox Mobile (Gecko) Android IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatGeckoMobile(33)}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}
Availability on Web workers {{CompatNo}} {{CompatUnknown}} {{CompatNo}} {{CompatUnknown}} {{CompatNo}}

See also

  • It's modifiable descendant, {{domxref("DOMMatrix")}}
  • {{domxref("SVGMatrix")}}, the SVG matrix intended to be superseded by {{domxref("DOMMatrix")}}
  • The CSS {{cssxref("transform-function", "matrix()", "#matrix()")}} and {{cssxref("transform-function", "matrix3d()", "#matrix3d()")}} functional notation that can be generated from this interface to be used in a CSS {{cssxref("transform")}}.

Revision Source

<p>{{APIRef}}{{SeeCompatTable}}</p>
<p>The <code><strong>DOMMatrixReadOnly</strong></code> interface represents 4x4 matrices, suitable for 2D and 3D operations. If this interface defines only read-only matrices, the {{domxref("DOMMatrix")}} interface which inherits from it, add all the properties and the methods to allow to have modifiable matrices.</p>
<p>A 4x4 matrix is suitable to describe any rotation and translation in 3D.</p>
<p>This interface should be available inside Web workers, though some implementations doesn't allow it yet.</p>
<h2 id="Properties">Properties</h2>
<p><em>This interface doesn't inherit any other property.</em></p>
<dl>
 <dt>
  <code>m11</code>, <code>m12</code>, <code>m13</code>, <code>m14</code>, <code>m21</code>, <code>m22</code>, <code>m23</code>, <code>m2<code>4</code></code>, <code><code>m31</code></code>, <code><code>m32</code></code>, <code><code>m33</code></code>, <code><code>m34</code></code>, <code><code>m41</code></code>, <code><code>m42</code></code>, <code><code>m43</code></code>, <code><code>m44</code></code> {{ReadonlyInline}}</dt>
 <dd>
  Are <code>double</code> representing each component of a 4x4 matrix. They are read-only, but their counterpart, with the same name, in {{domxref("DOMMatrix")}} aren't.</dd>
 <dt>
  <code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, <code>f</code> {{ReadOnlyInline}}</dt>
 <dd>
  Are <code>double</code> representing each component of a 4x4 matrix needed for 2D rotations and translations. They are aliases for some components of the 4x4 matrix:
  <table class="standard-table">
   <thead>
    <tr>
     <th scope="col">2D</th>
     <th scope="col">3D equivalent</th>
    </tr>
   </thead>
   <tbody>
    <tr>
     <td><code>a</code></td>
     <td><code>m11</code></td>
    </tr>
    <tr>
     <td><code>b</code></td>
     <td><code>m12</code></td>
    </tr>
    <tr>
     <td><code>c</code></td>
     <td><code>m21</code></td>
    </tr>
    <tr>
     <td><code>d</code></td>
     <td><code>m22</code></td>
    </tr>
    <tr>
     <td><code>e</code></td>
     <td><code>m41</code></td>
    </tr>
    <tr>
     <td><code>f</code></td>
     <td><code>m42</code></td>
    </tr>
   </tbody>
  </table>
  They are read-only, but their counterpart, with the same name, in {{domxref("DOMMatrix")}} aren't.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.is2D")}} {{ReadOnlyInline}}</dt>
 <dd>
  Is a {{jsxref("Boolean")}} indicating if the matrix contains a 2D matrix and only accept 2D transformations.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.isIdentity")}} {{ReadOnlyInline}}</dt>
 <dd>
  Is a {{jsxref("Boolean")}} indincating if the matrix identity, that is a matrix with <code>1</code> on the components of its diagonal, and <code>0</code> elsewhere.</dd>
</dl>
<h2 id="Methods">Methods</h2>
<p><em>This interface doesn't inherit any method.</em></p>
<dl>
 <dt>
  {{domxref("DOMMatrixReadOnly.translate()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix being translated by the given vector. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.scale()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x and y dimensions being scaled by the given factor, centered on the origin given. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.scale3d()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x, y and z dimension being scaled by the given factor, centered on the origin given. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.scaleNonUniform()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the matrix x, y and z dimension being scaled by the given factor for each dimension, centered on the origin given. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.rotate()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the given angle, with the rotation centered on the origin given. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.rotateFromVector()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the angle between the given vector and (1,0), centered on the origin given. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.rotateAxisAngle()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being rotated by the given angle and the give vector. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.skewX()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being skewed along the x-axis by the given factor. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.skewY()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being skewed along the y-axis by the given factor. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.multiply()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being multiply by the given {{domxref("DOMMatrix")}}. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.flipX()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being flipped around the x-axis, that is multiplied by the <code>DOMMatrix(-1, 0, 0, 1, 0, 0)</code>. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.flipY()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being flipped around the y-axis, that is multiplied by the <code>DOMMatrix(1, 0, 0, -1, 0, 0)</code>. The original matrix is not modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.invert()")}}</dt>
 <dd>
  Returns a {{domxref("DOMMatrix")}} containing a new matrix being the result of the original matrix being inverted. The original matrix is not modified. If the matrix cannot be inverted, all its components are set to <code>NaN</code> and <code>is2D()</code> returns <code>false</code>.</dd>
</dl>
<dl>
 <dt>
  {{domxref("DOMMatrixReadOnly.transformPoint()")}}</dt>
 <dd>
  Returns a {{domxref("DOMPoint")}} that is the point given in parameter multiplied by the matrix. Bot the original point and the matrix aren't modified.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.toFloat32Array()")}}</dt>
 <dd>
  Returns a {{jsxref("Float32Array")}} containing the 6 components (<code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, <code>f</code>) in the case of a 2D matrix or the 16 components (<code>m11</code>, <code>m12</code>, <code>m13</code>, <code>m14</code>, <code>m21</code>, <code>m22</code>, <code>m23</code>, <code>m24</code>, <code>m31</code>, <code>m32</code>, <code>m33</code>, <code>m34</code>, <code>m41</code>, <code>m42</code>, <code>m43</code>, <code>m44</code>) for a 3D matrix.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.toFloat64Array()")}}</dt>
 <dd>
  Returns a {{jsxref("Float64Array")}} containing the 6 components (<code>a</code>, <code>b</code>, <code>c</code>, <code>d</code>, <code>e</code>, <code>f</code>) in the case of a 2D matrix or the 16 components (<code>m11</code>, <code>m12</code>, <code>m13</code>, <code>m14</code>, <code>m21</code>, <code>m22</code>, <code>m23</code>, <code>m24</code>, <code>m31</code>, <code>m32</code>, <code>m33</code>, <code>m34</code>, <code>m41</code>, <code>m42</code>, <code>m43</code>, <code>m44</code>) for a 3D matrix.</dd>
 <dt>
  {{domxref("DOMMatrixReadOnly.toString()")}}</dt>
 <dd>
  Returns a {{domxref("DOMString")}} containing the 6 components separated by a <code>','</code> and prefixed by the CSS matrix functional notation, as <code>'matrix (a, b, c, d, e, f)',</code> in the case of a 2D matrix or matrix3d functional notation and the 16 components,<code>'matrix3d(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44)'</code>, for a 3D matrix.</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{ SpecName('Geometry Interfaces', '#dom-dommatrixreadonly', 'DOMMatrixReadOnly') }}</td>
   <td>{{ Spec2('Geometry Interfaces') }}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Firefox (Gecko)</th>
    <th>Chrome</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{CompatGeckoDesktop(33)}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
   </tr>
   <tr>
    <td>Availability on Web workers</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>Android</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{CompatGeckoMobile(33)}}</td>
    <td rowspan="1">{{CompatUnknown}}</td>
    <td rowspan="1">{{CompatNo}}</td>
    <td rowspan="1">{{CompatUnknown}}</td>
    <td rowspan="1">{{CompatNo}}</td>
   </tr>
   <tr>
    <td>Availability on Web workers</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
    <td>{{CompatUnknown}}</td>
    <td>{{CompatNo}}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
 <li>It's modifiable descendant, {{domxref("DOMMatrix")}}</li>
 <li>{{domxref("SVGMatrix")}}, the SVG matrix intended to be superseded by {{domxref("DOMMatrix")}}</li>
 <li>The CSS {{cssxref("transform-function", "matrix()", "#matrix()")}} and {{cssxref("transform-function", "matrix3d()", "#matrix3d()")}} functional notation that can be generated from this interface to be used in a CSS {{cssxref("transform")}}.</li>
</ul>
<p><span id="cke_bm_73C" style="display: none;">&nbsp;</span></p>
Revert to this revision