name | description |
---|---|
Constant | enum and enum class, const values |
Constructor | functions that construct SkMatrix |
Member Function | static functions and member methods |
Operator | operator overloading methods |
Related Function | similar methods grouped together |
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.
name | description |
---|---|
Concat | returns the concatenation of Matrix pair |
I | returns a reference to a const identity Matrix |
InvalidMatrix | returns a reference to a const invalid Matrix |
MakeAll | constructs all nine values |
MakeRectToRect | constructs from source Rect to destination Rect |
MakeScale | constructs from scale in x and y |
MakeTrans | constructs from translate in x and y |
SetAffineIdentity | sets 3x2 array to identity |
asAffine | copies to 3x2 array |
cheapEqualTo | compares Matrix pair using memcmp() |
decomposeScale | separates scale if possible |
dirtyMatrixTypeCache | sets internal cache to unknown state |
dump | sends text representation using floats to standard output |
fixedStepInX | returns step in x for a position in y |
get | returns one of nine Matrix values |
get9 | returns all nine Matrix values |
getMaxScale | returns maximum scaling, if possible |
getMinMaxScales | returns minimum and maximum scaling, if possible |
getMinScale | returns minimum scaling, if possible |
getPerspX | returns input x perspective factor |
getPerspY | returns input y perspective factor |
getScaleX | returns horizontal scale factor |
getScaleY | returns vertical scale factor |
getSkewX | returns horizontal skew factor |
getSkewY | returns vertical skew factor |
getTranslateX | returns horizontal translation |
getTranslateY | returns vertical translation |
getType | returns transform complexity |
hasPerspective | returns if transform includes perspective |
invert | returns inverse, if possible |
isFinite | returns if all Matrix values are not infinity, NaN |
isFixedStepInX | returns if transformation supports fixed step in x |
isIdentity | returns if matrix equals the identity Matrix |
isScaleTranslate | returns if transform is limited to scale and translate |
isSimilarity | returns if transform is limited to square scale and rotation |
isTranslate | returns if transform is limited to translate |
mapHomogeneousPoints | maps Point3 array |
mapPoints | maps Point array |
mapRadius | returns mean radius of mapped Circle |
mapRect | returns bounds of mapped Rect |
mapRectScaleTranslate | returns bounds of mapped Rect |
mapRectToQuad | maps Rect to Point array |
mapVector | maps Vector |
mapVectors | maps Vector array |
mapXY | maps Point |
postConcat | post-multiplies Matrix by Matrix parameter |
postIDiv | post-multiplies Matrix by inverse scale |
postRotate | post-multiplies Matrix by rotation |
postScale | post-multiplies Matrix by scale |
postSkew | post-multiplies Matrix by skew |
postTranslate | post-multiplies Matrix by translation |
preConcat | pre-multiplies Matrix by Matrix parameter |
preRotate | pre-multiplies Matrix by rotation |
preScale | pre-multiplies Matrix by scale |
preSkew | pre-multiplies Matrix by skew |
preTranslate | pre-multiplies Matrix by translation |
preservesAxisAlignment | returns if mapping restricts to 90 degree multiples and mirroring |
preservesRightAngles | returns if mapped 90 angle remains 90 degrees |
rectStaysRect | returns if mapped Rect can be represented by another Rect |
reset | sets Matrix to identity |
set | sets one value |
set9 | sets all values from Scalar array |
setAffine | sets left two columns |
setAll | sets all values from parameters |
setConcat | sets to Matrix parameter multiplied by Matrix parameter |
setIdentity | sets Matrix to identity |
setPerspX | sets input x perspective factor |
setPerspY | sets input y perspective factor |
setPolyToPoly | sets to map one to four points to an equal array of points |
setRSXform | sets to rotate, scale, and translate |
setRectToRect | sets to map one Rect to another |
setRotate | sets to rotate about a point |
setScale | sets to scale about a point |
setScaleTranslate | sets to scale and translate |
setScaleX | sets horizontal scale factor |
setScaleY | sets vertical scale factor |
setSinCos | sets to rotate and scale about a point |
setSkew | sets to skew about a point |
setSkewX | sets horizontal skew factor |
setSkewY | sets vertical skew factor |
setTranslate | sets to translate in x and y |
setTranslateX | sets horizontal translation |
setTranslateY | sets vertical translation |
toString | converts Matrix to machine readable form |
name | description |
---|---|
Property | values and attributes |
Set | set one or more matrix values |
Transform | map points with Matrix |
Utility | rarely called management functions |
name | description |
---|---|
I | returns a reference to a const identity Matrix |
InvalidMatrix | returns a reference to a const invalid Matrix |
MakeAll | constructs all nine values |
MakeRectToRect | constructs from source Rect to destination Rect |
MakeScale | constructs from scale in x and y |
MakeScale(SkScalar sx, SkScalar sy) | |
MakeScale(SkScalar scale) | |
MakeTrans | constructs from translate in x and y |
SetAffineIdentity | sets 3x2 array to identity |
asAffine | copies to 3x2 array |
reset | sets Matrix to identity |
setAffine | sets left two columns |
setConcat | sets to Matrix parameter multiplied by Matrix parameter |
setIdentity | sets Matrix to identity |
setRSXform | sets to rotate, scale, and translate |
setRotate | sets to rotate about a point |
setRotate(SkScalar degrees, SkScalar px, SkScalar py) | |
setRotate(SkScalar degrees) | |
setScale | sets to scale about a point |
setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) | |
setScale(SkScalar sx, SkScalar sy) | |
setScaleTranslate | sets to scale and translate |
setSinCos | sets to rotate and scale about a point |
setSinCos(SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py) | |
setSinCos(SkScalar sinValue, SkScalar cosValue) | |
setSkew | sets to skew about a point |
setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) | |
setSkew(SkScalar kx, SkScalar ky) | |
setTranslate | sets to translate in x and y |
setTranslate(SkScalar dx, SkScalar dy) | |
setTranslate(const SkVector& v) |
Sets Matrix to scale by (sx, sy). Returned matrix is:
Matrix with scale
setScale[2] postScale[2] preScale[2]
Sets Matrix to scale by (scale, scale). Returned matrix is:
Matrix with scale
setScale[2] postScale[2] preScale[2]
Sets Matrix to translate by (dx, dy). Returned matrix is:
Matrix with translation
setTranslate[2] postTranslate preTranslate
Sets Matrix to:
Matrix constructed from parameters
setAll set9 postConcat preConcat
Enum of bit fields for mask returned by getType. Used to identify the complexity of Matrix, to optimize performance.
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
getType
name | description |
---|---|
decomposeScale | separates scale if possible |
fixedStepInX | returns step in x for a position in y |
get | returns one of nine Matrix values |
get9 | returns all nine Matrix values |
getMaxScale | returns maximum scaling, if possible |
getMinMaxScales | returns minimum and maximum scaling, if possible |
getMinScale | returns minimum scaling, if possible |
getPerspX | returns input x perspective factor |
getPerspY | returns input y perspective factor |
getScaleX | returns horizontal scale factor |
getScaleY | returns vertical scale factor |
getSkewX | returns horizontal skew factor |
getSkewY | returns vertical skew factor |
getTranslateX | returns horizontal translation |
getTranslateY | returns vertical translation |
getType | returns transform complexity |
hasPerspective | returns if transform includes perspective |
isFinite | returns if all Matrix values are not infinity, NaN |
isFixedStepInX | returns if transformation supports fixed step in x |
isIdentity | returns if matrix equals the identity Matrix |
isScaleTranslate | returns if transform is limited to scale and translate |
isSimilarity | returns if transform is limited to square scale and rotation |
isTranslate | returns if transform is limited to translate |
preservesAxisAlignment | returns if mapping restricts to 90 degree multiples and mirroring |
preservesRightAngles | returns if mapped 90 angle remains 90 degrees |
rectStaysRect | returns if mapped Rect can be represented by another Rect |
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.
kIdentity Mask, or combinations of: kTranslate Mask, kScale Mask, kAffine Mask, kPerspective Mask
identity flags hex: 0 decimal: 0 set all flags hex: f decimal: 15
TypeMask
Returns true if Matrix is identity. Identity matrix is:
true if Matrix has no effect
is identity: true is identity: false
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:
true if Matrix is identity; or scales, translates, or both
is scale-translate: true is scale-translate: true is scale-translate: true is scale-translate: true
setScale[2] isTranslate setTranslate[2] getType
Returns true if Matrix is identity, or translates. Matrix form is:
true if Matrix is identity, or translates
is translate: true is translate: true is translate: false is translate: false
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 in x or y. 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.
true if Matrix maps one Rect into another
rectStaysRect: true rectStaysRect: true rectStaysRect: true rectStaysRect: true
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 in x or y. 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.
true if Matrix maps one Rect into another
preservesAxisAlignment: true preservesAxisAlignment: true preservesAxisAlignment: true preservesAxisAlignment: true
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.
true if Matrix is in most general form
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.
true if Matrix only rotates, uniformly scales, translates
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.
true if Matrix only rotates, scales, translates
isScaleTranslate isSimilarity rectStaysRect isFixedStepInX
Matrix organizes its values in row order. These members correspond to each value in Matrix.
get set
Affine arrays are in column major order to match the matrix used by PDF and XPS.
SetAffineIdentity asAffine setAffine
name | description |
---|---|
Concat | returns the concatenation of Matrix pair |
cheapEqualTo | compares Matrix pair using memcmp() |
invert | returns inverse, if possible |
operator!=(const SkMatrix& a, const SkMatrix& b) | returns true if members are unequal |
operator==(const SkMatrix& a, const SkMatrix& b) | returns true if members are equal |
operator[](int index) | returns writable reference to Matrix value |
operator[](int index) const | returns Matrix value |
Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.
value corresponding to index
matrix[SkMatrix::kMScaleX] == 42 matrix[SkMatrix::kMScaleY] == 24
get set
Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined.
value corresponding to index
matrix.get(SkMatrix::kMSkewX) == 42 matrix.get(SkMatrix::kMSkewY) == 24
operator[](int index) set
Returns scale factor multiplied by x input, contributing to x output. With mapPoints, scales Points along the x-axis.
horizontal scale factor
matrix.getScaleX() == 42
get getScaleY setScaleX setScale[2]
Returns scale factor multiplied by y input, contributing to y output. With mapPoints, scales Points along the y-axis.
vertical scale factor
matrix.getScaleY() == 24
get getScaleX setScaleY setScale[2]
Returns scale factor multiplied by x input, contributing to y output. With mapPoints, skews Points along the y-axis. Skew x and y together can rotate Points.
vertical skew factor
matrix.getSkewY() == 24
get getSkewX setSkewY setSkew[2]
Returns scale factor multiplied by y input, contributing to x output. With mapPoints, skews Points along the x-axis. Skew x and y together can rotate Points.
horizontal scale factor
matrix.getSkewX() == 42
get getSkewY setSkewX setSkew[2]
Returns translation contributing to x output. With mapPoints, moves Points along the x-axis.
horizontal translation factor
matrix.getTranslateX() == 42
get getTranslateY setTranslateX setTranslate[2]
Returns translation contributing to y output. With mapPoints, moves Points along the y-axis.
vertical translation factor
matrix.getTranslateY() == 24
get getTranslateX setTranslateY setTranslate[2]
Returns factor scaling input x relative to input y.
input x perspective factor
kMPersp0 getPerspY
Returns factor scaling input y relative to input x.
input y perspective factor
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.
writable value corresponding to index
with identity matrix: x = 24 after skew x mod: x = 24 after 2nd skew x mod: x = 24 after dirty cache: x = 66
get dirtyMatrixTypeCache set
name | description |
---|---|
postConcat | post-multiplies Matrix by Matrix parameter |
postIDiv | post-multiplies Matrix by inverse scale |
postRotate | post-multiplies Matrix by rotation |
postRotate(SkScalar degrees, SkScalar px, SkScalar py) | |
postRotate(SkScalar degrees) | |
postScale | post-multiplies Matrix by scale |
postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) | |
postScale(SkScalar sx, SkScalar sy) | |
postSkew | post-multiplies Matrix by skew |
postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) | |
postSkew(SkScalar kx, SkScalar ky) | |
postTranslate | post-multiplies Matrix by translation |
preConcat | pre-multiplies Matrix by Matrix parameter |
preRotate | pre-multiplies Matrix by rotation |
preRotate(SkScalar degrees, SkScalar px, SkScalar py) | |
preRotate(SkScalar degrees) | |
preScale | pre-multiplies Matrix by scale |
preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) | |
preScale(SkScalar sx, SkScalar sy) | |
preSkew | pre-multiplies Matrix by skew |
preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) | |
preSkew(SkScalar kx, SkScalar ky) | |
preTranslate | pre-multiplies Matrix by translation |
set | sets one value |
set9 | sets all values from Scalar array |
setAll | sets all values from parameters |
setPerspX | sets input x perspective factor |
setPerspY | sets input y perspective factor |
setPolyToPoly | sets to map one to four points to an equal array of points |
setRectToRect | sets to map one Rect to another |
setScaleX | sets horizontal scale factor |
setScaleY | sets vertical scale factor |
setSkewX | sets horizontal skew factor |
setSkewY | sets vertical skew factor |
setTranslateX | sets horizontal translation |
setTranslateY | sets vertical translation |
Sets Matrix value. Asserts if index is out of range and SK_DEBUG is defined. Safer than operator[]; internal cache is always maintained.
with identity matrix: x = 24 after skew x mod: x = 24 after 2nd skew x mod: x = 66
operator[] get
Sets horizontal scale factor.
set setScale[2] setScaleY
Sets vertical scale factor.
set setScale[2] setScaleX
Sets vertical skew factor.
set setSkew[2] setSkewX
Sets horizontal skew factor.
set setSkew[2] setSkewX
Sets horizontal translation.
set setTranslate[2] setTranslateY
Sets vertical translation.
set setTranslate[2] setTranslateX
Sets input x perspective factor, which causes mapXY to vary input x inversely proportional to input y.
getPerspX set setAll set9 MakeAll
Sets input y perspective factor, which causes mapXY to vary input y inversely proportional to input x.
getPerspY set setAll set9 MakeAll
Sets all values from parameters. Sets matrix to:
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.
{4, 0, 3}, {0, 5, 4}, {0, 0, 1}
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.
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.
m.isIdentity(): true
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.
m.isIdentity(): true
isIdentity reset
Sets Matrix to translate by (dx, dy).
setTranslateX setTranslateY
Sets Matrix to translate by (v.fX, v.fY).
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.
setScaleX setScaleY MakeScale[2] preScale[2] postScale[2]
Sets Matrix to scale by sx and sy about at pivot point at (0, 0).
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.
setSinCos[2] preRotate[2] postRotate[2]
Sets Matrix to rotate by degrees about a pivot point at (0, 0). Positive degrees rotates clockwise.
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.
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.
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).
reference to Matrix
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.
setSkewX setSkewY preSkew[2] postSkew[2]
Sets Matrix to skew by kx and ky, about a pivot point at (0, 0).
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
true on successful scale
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:
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:
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:
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:
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:
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.
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:
true if Matrix can represent Rect mapping
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]
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:
Matrix mapping src to dst
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]
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.
true if Matrix was constructed successfully
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.
true if Matrix can be inverted
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.
ScaleX: 1 SkewY: 0 SkewX: 0 ScaleY: 1 TransX: 0 TransY: 0
setAffine asAffine
Fills affine in column major order. Sets affine to:
If Matrix contains perspective, returns false and leaves affine unchanged.
true if Matrix does not contain perspective
ScaleX: 2 SkewY: 5 SkewX: 3 ScaleY: 6 TransX: 4 TransY: 7
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:
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]
asAffine SetAffineIdentity
name | description |
---|---|
mapHomogeneousPoints | maps Point3 array |
mapPoints | maps Point array |
mapPoints(SkPoint dst[], const SkPoint src[], int count) const | |
mapPoints(SkPoint pts[], int count) const | |
mapRadius | returns mean radius of mapped Circle |
mapRect | returns bounds of mapped Rect |
mapRect(SkRect* dst, const SkRect& src) const | |
mapRect(SkRect* rect) const | |
mapRectScaleTranslate | returns bounds of mapped Rect |
mapRectToQuad | maps Rect to Point array |
mapVector | maps Vector |
mapVector(SkScalar dx, SkScalar dy, SkVector* result) const | |
mapVector(SkScalar dx, SkScalar dy) const | |
mapVectors | maps Vector array |
mapVectors(SkVector dst[], const SkVector src[], int count) const | |
mapVectors(SkVector vecs[], int count) const | |
mapXY | maps Point |
mapXY(SkScalar x, SkScalar y, SkPoint* result) const | |
mapXY(SkScalar x, SkScalar y) const |
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.
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:
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:
mapPoints[2] mapXY[2] mapVectors[2]
Maps Point (x, y) to result. Point is mapped by multiplying by Matrix. Given:
result is computed as:
mapPoints[2] mapVectors[2]
Returns Point (x, y) multiplied by Matrix. Given:
result is computed as:
mapped Point
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.
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:
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:
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:
mapped Vector
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.
true if dst is equivalent to mapped src
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.
true if result is equivalent to mapped src
mapRectScaleTranslate mapPoints[2] rectStaysRect
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:
mapRect[2] 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.
mapRect[2] 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.
average mapped radius
mapVector[2]
Returns true if a unit step in x at some y 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.
true if Matrix does not have complex perspective
[ 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
fixedStepInX getType
Returns Vector representing a unit step in x at y mapped through Matrix. If isFixedStepInX is false, returned value is undefined.
Vector advance of mapped unit step in x
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.
true if m and Matrix are represented by identical bit patterns
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
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.
true if Matrix a and Matrix b are numerically equal
identity: a == b a.cheapEqualTo(b): true
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.
true if Matrix a and Matrix b are numerically not equal
cheapEqualTo operator==(const SkMatrix& a, const SkMatrix& b)
name | description |
---|---|
dirtyMatrixTypeCache | sets internal cache to unknown state |
dump | sends text representation using floats to standard output |
toString | converts Matrix to machine readable form |
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.
[ 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
toString
Creates string representation of Matrix. Floating point values are written with limited precision; it may not be possible to reconstruct original Matrix from output.
mStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] neStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] matrix != nearlyEqual
dump
Returns the minimum scaling factor of Matrix by decomposing the scaling and skewing elements. Returns -1 if scale factor overflows or Matrix contains perspective.
minimum scale factor
matrix.getMinScale() 24
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.
maximum scale factor
matrix.getMaxScale() 42
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.
true if scale factors were computed correctly
matrix.getMinMaxScales() false 2 2
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 scales in x and y. Sets remaining to Matrix with x and y 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 successMatrix = scale * Remaining
true if scale can be computed
[ 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]
setScale[2] MakeScale[2]
Returns reference to const identity Matrix. Returned Matrix is set to:
const identity Matrix
m1 == m2 m2 == m3
reset setIdentity
Returns reference to a const Matrix with invalid values. Returned Matrix is set to:
const invalid Matrix
scaleX 3.40282e+38
SeeAlso getType
Returns Matrix a multiplied by Matrix b.
Given:
sets Matrix to:
Matrix computed from a times b
preConcat postConcat
Sets internal cache to unknown state. Use to force update after repeated modifications to Matrix element reference returned by operator[](int index).
with identity matrix: x = 24 after skew x mod: x = 24 after 2nd skew x mod: x = 24 after dirty cache: x = 66
operator[](int index) getType
Initializes Matrix with scale and translate elements.
[ 1.0000 0.0000 3.0000][ 0.0000 2.0000 4.0000][ 0.0000 0.0000 1.0000]
setScale[2] preTranslate postTranslate
Returns true if all elements of the matrix are finite. Returns false if any element is infinity, or NaN.
true if matrix has only finite elements
[ 1.0000 0.0000 nan][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] matrix is finite: false matrix != matrix
operator==