The goog.graphics.AffineTransform Class

goog.graphics.AffineTransform(opt_m00, opt_m10, opt_m01, opt_m11, opt_m02, opt_m12)

Creates a 2D affine transform. An affine transform performs a linear mapping from 2D coordinates to other 2D coordinates that preserves the "straightness" and "parallelness" of lines. Such a coordinate transformation can be represented by a 3 row by 3 column matrix with an implied last row of [ 0 0 1 ]. This matrix transforms source coordinates (x,y) into destination coordinates (x',y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

      [ x']   [  m00  m01  m02  ] [ x ]   [ m00x + m01y + m02 ]
      [ y'] = [  m10  m11  m12  ] [ y ] = [ m10x + m11y + m12 ]
      [ 1 ]   [   0    0    1   ] [ 1 ]   [         1         ]
 
This class is optimized for speed and minimizes calculations based on its knowledge of the underlying matrix (as opposed to say simply performing matrix multiplication).
opt_m00 {number=}
The m00 coordinate of the transform.
opt_m10 {number=}
The m10 coordinate of the transform.
opt_m01 {number=}
The m01 coordinate of the transform.
opt_m11 {number=}
The m11 coordinate of the transform.
opt_m02 {number=}
The m02 coordinate of the transform.
opt_m12 {number=}
The m12 coordinate of the transform.

.clone()

returns {!goog.graphics.AffineTransform}
A copy of this transform.

.concatenate(tx)

Concatenates an affine transform to this transform.

tx {!goog.graphics.AffineTransform}
The transform to concatenate.
returns {!goog.graphics.AffineTransform}
This affine transform.

.copyFrom(tx)

Sets this transform to be identical to the given transform.

tx {!goog.graphics.AffineTransform}
The transform to copy.
returns {!goog.graphics.AffineTransform}
This affine transform.

.createInverse()

returns {!goog.graphics.AffineTransform}
An AffineTransform object representing the inverse transformation.

.equals(tx)

Compares two affine transforms for equality.

tx {goog.graphics.AffineTransform}
The other affine transform.
returns {boolean}
whether the two transforms are equal.

.getDeterminant()

returns {number}
The determinant of this transform.

.getRotateInstance(theta, x, y)

Creates a transform representing a rotation transformation.

theta {number}
The angle of rotation measured in radians.
x {number}
The x coordinate of the anchor point.
y {number}
The y coordinate of the anchor point.
returns {!goog.graphics.AffineTransform}
A transform representing a rotation transformation.

.getScaleInstance(sx, sy)

Creates a transform representing a scaling transformation.

sx {number}
The x-axis scaling factor.
sy {number}
The y-axis scaling factor.
returns {!goog.graphics.AffineTransform}
A transform representing a scaling transformation.

.getScaleX()

returns {number}
The scaling factor in the x-direction (m00).

.getScaleY()

returns {number}
The scaling factor in the y-direction (m11).

.getShearInstance(shx, shy)

Creates a transform representing a shearing transformation.

shx {number}
The x-axis shear factor.
shy {number}
The y-axis shear factor.
returns {!goog.graphics.AffineTransform}
A transform representing a shearing transformation.

.getShearX()

returns {number}
The shear factor in the x-direction (m01).

.getShearY()

returns {number}
The shear factor in the y-direction (m10).

.getTranslateInstance(dx, dy)

Creates a transform representing a translation transformation.

dx {number}
The distance to translate in the x direction.
dy {number}
The distance to translate in the y direction.
returns {!goog.graphics.AffineTransform}
A transform representing a translation transformation.

.getTranslateX()

returns {number}
The translation in the x-direction (m02).

.getTranslateY()

returns {number}
The translation in the y-direction (m12).

.isIdentity()

returns {boolean}
Whether this transform is the identity transform.

.isInvertible()

Returns whether the transform is invertible. A transform is not invertible if the determinant is 0 or any value is non-finite or NaN.

returns {boolean}
Whether the transform is invertible.

.preConcatenate(tx)

Pre-concatenates an affine transform to this transform.

tx {!goog.graphics.AffineTransform}
The transform to preconcatenate.
returns {!goog.graphics.AffineTransform}
This affine transform.

.preRotate(theta, x, y)

Pre-concatenates this transform with a rotation transformation around an anchor point.

theta {number}
The angle of rotation measured in radians.
x {number}
The x coordinate of the anchor point.
y {number}
The y coordinate of the anchor point.
returns {!goog.graphics.AffineTransform}
This affine transform.

.preScale(sx, sy)

Pre-concatenates this transform with a scaling transformation, i.e. calculates the following matrix product:

 [sx  0 0] [m00 m01 m02]
 [ 0 sy 0] [m10 m11 m12]
 [ 0  0 1] [  0   0   1]
 
sx {number}
The x-axis scaling factor.
sy {number}
The y-axis scaling factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.preShear(shx, shy)

Pre-concatenates this transform with a shear transformation. i.e. calculates the following matrix product:

 [  1 shx 0] [m00 m01 m02]
 [shy   1 0] [m10 m11 m12]
 [  0   0 1] [  0   0   1]
 
shx {number}
The x shear factor.
shy {number}
The y shear factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.preTranslate(dx, dy)

Pre-concatenates this transform with a translate transformation, i.e. calculates the following matrix product:

 [1 0 dx] [m00 m01 m02]
 [0 1 dy] [m10 m11 m12]
 [0 0  1] [  0   0   1]
 
dx {number}
The distance to translate in the x direction.
dy {number}
The distance to translate in the y direction.
returns {!goog.graphics.AffineTransform}
This affine transform.

.rotate(theta, x, y)

Concatenates this transform with a rotation transformation around an anchor point.

theta {number}
The angle of rotation measured in radians.
x {number}
The x coordinate of the anchor point.
y {number}
The y coordinate of the anchor point.
returns {!goog.graphics.AffineTransform}
This affine transform.

.scale(sx, sy)

Concatenates this transform with a scaling transformation.

sx {number}
The x-axis scaling factor.
sy {number}
The y-axis scaling factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.setToRotation(theta, x, y)

Sets this transform to a rotation transformation.

theta {number}
The angle of rotation measured in radians.
x {number}
The x coordinate of the anchor point.
y {number}
The y coordinate of the anchor point.
returns {!goog.graphics.AffineTransform}
This affine transform.

.setToScale(sx, sy)

Sets this transform to a scaling transformation.

sx {number}
The x-axis scaling factor.
sy {number}
The y-axis scaling factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.setToShear(shx, shy)

Sets this transform to a shearing transformation.

shx {number}
The x-axis shear factor.
shy {number}
The y-axis shear factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.setToTranslation(dx, dy)

Sets this transform to a translation transformation.

dx {number}
The distance to translate in the x direction.
dy {number}
The distance to translate in the y direction.
returns {!goog.graphics.AffineTransform}
This affine transform.

.setTransform(m00, m10, m01, m11, m02, m12)

Sets this transform to the matrix specified by the 6 values.

m00 {number}
The m00 coordinate of the transform.
m10 {number}
The m10 coordinate of the transform.
m01 {number}
The m01 coordinate of the transform.
m11 {number}
The m11 coordinate of the transform.
m02 {number}
The m02 coordinate of the transform.
m12 {number}
The m12 coordinate of the transform.
returns {!goog.graphics.AffineTransform}
This affine transform.

.shear(shx, shy)

Concatenates this transform with a shear transformation.

shx {number}
The x shear factor.
shy {number}
The y shear factor.
returns {!goog.graphics.AffineTransform}
This affine transform.

.toString()

returns {string}
A string representation of this transform. The format of of the string is compatible with SVG matrix notation, i.e. "matrix(a,b,c,d,e,f)".

.transform(src, srcOff, dst, dstOff, numPts)

Transforms an array of coordinates by this transform and stores the result into a destination array.

src {!Array.<number>}
The array containing the source points as x, y value pairs.
srcOff {number}
The offset to the first point to be transformed.
dst {!Array.<number>}
The array into which to store the transformed point pairs.
dstOff {number}
The offset of the location of the first transformed point in the destination array.
numPts {number}
The number of points to tranform.

.translate(dx, dy)

Concatenates this transform with a translate transformation.

dx {number}
The distance to translate in the x direction.
dy {number}
The distance to translate in the y direction.
returns {!goog.graphics.AffineTransform}
This affine transform.