SkMatrix Reference


Matrix holds a 3x3 matrix for transforming coordinates. This allows mapping Points and Vectors with translation, scaling, skewing, rotation, and perspective.

Matrix elements are in row major order. Matrix does not have a constructor, so it must be explicitly initialized. setIdentity initializes Matrix so it has no effect. setTranslate, setScale, setSkew, setRotate, set9 and setAll initializes all Matrix elements with the corresponding mapping.

Matrix includes a hidden variable that classifies the type of matrix to improve performance. Matrix is not thread safe unless getType is called first.


Sets Matrix to scale by (sx, sy). Returned matrix is:

Parameters

Return Value

Matrix with scale

Example

See Also

setScale[2] postScale[2] preScale[2]


Sets Matrix to scale by (scale, scale). Returned matrix is:

Parameters

Return Value

Matrix with scale

Example

See Also

setScale[2] postScale[2] preScale[2]


Sets Matrix to translate by (dx, dy). Returned matrix is:

Parameters

Return Value

Matrix with translation

Example

See Also

setTranslate[2] postTranslate preTranslate


Sets Matrix to:

Parameters

Return Value

Matrix constructed from parameters

Example

See Also

setAll set9 postConcat preConcat


Enum of bit fields for mask returned by getType. Used to identify the complexity of Matrix, to optimize performance.

Constants

Example

Example Output

after reset: kIdentity_Mask
after postTranslate: kTranslate_Mask
after postScale: kTranslate_Mask kScale_Mask
after postScale: kTranslate_Mask kScale_Mask kAffine_Mask
after setPolyToPoly: kTranslate_Mask kScale_Mask kAffine_Mask kPerspective_Mask

See Also

getType


Returns a bit field describing the transformations the matrix may perform. The bit field is computed conservatively, so it may include false positives. For example, when kPerspective Mask is set, all other bits are set.

Return Value

kIdentity Mask, or combinations of: kTranslate Mask, kScale Mask, kAffine Mask, kPerspective Mask

Example

Example Output

identity flags hex: 0 decimal: 0
set all  flags hex: f decimal: 15

See Also

TypeMask


Returns true if Matrix is identity. Identity matrix is:

Return Value

true if Matrix has no effect

Example

Example Output

is identity: true
is identity: false

See Also

reset() setIdentity getType


Returns true if Matrix at most scales and translates. Matrix may be identity, contain only scale elements, only translate elements, or both. Matrix form is:

Return Value

true if Matrix is identity; or scales, translates, or both

Example

Example Output

is scale-translate: true
is scale-translate: true
is scale-translate: true
is scale-translate: true

See Also

setScale[2] isTranslate setTranslate[2] getType


Returns true if Matrix is identity, or translates. Matrix form is:

Return Value

true if Matrix is identity, or translates

Example

Example Output

is translate: true
is translate: true
is translate: false
is translate: false

See Also

setTranslate[2] getType


Returns true Matrix maps Rect to another Rect. If true, Matrix is identity, or scales, or rotates a multiple of 90 degrees, or mirrors on axes. In all cases, Matrix may also have translation. Matrix form is either:

or

for non-zero values of scale-x, scale-y, rotate-x, and rotate-y.

Also called preservesAxisAlignment; use the one that provides better inline documentation.

Return Value

true if Matrix maps one Rect into another

Example

Example Output

rectStaysRect: true
rectStaysRect: true
rectStaysRect: true
rectStaysRect: true

See Also

preservesAxisAlignment preservesRightAngles


Returns true Matrix maps Rect to another Rect. If true, Matrix is identity, or scales, or rotates a multiple of 90 degrees, or mirrors on axes. In all cases, Matrix may also have translation. Matrix form is either:

or

for non-zero values of scale-x, scale-y, rotate-x, and rotate-y.

Also called rectStaysRect; use the one that provides better inline documentation.

Return Value

true if Matrix maps one Rect into another

Example

Example Output

preservesAxisAlignment: true
preservesAxisAlignment: true
preservesAxisAlignment: true
preservesAxisAlignment: true

See Also

rectStaysRect preservesRightAngles


Returns true if the matrix contains perspective elements. Matrix form is:

