Sg 2.9
Matrix
Packages RSS
About
News
Gallery
Scripts
Tutorials
Download
Reference
Forum
Users
License
Twitter

Matrix represents an affine transformation between two coordinate spaces in 2 dimensions. Such a transform preserves the "straightness" and "parallelness" of lines. The transform is built from a sequence of translations, scales, flips, rotations, and shears.

The transformation can be represented using matrix math on a 3x3 array. Given (x, y), the transformation (x', y') can be found by:

[ x'] [ scaleX shearX translateX ] [ x ]
[ y'] = [ shearY scaleY translateY ] [ y ]
[ 1 ] [ 0 0 1 ] [ 1 ]
 [ scaleX * x + shearX * y + translateX ]
 = [ shearY * x + scaleY * y + translateY ]
 [ 1 ]

The bottom row of the matrix is constant, so a transform can be uniquely represented by "[[scaleX, shearX, translateX], [shearY, scaleY, translateY]]".

Constructors

Construct a transform with the given matrix entries:

[ scaleX shearX translateX ]
[ shearY scaleY translateY ]
[ 0 0 1 ]
    Parameters:
  • scaleX: Number — the x scaling component
  • shearY: Number — the y shearing component
  • shearX: Number — the x shearing component
  • scaleY: Number — the y scaling component
  • translateX: Number — the x translation component
  • translateY: Number — the y translation component

Construct a matrix from a sequence of numbers. The array must have at least 4 entries, which has a translation factor of 0; or 6 entries, for specifying all parameters:

[ values[0] values[2] (values[4]) ]
[ values[1] values[3] (values[5]) ]
[ 0 0 1 ]
    Parameters:
  • values: Array of Number — the matrix to copy from, with at least 4 (6) entries
    Throws:
  • NullPointerException — if values is null
  • ArrayIndexOutOfBoundsException — if values is too small

Operators

    Returns:
  • Boolean

Properties

    Returns:
  • Number
    Returns:
  • Number
    Returns:
  • Number
    Returns:
  • Number
    Returns:
  • Number
    Returns:
  • Number

Functions

Returns a copy of the Matrix object.

    Returns:
  • Matrix — a copy of the Matrix object.

Creates the inverse transformation of the matrix. If the matrix is not invertible (in which case isSingular() returns true), invert() returns null, otherwise the matrix itself is modified and a reference to it is returned.

    Returns:
  • Matrix — the inverted matrix, or null, if the matrix is singular

Matrix Concatenation

Concatenates the matrix with a translation matrix that translates by (x, y). The object itself is modified and a reference to it is returned.

    Parameters:
  • x: Number — the x coordinate of the translation
  • y: Number — the y coordinate of the translation
    Returns:
  • Matrix — the translated matrix

Concatenates the matrix with a translation matrix that translates by the specified point. The object itself is modified and a reference to it is returned.

    Parameters:
  • pt: Point — the coordinates of the translation
    Returns:
  • Matrix — the translated matrix

Concatenates the matrix with a scaling matrix that scales by the specified (scaleX, scaleY) factors. The object itself is modified and a reference to it is returned.

    Parameters:
  • scaleX: Number
  • scaleY: Number
  • center: Point — optional
    Returns:
  • Matrix — a reference to the matrix

Concatenates the matrix with a scaling matrix that scales by the specified scale factor. The object itself is modified and a reference to it is returned.

    Parameters:
  • scale: Number
  • center: Point — optional
    Returns:
  • Matrix — a reference to the matrix

Concatenates the matrix with a matrix that rotates coordinates by a specified angle (and around a center point, if specified). The matrix itself is modified and a reference to it is returned.

Angles are oriented clockwise and measured in degrees by default. Read more about angle units and orientation in the description of the point.angle property.

    Parameters:
  • angle: Number — the angle to rotate by
  • center: Point — the center point around which to rotate — optional
    Returns:
  • Matrix — a reference to the matrix

Concatenates the matrix with a shearing matrix. The object itself is modified and a reference to it is returned.

    Parameters:
  • shearX: Number — the horizontal shearing
  • shearY: Number — the vertical shearing
    Returns:
  • Matrix — a reference to the matrix

Concatenates the specified matrix to the matrix in the most commonly useful way to provide a new user space that is mapped to the former user space by the specified matrix. The matrix itself is modified and a reference to it is returned.

    Returns:
  • Matrix — a reference to the matrix

Concatenates the specified matrix to the matrix in a less commonly used way such that the specified matrix modifies the coordinate transformation relative to the absolute pixel space rather than relative to the existing user space. The object itself is modified and a reference to it is returned.

    Returns:
  • Matrix — a reference to the matrix

Tests

Checks whether the matrix is an identity. Identity matrices are equal to their inversion.

    Returns:
  • Boolean — true if the matrix is an identity, false otherwise

Checks whether the matrix is singular or not. Singular matrices cannot be inverted.

    Returns:
  • Boolean — true if the matrix is singular, false otherwise

AltStyle によって変換されたページ (->オリジナル) /