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 742685 of DOMMatrix

  • Revision slug: Web/API/DOMMatrix
  • Revision title: DOMMatrix
  • Revision id: 742685
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment Typo

Revision Content

{{APIRef("Geometry Interfaces")}}{{SeeCompatTable}}

The DOMMatrix interface represents 4x4 matrices, suitable for 2D and 3D operations.

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

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

Properties

This interface inherits properties from {{domxref("DOMMatrixReadOnly")}}, though some are modified not to be read-only.

m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44
Are double representing each component of a 4x4 matrix.
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

Methods

This interface inherits methods from {{domxref("DOMMatrixReadOnly")}}.

{{domxref("DOMMatrixReadOnly.multiplySelf()")}}
Returns itself, a {{domxref("DOMMatrix")}},  with its new content being the result of the original matrix being multiplied by the given {{domxref("DOMMatrix")}}.
{{domxref("DOMMatrixReadOnly.preMultiplySelf()")}}
Returns itself, a {{domxref("DOMMatrix")}},  with its new content being the result of the given {{domxref("DOMMatrix")}} being multiplied by the original matrix.
{{domxref("DOMMatrix.translateSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix being translated by the given vector.
{{domxref("DOMMatrix.scaleSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix x and y dimensions being scaled by the given factor, centered on the origin given.
{{domxref("DOMMatrix.scale3dSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix x, y and z dimension being scaled by the given factor, centered on the origin given.
{{domxref("DOMMatrix.scaleNonUniformSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content 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.
{{domxref("DOMMatrix.rotateSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the given angle, with the rotation centered on the origin given.
{{domxref("DOMMatrix.rotateFromVectorSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the angle between the given vector and (1,0), centered on the origin given.
{{domxref("DOMMatrix.rotateAxisAngleSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the given angle and the give vector.
{{domxref("DOMMatrix.skewXSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being skewed along the x-axis by the given factor.
{{domxref("DOMMatrix.skewYSelf()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being skewed along the y-axis by the given factor.
{{domxref("DOMMatrix.invertSelf()")}}
Returns itself,  a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being inverted. If the matrix cannot be inverted, all its components are set to NaN and is2D() returns false.
{{domxref("DOMMatrix.setMatrixValue()")}}
Returns itself, a {{domxref("DOMMatrix")}}, with its describing the matrix representing the same transformation as the CSS {{domxref("transform")}} functions given in parameter.

Specifications

Specification Status Comment
{{ SpecName('Geometry Interfaces', '#dom-dommatrix', 'DOMMatrix') }} {{ 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

  • Its non-modifiable part, {{domxref("DOMMatrixReadOnly")}}
  • {{domxref("SVGMatrix")}}, the SVG matrix intended to be superseded by {{domxref("DOMMatrix")}}

 

Revision Source

<p>{{APIRef("Geometry Interfaces")}}{{SeeCompatTable}}</p>

<p>The <code><strong>DOMMatrix</strong></code> interface represents 4x4 matrices, suitable for 2D and 3D operations.</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 don't allow it yet.</p>

<h2 id="Properties">Properties</h2>

<p><em>This interface inherits properties from {{domxref("DOMMatrixReadOnly")}}, though some are modified not to be read-only.</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></dt>
 <dd>Are <code>double</code> representing each component of a 4x4 matrix.</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>
 </dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em>This interface inherits methods from {{domxref("DOMMatrixReadOnly")}}.</em></p>

<dl>
 <dt>{{domxref("DOMMatrixReadOnly.multiplySelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}},&nbsp; with its new content being the result of the original matrix being multiplied by the given {{domxref("DOMMatrix")}}.</dd>
 <dt>{{domxref("DOMMatrixReadOnly.preMultiplySelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}},&nbsp; with its new content being the result of the given {{domxref("DOMMatrix")}} being multiplied by the original matrix.</dd>
 <dt>{{domxref("DOMMatrix.translateSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix being translated by the given vector.</dd>
 <dt>{{domxref("DOMMatrix.scaleSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix x and y dimensions being scaled by the given factor, centered on the origin given.</dd>
 <dt>{{domxref("DOMMatrix.scale3dSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the matrix x, y and z dimension being scaled by the given factor, centered on the origin given.</dd>
 <dt>{{domxref("DOMMatrix.scaleNonUniformSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content 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.</dd>
 <dt>{{domxref("DOMMatrix.rotateSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the given angle, with the rotation centered on the origin given.</dd>
 <dt>{{domxref("DOMMatrix.rotateFromVectorSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the angle between the given vector and (1,0), centered on the origin given.</dd>
 <dt>{{domxref("DOMMatrix.rotateAxisAngleSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being rotated by the given angle and the give vector.</dd>
 <dt>{{domxref("DOMMatrix.skewXSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being skewed along the x-axis by the given factor.</dd>
 <dt>{{domxref("DOMMatrix.skewYSelf()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being skewed along the y-axis by the given factor.</dd>
 <dt>{{domxref("DOMMatrix.invertSelf()")}}</dt>
 <dd>Returns itself,&nbsp; a {{domxref("DOMMatrix")}}, with its new content being the result of the original matrix being inverted. If the matrix cannot be inverted, all its components are set to <code>NaN</code> and <code>is2D()</code> returns <code>false</code>.</dd>
 <dt>{{domxref("DOMMatrix.setMatrixValue()")}}</dt>
 <dd>Returns itself, a {{domxref("DOMMatrix")}}, with its describing the matrix representing the same transformation as the CSS {{domxref("transform")}} functions given in parameter.</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-dommatrix', 'DOMMatrix') }}</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>Its non-modifiable part, {{domxref("DOMMatrixReadOnly")}}</li>
 <li>{{domxref("SVGMatrix")}}, the SVG matrix intended to be superseded by {{domxref("DOMMatrix")}}</li>
</ul>

<p>&nbsp;</p>
Revert to this revision