where perspective-x or perspective-y is non-zero, or perspective-scale is not one. All other elements may have any value.

Return Value

true if Matrix is in most general form

Example

See Also

setAll set9 MakeAll


Returns true if Matrix contains only translation, rotation, reflection, and uniform scale. Returns false if Matrix contains different scales, skewing, perspective, or degenerate forms that collapse to a line or point.

Describes that the Matrix makes rendering with and without the matrix are visually alike; a transformed circle remains a circle. Mathematically, this is referred to as similarity of a Euclidean Space, or a similarity transformation.

Preserves right angles, keeping the arms of the angle equal lengths.

Parameters

Return Value

true if Matrix only rotates, uniformly scales, translates

Example

See Also

isScaleTranslate preservesRightAngles rectStaysRect isFixedStepInX


Returns true if Matrix contains only translation, rotation, reflection, and scale. Scale may differ along rotated axes. Returns false if Matrix skewing, perspective, or degenerate forms that collapse to a line or point.

Preserves right angles, but not requiring that the arms of the angle retain equal lengths.

Parameters

Return Value

true if Matrix only rotates, scales, translates

Example

See Also

isScaleTranslate isSimilarity rectStaysRect isFixedStepInX


Matrix organizes its values in row order. These members correspond to each value in Matrix.

Constants

Example

See Also

get() set()


Affine arrays are in column major order to match the matrix used by PDF and XPS.

Constants

See Also

SetAffineIdentity asAffine setAffine


Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.

Parameters

Return Value

value corresponding to index

Example

Example Output

matrix[SkMatrix::kMScaleX] == 42
matrix[SkMatrix::kMScaleY] == 24

See Also

get set


Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.

Parameters

Return Value

value corresponding to index

Example

Example Output

matrix.get(SkMatrix::kMSkewX) == 42
matrix.get(SkMatrix::kMSkewY) == 24

See Also

operator[](int index) set


Returns scale factor multiplied by x-axis input, contributing to x-axis output. With mapPoints, scales Points along the x-axis.

Return Value

horizontal scale factor

Example

Example Output

matrix.getScaleX() == 42

See Also

get getScaleY setScaleX setScale[2]


Returns scale factor multiplied by y-axis input, contributing to y-axis output. With mapPoints, scales Points along the y-axis.

Return Value

vertical scale factor

Example

Example Output

matrix.getScaleY() == 24

See Also

get getScaleX setScaleY setScale[2]


Returns scale factor multiplied by x-axis input, contributing to y-axis output. With mapPoints, skews Points along the y-axis. Skewing both axes can rotate Points.

Return Value

vertical skew factor

Example

Example Output

matrix.getSkewY() == 24

See Also

get getSkewX setSkewY setSkew[2]


Returns scale factor multiplied by y-axis input, contributing to x-axis output. With mapPoints, skews Points along the x-axis. Skewing both axes can rotate Points.

Return Value

horizontal scale factor

Example

Example Output

matrix.getSkewX() == 42

See Also

get getSkewY setSkewX setSkew[2]


Returns translation contributing to x-axis output. With mapPoints, moves Points along the x-axis.

Return Value

horizontal translation factor

Example

Example Output

matrix.getTranslateX() == 42

See Also

get getTranslateY setTranslateX setTranslate[2]


Returns translation contributing to y-axis output. With mapPoints, moves Points along the y-axis.

Return Value

vertical translation factor

Example

Example Output

matrix.getTranslateY() == 24

See Also

get getTranslateX setTranslateY setTranslate[2]


Returns factor scaling input x-axis relative to input y-axis.

Return Value

input x-axis perspective factor

Example

See Also

kMPersp0 getPerspY


Returns factor scaling input y-axis relative to input x-axis.

Return Value

input y-axis perspective factor

Example

See Also

kMPersp1 getPerspX


Returns writable Matrix value. Asserts if index is out of range and SK_DEBUG is defined. Clears internal cache anticipating that caller will change Matrix value.

Next call to read Matrix state may recompute cache; subsequent writes to Matrix value must be followed by dirtyMatrixTypeCache.

Parameters

Return Value

writable value corresponding to index

Example

Example Output

