Options
Menu

Class Matrix2D

Matrix2D

Represents an affine transformation matrix, and provides tools for constructing and concatenating matrices.

This matrix can be visualized as:

[ a  c  tx
  b  d  ty
  0  0  1  ]

Note the locations of b and c.


Visit http://createjs.com/ for documentation, updates and examples.

Copyright (c) 2017 gskinner.com, inc.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Hierarchy

  • Matrix2D

Implements

Index

Constructors

constructor

  • new Matrix2D(a?: undefined | number, b?: undefined | number, c?: undefined | number, d?: undefined | number, tx?: undefined | number, ty?: undefined | number): Matrix2D
  • Parameters

    • Optional a: undefined | number

      Specifies the a property for the new matrix.

    • Optional b: undefined | number

      Specifies the b property for the new matrix.

    • Optional c: undefined | number

      Specifies the c property for the new matrix.

    • Optional d: undefined | number

      Specifies the d property for the new matrix.

    • Optional tx: undefined | number

      Specifies the tx property for the new matrix.

    • Optional ty: undefined | number

      Specifies the ty property for the new matrix.

    Returns Matrix2D

Properties

a

a: number

Position (0, 0) in a 3x3 affine transformation matrix.

b

b: number

Position (0, 1) in a 3x3 affine transformation matrix.

c

c: number

Position (1, 0) in a 3x3 affine transformation matrix.

d

d: number

Position (1, 1) in a 3x3 affine transformation matrix.

tx

tx: number

Position (2, 0) in a 3x3 affine transformation matrix.

ty

ty: number

Position (2, 1) in a 3x3 affine transformation matrix.

Static DEG_TO_RAD

DEG_TO_RAD: number

Multiplier for converting degrees to radians. Used internally by Matrix2D.

Static identity

identity: Matrix2D

An identity matrix, representing a null transformation.

Methods

append

  • append(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D
  • Appends the specified matrix properties to this matrix. All parameters are required. This is the equivalent of multiplying (this matrix) * (specified matrix).

    Parameters

    • a: number
    • b: number
    • c: number
    • d: number
    • tx: number
    • ty: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

appendMatrix

  • Parameters

    Returns Matrix2D

appendTransform

  • appendTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): Matrix2D
  • Parameters

    • x: number
    • y: number
    • scaleX: number
    • scaleY: number
    • rotation: number
    • skewX: number
    • skewY: number
    • regX: number
    • regY: number

    Returns Matrix2D

clone

  • Returns a clone of the Matrix2D instance.

    Returns Matrix2D

    a clone of the Matrix2D instance.

copy

  • Parameters

    Returns Matrix2D

decompose

  • Decomposes the matrix into transform properties (x, y, scaleX, scaleY, and rotation). Note that these values may not match the transform properties you used to generate the matrix, though they will produce the same visual results.

    Parameters

    Returns DecomposedProps

    The target, or a new generic object with the transform properties applied.

equals

  • Parameters

    Returns boolean

identity

  • Sets the properties of the matrix to those of an identity matrix (one that applies a null transformation).

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

invert

  • Inverts the matrix, causing it to perform the opposite transformation.

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

isIdentity

  • isIdentity(): boolean
  • Returns true if the matrix is an identity matrix.

    Returns boolean

prepend

  • prepend(a: number, b: number, c: number, d: number, tx: number, ty: number): Matrix2D
  • Prepends the specified matrix properties to this matrix. This is the equivalent of multiplying (specified matrix) * (this matrix). All parameters are required.

    Parameters

    • a: number
    • b: number
    • c: number
    • d: number
    • tx: number
    • ty: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

prependMatrix

  • Parameters

    Returns Matrix2D

prependTransform

  • prependTransform(x: number, y: number, scaleX: number, scaleY: number, rotation: number, skewX: number, skewY: number, regX: number, regY: number): Matrix2D
  • Parameters

    • x: number
    • y: number
    • scaleX: number
    • scaleY: number
    • rotation: number
    • skewX: number
    • skewY: number
    • regX: number
    • regY: number

    Returns Matrix2D

rotate

  • Applies a clockwise rotation transformation to the matrix.

    Parameters

    • angle: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

scale

  • Applies a scale transformation to the matrix.

    Parameters

    • x: number
    • y: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

setValues

  • setValues(a?: undefined | number, b?: undefined | number, c?: undefined | number, d?: undefined | number, tx?: undefined | number, ty?: undefined | number): Matrix2D
  • Sets the specified values on this instance.

    Parameters

    • Optional a: undefined | number
    • Optional b: undefined | number
    • Optional c: undefined | number
    • Optional d: undefined | number
    • Optional tx: undefined | number
    • Optional ty: undefined | number

    Returns Matrix2D

    This instance. Useful for chaining method calls.

skew

  • skew(skewX: number, skewY: number): Matrix2D
  • Applies a skew transformation to the matrix.

    Parameters

    • skewX: number
    • skewY: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.

toString

  • toString(): string
  • Returns a string representation of this object.

    Returns string

    a string representation of the instance.

transformPoint

  • transformPoint(x: number, y: number, pt: Point): Point
  • Parameters

    • x: number
    • y: number
    • pt: Point

    Returns Point

translate

  • translate(x: number, y: number): Matrix2D
  • Translates the matrix on the x and y axes.

    Parameters

    • x: number
    • y: number

    Returns Matrix2D

    This matrix. Useful for chaining method calls.