with identity matrix: x = 24
after skew x mod:     x = 24
after 2nd skew x mod: x = 24
after dirty cache:    x = 66

See Also

get dirtyMatrixTypeCache set


Sets Matrix value. Asserts if index is out of range and SK_DEBUG is defined. Safer than operator[]; internal cache is always maintained.

Parameters

Example

Example Output

with identity matrix: x = 24
after skew x mod:     x = 24
after 2nd skew x mod: x = 66

See Also

operator[] get


Sets horizontal scale factor.

Parameters

Example

See Also

set setScale[2] setScaleY


Sets vertical scale factor.

Parameters

Example

See Also

set setScale[2] setScaleX


Sets vertical skew factor.

Parameters

Example

See Also

set setSkew[2] setSkewX


Sets horizontal skew factor.

Parameters

Example

See Also

set setSkew[2] setSkewX


Sets horizontal translation.

Parameters

Example

See Also

set setTranslate[2] setTranslateY


Sets vertical translation.

Parameters

Example

See Also

set setTranslate[2] setTranslateX


Sets input x-axis perspective factor, which causes mapXY to vary input x-axis values inversely proportional to input y-axis values.

Parameters

Example

See Also

getPerspX set setAll set9 MakeAll


Sets input y-axis perspective factor, which causes mapXY to vary input y-axis values inversely proportional to input x-axis values.

Parameters

Example

See Also

getPerspY set setAll set9 MakeAll


Sets all values from parameters. Sets matrix to:

Parameters

Example

See Also

set9 MakeAll


Copies nine Scalar values contained by Matrix into buffer, in member value ascending order: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2.

Parameters

Example

Example Output

{4, 0, 3},
{0, 5, 4},
{0, 0, 1}

See Also

set9


Sets Matrix to nine Scalar values in buffer, in member value ascending order: kMScaleX, kMSkewX, kMTransX, kMSkewY, kMScaleY, kMTransY, kMPersp0, kMPersp1, kMPersp2.

Sets matrix to:

In the future, set9 followed by get9 may not return the same values. Since Matrix maps non-homogeneous coordinates, scaling all nine values produces an equivalent transformation, possibly improving precision.

Parameters

Example

See Also

setAll get9 MakeAll


Sets Matrix to identity; which has no effect on mapped Points. Sets Matrix to:

Also called setIdentity(); use the one that provides better inline documentation.

Example

Example Output

m.isIdentity(): true

See Also

isIdentity setIdentity


Sets Matrix to identity; which has no effect on mapped Points. Sets Matrix to:

Also called reset(); use the one that provides better inline documentation.

Example

Example Output

m.isIdentity(): true

See Also

isIdentity reset


Sets Matrix to translate by (dx, dy).

Parameters

Example

See Also

setTranslateX setTranslateY


Sets Matrix to translate by (v.fX, v.fY).

Parameters

Example

See Also

setTranslateX setTranslateY MakeTrans


Sets Matrix to scale by sx and sy, about a pivot point at (px, py). The pivot point is unchanged when mapped with Matrix.

Parameters

Example

See Also

setScaleX setScaleY MakeScale[2] preScale[2] postScale[2]


Sets Matrix to scale by sx and sy about at pivot point at (0, 0).

Parameters

Example

See Also

setScaleX setScaleY MakeScale[2] preScale[2] postScale[2]


Sets Matrix to rotate by degrees about a pivot point at (px, py). The pivot point is unchanged when mapped with Matrix.

Positive degrees rotates clockwise.

Parameters

Example

See Also

setSinCos[2] preRotate[2] postRotate[2]


Sets Matrix to rotate by degrees about a pivot point at (0, 0). Positive degrees rotates clockwise.

Parameters

Example

See Also

setSinCos[2] preRotate[2] postRotate[2]


Sets Matrix to rotate by sinValue and cosValue, about a pivot point at (px, py). The pivot point is unchanged when mapped with Matrix.

Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1). Vector length specifies scale.

Parameters

Example

See Also

setRotate[2] setScale[2] setRSXform


Sets Matrix to rotate by sinValue and cosValue, about a pivot point at (0, 0).

Vector (sinValue, cosValue) describes the angle of rotation relative to (0, 1). Vector length specifies scale.

Parameters

Example

See Also

setRotate[2] setScale[2] setRSXform


Sets Matrix to rotate, scale, and translate using a compressed matrix form.

Vector (rsxForm.fSSin, rsxForm.fSCos) describes the angle of rotation relative to (0, 1). Vector length specifies scale. Mapped point is rotated and scaled by Vector, then translated by (rsxForm.fTx, rsxForm.fTy).

Parameters

Return Value

reference to Matrix

Example

See Also

setSinCos[2] setScale[2] setTranslate[2]


Sets Matrix to skew by kx and ky, about a pivot point at (px, py). The pivot point is unchanged when mapped with Matrix.

Parameters

Example

See Also

setSkewX setSkewY preSkew[2] postSkew[2]


Sets Matrix to skew by kx and ky, about a pivot point at (0, 0).

Parameters

Example

See Also

setSkewX setSkewY preSkew[2] postSkew[2]


Sets Matrix to Matrix a multiplied by Matrix b. Either a or b may be this.

Given:

sets Matrix to:

Parameters

Example

See Also

Concat preConcat postConcat SkCanvas::concat


Sets Matrix to Matrix multiplied by Matrix constructed from translation (dx, dy). This can be thought of as moving the point to be mapped before applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

postTranslate setTranslate[2] MakeTrans


Sets Matrix to Matrix multiplied by Matrix constructed from scaling by (sx, sy) about pivot point (px, py). This can be thought of as scaling about a pivot point before applying Matrix.

Given:

where

sets Matrix to:

Parameters

Example

See Also

postScale[2] setScale[2] MakeScale[2]


Sets Matrix to Matrix multiplied by Matrix constructed from scaling by (sx, sy) about pivot point (0, 0). This can be thought of as scaling about the origin before applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

postScale[2] setScale[2] MakeScale[2]


Sets Matrix to Matrix multiplied by Matrix constructed from rotating by degrees about pivot point (px, py). This can be thought of as rotating about a pivot point before applying Matrix.

Positive degrees rotates clockwise.

Given:

where

sets Matrix to:

Parameters

Example

See Also

postRotate[2] setRotate[2]


Sets Matrix to Matrix multiplied by Matrix constructed from rotating by degrees about pivot point (0, 0). This can be thought of as rotating about the origin before applying Matrix.

Positive degrees rotates clockwise.

Given:

where

sets Matrix to:

Parameters

Example

See Also

postRotate[2] setRotate[2]


Sets Matrix to Matrix multiplied by Matrix constructed from skewing by (kx, ky) about pivot point (px, py). This can be thought of as skewing about a pivot point before applying Matrix.

Given:

where

sets Matrix to:

Parameters

Example

See Also

postSkew[2] setSkew[2]


Sets Matrix to Matrix multiplied by Matrix constructed from skewing by (kx, ky) about pivot point (0, 0). This can be thought of as skewing about the origin before applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

postSkew[2] setSkew[2]


Sets Matrix to Matrix multiplied by Matrix other. This can be thought of mapping by other before applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

postConcat setConcat Concat


Sets Matrix to Matrix constructed from translation (dx, dy) multiplied by Matrix. This can be thought of as moving the point to be mapped after applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

preTranslate setTranslate[2] MakeTrans


Sets Matrix to Matrix constructed from scaling by (sx, sy) about pivot point (px, py), multiplied by Matrix. This can be thought of as scaling about a pivot point after applying Matrix.

Given:

where

sets Matrix to:

Parameters

Example

See Also

preScale[2] setScale[2] MakeScale[2]


Sets Matrix to Matrix constructed from scaling by (sx, sy) about pivot point (0, 0), multiplied by Matrix. This can be thought of as scaling about the origin after applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

preScale[2] setScale[2] MakeScale[2]


Sets Matrix to Matrix constructed from scaling by (1/divx, 1/divy), about pivot point (px, py), multiplied by Matrix.

Returns false if either divx or divy is zero.

Given:

where

sets Matrix to:

Parameters

Return Value

true on successful scale

Example

See Also

postScale[2] MakeScale[2]


Sets Matrix to Matrix constructed from rotating by degrees about pivot point (px, py), multiplied by Matrix. This can be thought of as rotating about a pivot point after applying Matrix.

Positive degrees rotates clockwise.

Given:

where

sets Matrix to:

Parameters

Example

See Also

preRotate[2] setRotate[2]


Sets Matrix to Matrix constructed from rotating by degrees about pivot point (0, 0), multiplied by Matrix. This can be thought of as rotating about the origin after applying Matrix.

Positive degrees rotates clockwise.

Given:

where

sets Matrix to:

Parameters

Example

See Also

preRotate[2] setRotate[2]


Sets Matrix to Matrix constructed from skewing by (kx, ky) about pivot point (px, py), multiplied by Matrix. This can be thought of as skewing about a pivot point after applying Matrix.

Given:

where

sets Matrix to:

Parameters

Example

See Also

preSkew[2] setSkew[2]


Sets Matrix to Matrix constructed from skewing by (kx, ky) about pivot point (0, 0), multiplied by Matrix. This can be thought of as skewing about the origin after applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

preSkew[2] setSkew[2]


Sets Matrix to Matrix other multiplied by Matrix. This can be thought of mapping by other after applying Matrix.

Given:

sets Matrix to:

Parameters

Example

See Also

preConcat setConcat Concat


ScaleToFit describes how Matrix is constructed to map one Rect to another. ScaleToFit may allow Matrix to have unequal horizontal and vertical scaling, or may restrict Matrix to square scaling. If restricted, ScaleToFit specifies how Matrix maps to the side or center of the destination Rect.

Constants

Example

See Also

setRectToRect MakeRectToRect setPolyToPoly


Sets Matrix to scale and translate src Rect to dst Rect. stf selects whether mapping completely fills dst or preserves the aspect ratio, and how to align src within dst. Returns false if src is empty, and sets Matrix to identity. Returns true if dst is empty, and sets Matrix to:

Parameters

Return Value

true if Matrix can represent Rect mapping

Example

Example Output

src: 0, 0, 0, 0  dst: 0, 0, 0, 0  success: false
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
src: 0, 0, 0, 0  dst: 5, 6, 8, 9  success: false
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
src: 1, 2, 3, 4  dst: 0, 0, 0, 0  success: true
[  0.0000   0.0000   0.0000][  0.0000   0.0000   0.0000][  0.0000   0.0000   1.0000]
src: 1, 2, 3, 4  dst: 5, 6, 8, 9  success: true
[  1.5000   0.0000   3.5000][  0.0000   1.5000   3.0000][  0.0000   0.0000   1.0000]

See Also

MakeRectToRect ScaleToFit setPolyToPoly SkRect::isEmpty


Returns Matrix set to scale and translate src Rect to dst Rect. stf selects whether mapping completely fills dst or preserves the aspect ratio, and how to align src within dst. Returns the identity Matrix if src is empty. If dst is empty, returns Matrix set to:

Parameters

Return Value

Matrix mapping src to dst

Example

Example Output

src: 0, 0, 0, 0  dst: 0, 0, 0, 0
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
src: 0, 0, 0, 0  dst: 5, 6, 8, 9
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
src: 1, 2, 3, 4  dst: 0, 0, 0, 0
[  0.0000   0.0000   0.0000][  0.0000   0.0000   0.0000][  0.0000   0.0000   1.0000]
src: 1, 2, 3, 4  dst: 5, 6, 8, 9
[  1.5000   0.0000   3.5000][  0.0000   1.5000   3.0000][  0.0000   0.0000   1.0000]

See Also

setRectToRect ScaleToFit setPolyToPoly SkRect::isEmpty


Sets Matrix to map src to dst. count must be zero or greater, and four or less.

If count is zero, sets Matrix to identity and returns true. If count is one, sets Matrix to translate and returns true. If count is two or more, sets Matrix to map Points if possible; returns false if Matrix cannot be constructed. If count is four, Matrix may include perspective.

Parameters

Return Value

true if Matrix was constructed successfully

Example

See Also

setRectToRect MakeRectToRect


Sets inverse to reciprocal matrix, returning true if Matrix can be inverted. Geometrically, if Matrix maps from source to destination, inverse Matrix maps from destination to source. If Matrix can not be inverted, inverse is unchanged.

Parameters

Return Value

true if Matrix can be inverted

Example

See Also

Concat


Fills affine with identity values in column major order. Sets affine to:

Affine 3x2 matrices in column major order are used by OpenGL and XPS.

Parameters

Example

Example Output

ScaleX: 1 SkewY: 0 SkewX: 0 ScaleY: 1 TransX: 0 TransY: 0

See Also

setAffine asAffine


Fills affine in column major order. Sets affine to:

If Matrix contains perspective, returns false and leaves affine unchanged.

Parameters

Return Value

true if Matrix does not contain perspective

Example

Example Output

ScaleX: 2 SkewY: 5 SkewX: 3 ScaleY: 6 TransX: 4 TransY: 7

See Also

setAffine SetAffineIdentity


Sets Matrix to affine values, passed in column major order. Given affine, column, then row, as:

Matrix is set, row, then column, to:

Parameters

Example

Example Output

ScaleX: 2 SkewY: 5 SkewX: 3 ScaleY: 6 TransX: 4 TransY: 7
[  2.0000   3.0000   4.0000][  5.0000   6.0000   7.0000][  0.0000   0.0000   1.0000]

See Also

asAffine SetAffineIdentity


Maps src Point array of length count to dst Point array of equal or greater length. Points are mapped by multiplying each Point by Matrix. Given:

where

each dst Point is computed as:

src and dst may point to the same storage.

Parameters

Example

See Also

mapXY[2] mapHomogeneousPoints mapVectors[2]


Maps pts Point array of length count in place. Points are mapped by multiplying each Point by Matrix. Given:

where

each resulting pts Point is computed as:

Parameters

Example

See Also

mapXY[2] mapHomogeneousPoints mapVectors[2]


Maps src Point3 array of length count to dst Point3 array, which must of length count or greater. Point3 array is mapped by multiplying each Point3 by Matrix. Given:

each resulting dst Point is computed as:

Parameters

Example

See Also

mapPoints[2] mapXY[2] mapVectors[2]


Maps Point (x, y) to result. Point is mapped by multiplying by Matrix. Given:

result is computed as:

Parameters

Example

See Also

mapPoints[2] mapVectors[2]


Returns Point (x, y) multiplied by Matrix. Given:

result is computed as:

Parameters

Return Value

mapped Point

Example

See Also

mapPoints[2] mapVectors[2]


Maps src Vector array of length count to Vector Point array of equal or greater length. Vectors are mapped by multiplying each Vector by Matrix, treating Matrix translation as zero. Given:

where

each dst Vector is computed as:

src and dst may point to the same storage.

Parameters

Example

See Also

mapVector[2] mapPoints[2] mapXY[2]


Maps vecs Vector array of length count in place, multiplying each Vector by Matrix, treating Matrix translation as zero. Given:

where

each result Vector is computed as:

Parameters

Example

See Also

mapVector[2] mapPoints[2] mapXY[2]


Maps Vector (x, y) to result. Vector is mapped by multiplying by Matrix, treating Matrix translation as zero. Given:

each result Vector is computed as:

Parameters

Example

See Also

mapVectors[2] mapPoints[2] mapXY[2]


Returns Vector (x, y) multiplied by Matrix, treating Matrix translation as zero. Given:

each result Vector is computed as:

Parameters

Return Value

mapped Vector

Example

See Also

mapVectors[2] mapPoints[2] mapXY[2]


Sets dst to bounds of src corners mapped by Matrix. Returns true if mapped corners are dst corners.

Returned value is the same as calling rectStaysRect.

Parameters

Return Value

true if dst is equivalent to mapped src

Example

See Also

mapPoints[2] rectStaysRect


Sets rect to bounds of rect corners mapped by Matrix. Returns true if mapped corners are computed rect corners.

Returned value is the same as calling rectStaysRect.

Parameters

Return Value

true if result is equivalent to mapped src

Example

See Also

mapRectScaleTranslate mapPoints[2] rectStaysRect


Returns bounds of src corners mapped by Matrix.

Parameters

Return Value

mapped bounds

Example

See Also

mapRectToQuad mapRectScaleTranslate


Maps four corners of rect to dst. Points are mapped by multiplying each rect corner by Matrix. rect corner is processed in this order: (rect.fLeft, rect.fTop), (rect.fRight, rect.fTop), (rect.fRight, rect.fBottom), (rect.fLeft, rect.fBottom).

rect may be empty: rect.fLeft may be greater than or equal to rect.fRight; rect.fTop may be greater than or equal to rect.fBottom.

Given:

where pt is initialized from each of (rect.fLeft, rect.fTop), (rect.fRight, rect.fTop), (rect.fRight, rect.fBottom), (rect.fLeft, rect.fBottom), each dst Point is computed as:

Parameters

Example

See Also

mapRect[2][3] mapRectScaleTranslate


Sets dst to bounds of src corners mapped by Matrix. If matrix contains elements other than scale or translate: asserts if SK_DEBUG is defined; otherwise, results are undefined.

Parameters

Example

See Also

mapRect[2][3] mapRectToQuad isScaleTranslate rectStaysRect


Returns geometric mean radius of ellipse formed by constructing Circle of size radius, and mapping constructed Circle with Matrix. The result squared is equal to the major axis length times the minor axis length. Result is not meaningful if Matrix contains perspective elements.

Parameters

Return Value

average mapped radius

Example

See Also

mapVector[2]


Returns true if a unit step on x-axis at some y-axis value mapped through Matrix can be represented by a constant Vector. Returns true if getType returns kIdentity Mask, or combinations of: kTranslate Mask, kScale Mask, and kAffine Mask.

May return true if getType returns kPerspective Mask, but only when Matrix does not include rotation or skewing along the y-axis.

Return Value

true if Matrix does not have complex perspective

Example

Example Output

[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
isFixedStepInX: true
[  1.0000   0.0000   0.0000][  0.0000   2.0000   0.0000][  0.0000   0.0000   1.0000]
isFixedStepInX: true
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.0000   0.1000   1.0000]
isFixedStepInX: true
[  1.0000   0.0000   0.0000][  0.0000   2.0000   0.0000][  0.0000   0.1000   1.0000]
isFixedStepInX: true
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.1000   0.0000   1.0000]
isFixedStepInX: false
[  1.0000   0.0000   0.0000][  0.0000   2.0000   0.0000][  0.1000   0.0000   1.0000]
isFixedStepInX: false
[  1.0000   0.0000   0.0000][  0.0000   1.0000   0.0000][  0.1000   0.1000   1.0000]
isFixedStepInX: false
[  1.0000   0.0000   0.0000][  0.0000   2.0000   0.0000][  0.1000   0.1000   1.0000]
isFixedStepInX: false

See Also

fixedStepInX getType


Returns Vector representing a unit step on x-axis at y mapped through Matrix. If isFixedStepInX is false, returned value is undefined.

Parameters

Return Value

Vector advance of mapped unit step on x-axis

Example

See Also

isFixedStepInX getType


Returns true if Matrix equals m, using an efficient comparison.

Returns false when the sign of zero values is the different; when one matrix has positive zero value and the other has negative zero value.

Returns true even when both Matrices contain NaN.

NaN never equals any value, including itself. To improve performance, NaN values are treated as bit patterns that are equal if their bit patterns are equal.

Parameters

Return Value

true if m and Matrix are represented by identical bit patterns

Example

Example Output

identity: a == b a.cheapEqualTo(b): true
neg zero: a == b a.cheapEqualTo(b): false
one NaN: a != b a.cheapEqualTo(b): false
both NaN: a != b a.cheapEqualTo(b): true

See Also

operator==(const SkMatrix& a, const SkMatrix& b)


Compares a and b; returns true if a and b are numerically equal. Returns true even if sign of zero values are different. Returns false if either Matrix contains NaN, even if the other Matrix also contains NaN.

Parameters

Return Value

true if Matrix a and Matrix b are numerically equal

Example

Example Output

identity: a == b a.cheapEqualTo(b): true

See Also

cheapEqualTo operator!=(const SkMatrix& a, const SkMatrix& b)


Compares a and b; returns true if a and b are not numerically equal. Returns false even if sign of zero values are different. Returns true if either Matrix contains NaN, even if the other Matrix also contains NaN.

Parameters

Return Value

true if Matrix a and Matrix b are numerically not equal

Example

See Also

cheapEqualTo operator==(const SkMatrix& a, const SkMatrix& b)


Writes text representation of Matrix to standard output. Floating point values are written with limited precision; it may not be possible to reconstruct original Matrix from output.

Example

Example Output

[  0.7071  -0.7071   0.0000][  0.7071   0.7071   0.0000][  0.0000   0.0000   1.0000]
[  0.7071  -0.7071   0.0000][  0.7071   0.7071   0.0000][  0.0000   0.0000   1.0000]
matrix != nearlyEqual

See Also

SkPath::dump[2]


Returns the minimum scaling factor of Matrix by decomposing the scaling and skewing elements. Returns -1 if scale factor overflows or Matrix contains perspective.

Return Value

minimum scale factor

Example

Example Output

matrix.getMinScale() 24

See Also

getMaxScale getMinMaxScales


Returns the maximum scaling factor of Matrix by decomposing the scaling and skewing elements. Returns -1 if scale factor overflows or Matrix contains perspective.

Return Value

maximum scale factor

Example

Example Output

matrix.getMaxScale() 42

See Also

getMinScale getMinMaxScales


Sets scaleFactors[0] to the minimum scaling factor, and scaleFactors[1] to the maximum scaling factor. Scaling factors are computed by decomposing the Matrix scaling and skewing elements.

Returns true if scaleFactors are found; otherwise, returns false and sets scaleFactors to undefined values.

Parameters

Return Value

true if scale factors were computed correctly

Example

Example Output

matrix.getMinMaxScales() false 2 2

See Also

getMinScale getMaxScale


Decomposes Matrix into scale components and whatever remains. Returns false if Matrix could not be decomposed.

Sets scale to portion of Matrix that scale axes. Sets remaining to Matrix with scaling factored out. remaining may be passed as nullptr to determine if Matrix can be decomposed without computing remainder.

Returns true if scale components are found. scale and remaining are unchanged if Matrix contains perspective; scale factors are not finite, or are nearly zero.

On success: Matrix = scale * Remaining.

Parameters

Return Value

true if scale can be computed

Example

Example Output

[  0.0000  -0.2500   0.0000][  0.5000   0.0000   0.0000][  0.0000   0.0000   1.0000]
success: true  scale: 0.5, 0.25
[  0.0000  -0.5000   0.0000][  2.0000   0.0000   0.0000][  0.0000   0.0000   1.0000]
[  0.0000  -0.2500   0.0000][  0.5000   0.0000   0.0000][  0.0000   0.0000   1.0000]

See Also

setScale[2] MakeScale[2]


Returns reference to const identity Matrix. Returned Matrix is set to:

Return Value

const identity Matrix

Example

Example Output

m1 == m2
m2 == m3

See Also

reset() setIdentity


Returns reference to a const Matrix with invalid values. Returned Matrix is set to:

Return Value

const invalid Matrix

Example

Example Output

scaleX 3.40282e+38

See Also

SeeAlso getType


Returns Matrix a multiplied by Matrix b.

Given:

sets Matrix to:

Parameters

Return Value

Matrix computed from a times b

Example

See Also

preConcat postConcat


Sets internal cache to unknown state. Use to force update after repeated modifications to Matrix element reference returned by operator[](int index).

Example

Example Output

with identity matrix: x = 24
after skew x mod:     x = 24
after 2nd skew x mod: x = 24
after dirty cache:    x = 66

See Also

operator[](int index) getType


Initializes Matrix with scale and translate elements.

Parameters

Example

Example Output

[  1.0000   0.0000   3.0000][  0.0000   2.0000   4.0000][  0.0000   0.0000   1.0000]

See Also

setScale[2] preTranslate postTranslate


Returns true if all elements of the matrix are finite. Returns false if any element is infinity, or NaN.

Return Value

true if matrix has only finite elements

Example

Example Output

[  1.0000   0.0000      nan][  0.0000   1.0000   0.0000][  0.0000   0.0000   1.0000]
matrix is finite: false
matrix != matrix

See Also

operator==