1SkMatrix Reference 2=== 3 4# <a name="Matrix"></a> Matrix 5 6## <a name="Overview"></a> Overview 7 8## <a name="Overview_Subtopic"></a> Overview Subtopic 9 10| name | description | 11| --- | --- | 12| Constant | enum and enum class, const values | 13| <a href="#Constructor">Constructor</a> | functions that construct <a href="#SkMatrix">SkMatrix</a> | 14| <a href="#Member_Function">Member Function</a> | static functions and member methods | 15| <a href="#Operator">Operator</a> | operator overloading methods | 16| <a href="#Related_Function">Related Function</a> | similar methods grouped together | 17 18# <a name="SkMatrix"></a> Class SkMatrix 19<a href="#Matrix">Matrix</a> holds a 3x3 matrix for transforming coordinates. This allows mapping 20<a href="SkPoint_Reference#Point">Points</a> and <a href="SkPoint_Reference#Vector">Vectors</a> with translation, scaling, skewing, rotation, and 21perspective. 22 23<a href="#Matrix">Matrix</a> elements are in row major order. <a href="#Matrix">Matrix</a> does not have a constructor, 24so it must be explicitly initialized. <a href="#SkMatrix_setIdentity">setIdentity</a> initializes <a href="#Matrix">Matrix</a> 25so it has no effect. <a href="#SkMatrix_setTranslate">setTranslate</a>, <a href="#SkMatrix_setScale">setScale</a>, <a href="#SkMatrix_setSkew">setSkew</a>, <a href="#SkMatrix_setRotate">setRotate</a>, <a href="#SkMatrix_set9">set9</a> and <a href="#SkMatrix_setAll">setAll</a> 26initializes all <a href="#Matrix">Matrix</a> elements with the corresponding mapping. 27 28<a href="#Matrix">Matrix</a> includes a hidden variable that classifies the type of matrix to 29improve performance. <a href="#Matrix">Matrix</a> is not thread safe unless <a href="#SkMatrix_getType">getType</a> is called first. 30 31## <a name="Member_Function"></a> Member Function 32 33| name | description | 34| --- | --- | 35| <a href="#SkMatrix_Concat">Concat</a> | returns the concatenation of <a href="#Matrix">Matrix</a> pair | 36| I | returns a reference to a const identity <a href="#Matrix">Matrix</a> | 37| <a href="#SkMatrix_InvalidMatrix">InvalidMatrix</a> | returns a reference to a const invalid <a href="#Matrix">Matrix</a> | 38| <a href="#SkMatrix_MakeAll">MakeAll</a> | constructs all nine values | 39| <a href="#SkMatrix_MakeRectToRect">MakeRectToRect</a> | constructs from source <a href="SkRect_Reference#Rect">Rect</a> to destination <a href="SkRect_Reference#Rect">Rect</a> | 40| <a href="#SkMatrix_MakeScale">MakeScale</a> | constructs from scale in x and y | 41| <a href="#SkMatrix_MakeTrans">MakeTrans</a> | constructs from translate in x and y | 42| <a href="#SkMatrix_SetAffineIdentity">SetAffineIdentity</a> | sets 3x2 array to identity | 43| <a href="#SkMatrix_asAffine">asAffine</a> | copies to 3x2 array | 44| <a href="#SkMatrix_cheapEqualTo">cheapEqualTo</a> | compares <a href="#Matrix">Matrix</a> pair using memcmp() | 45| <a href="#SkMatrix_decomposeScale">decomposeScale</a> | separates scale if possible | 46| <a href="#SkMatrix_dirtyMatrixTypeCache">dirtyMatrixTypeCache</a> | sets internal cache to unknown state | 47| <a href="#SkMatrix_dump">dump</a> | sends text representation using floats to standard output | 48| <a href="#SkMatrix_fixedStepInX">fixedStepInX</a> | returns step in x for a position in y | 49| <a href="#SkMatrix_get">get</a> | returns one of nine <a href="#Matrix">Matrix</a> values | 50| <a href="#SkMatrix_get9">get9</a> | returns all nine <a href="#Matrix">Matrix</a> values | 51| <a href="#SkMatrix_getMaxScale">getMaxScale</a> | returns maximum scaling, if possible | 52| <a href="#SkMatrix_getMinMaxScales">getMinMaxScales</a> | returns minimum and maximum scaling, if possible | 53| <a href="#SkMatrix_getMinScale">getMinScale</a> | returns minimum scaling, if possible | 54| <a href="#SkMatrix_getPerspX">getPerspX</a> | returns input x perspective factor | 55| <a href="#SkMatrix_getPerspY">getPerspY</a> | returns input y perspective factor | 56| <a href="#SkMatrix_getScaleX">getScaleX</a> | returns horizontal scale factor | 57| <a href="#SkMatrix_getScaleY">getScaleY</a> | returns vertical scale factor | 58| <a href="#SkMatrix_getSkewX">getSkewX</a> | returns horizontal skew factor | 59| <a href="#SkMatrix_getSkewY">getSkewY</a> | returns vertical skew factor | 60| <a href="#SkMatrix_getTranslateX">getTranslateX</a> | returns horizontal translation | 61| <a href="#SkMatrix_getTranslateY">getTranslateY</a> | returns vertical translation | 62| <a href="#SkMatrix_getType">getType</a> | returns transform complexity | 63| <a href="#SkMatrix_hasPerspective">hasPerspective</a> | returns if transform includes perspective | 64| <a href="#SkMatrix_invert">invert</a> | returns inverse, if possible | 65| <a href="#SkMatrix_isFinite">isFinite</a> | returns if all <a href="#Matrix">Matrix</a> values are not infinity, NaN | 66| <a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> | returns if transformation supports fixed step in x | 67| <a href="#SkMatrix_isIdentity">isIdentity</a> | returns if matrix equals the identity <a href="#Matrix">Matrix</a> | 68| <a href="#SkMatrix_isScaleTranslate">isScaleTranslate</a> | returns if transform is limited to scale and translate | 69| <a href="#SkMatrix_isSimilarity">isSimilarity</a> | returns if transform is limited to square scale and rotation | 70| <a href="#SkMatrix_isTranslate">isTranslate</a> | returns if transform is limited to translate | 71| <a href="#SkMatrix_mapHomogeneousPoints">mapHomogeneousPoints</a> | maps <a href="undocumented#Point3">Point3</a> array | 72| <a href="#SkMatrix_mapPoints">mapPoints</a> | maps <a href="SkPoint_Reference#Point">Point</a> array | 73| <a href="#SkMatrix_mapRadius">mapRadius</a> | returns mean radius of mapped <a href="undocumented#Circle">Circle</a> | 74| <a href="#SkMatrix_mapRect">mapRect</a> | returns bounds of mapped <a href="SkRect_Reference#Rect">Rect</a> | 75| <a href="#SkMatrix_mapRectScaleTranslate">mapRectScaleTranslate</a> | returns bounds of mapped <a href="SkRect_Reference#Rect">Rect</a> | 76| <a href="#SkMatrix_mapRectToQuad">mapRectToQuad</a> | maps <a href="SkRect_Reference#Rect">Rect</a> to <a href="SkPoint_Reference#Point">Point</a> array | 77| <a href="#SkMatrix_mapVector">mapVector</a> | maps <a href="SkPoint_Reference#Vector">Vector</a> | 78| <a href="#SkMatrix_mapVectors">mapVectors</a> | maps <a href="SkPoint_Reference#Vector">Vector</a> array | 79| <a href="#SkMatrix_mapXY">mapXY</a> | maps <a href="SkPoint_Reference#Point">Point</a> | 80| <a href="#SkMatrix_postConcat">postConcat</a> | post-multiplies <a href="#Matrix">Matrix</a> by <a href="#Matrix">Matrix</a> parameter | 81| <a href="#SkMatrix_postIDiv">postIDiv</a> | post-multiplies <a href="#Matrix">Matrix</a> by inverse scale | 82| <a href="#SkMatrix_postRotate">postRotate</a> | post-multiplies <a href="#Matrix">Matrix</a> by rotation | 83| <a href="#SkMatrix_postScale">postScale</a> | post-multiplies <a href="#Matrix">Matrix</a> by scale | 84| <a href="#SkMatrix_postSkew">postSkew</a> | post-multiplies <a href="#Matrix">Matrix</a> by skew | 85| <a href="#SkMatrix_postTranslate">postTranslate</a> | post-multiplies <a href="#Matrix">Matrix</a> by translation | 86| <a href="#SkMatrix_preConcat">preConcat</a> | pre-multiplies <a href="#Matrix">Matrix</a> by <a href="#Matrix">Matrix</a> parameter | 87| <a href="#SkMatrix_preRotate">preRotate</a> | pre-multiplies <a href="#Matrix">Matrix</a> by rotation | 88| <a href="#SkMatrix_preScale">preScale</a> | pre-multiplies <a href="#Matrix">Matrix</a> by scale | 89| <a href="#SkMatrix_preSkew">preSkew</a> | pre-multiplies <a href="#Matrix">Matrix</a> by skew | 90| <a href="#SkMatrix_preTranslate">preTranslate</a> | pre-multiplies <a href="#Matrix">Matrix</a> by translation | 91| <a href="#SkMatrix_preservesAxisAlignment">preservesAxisAlignment</a> | returns if mapping restricts to 90 degree multiples and mirroring | 92| <a href="#SkMatrix_preservesRightAngles">preservesRightAngles</a> | returns if mapped 90 angle remains 90 degrees | 93| <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> | returns if mapped <a href="SkRect_Reference#Rect">Rect</a> can be represented by another <a href="SkRect_Reference#Rect">Rect</a> | 94| <a href="#SkMatrix_reset">reset</a> | sets <a href="#Matrix">Matrix</a> to identity | 95| <a href="#SkMatrix_set">set</a> | sets one value | 96| <a href="#SkMatrix_set9">set9</a> | sets all values from <a href="undocumented#Scalar">Scalar</a> array | 97| <a href="#SkMatrix_setAffine">setAffine</a> | sets left two columns | 98| <a href="#SkMatrix_setAll">setAll</a> | sets all values from parameters | 99| <a href="#SkMatrix_setConcat">setConcat</a> | sets to <a href="#Matrix">Matrix</a> parameter multiplied by <a href="#Matrix">Matrix</a> parameter | 100| <a href="#SkMatrix_setIdentity">setIdentity</a> | sets <a href="#Matrix">Matrix</a> to identity | 101| <a href="#SkMatrix_setPerspX">setPerspX</a> | sets input x perspective factor | 102| <a href="#SkMatrix_setPerspY">setPerspY</a> | sets input y perspective factor | 103| <a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> | sets to map one to four points to an equal array of points | 104| <a href="#SkMatrix_setRSXform">setRSXform</a> | sets to rotate, scale, and translate | 105| <a href="#SkMatrix_setRectToRect">setRectToRect</a> | sets to map one <a href="SkRect_Reference#Rect">Rect</a> to another | 106| <a href="#SkMatrix_setRotate">setRotate</a> | sets to rotate about a point | 107| <a href="#SkMatrix_setScale">setScale</a> | sets to scale about a point | 108| <a href="#SkMatrix_setScaleTranslate">setScaleTranslate</a> | sets to scale and translate | 109| <a href="#SkMatrix_setScaleX">setScaleX</a> | sets horizontal scale factor | 110| <a href="#SkMatrix_setScaleY">setScaleY</a> | sets vertical scale factor | 111| <a href="#SkMatrix_setSinCos">setSinCos</a> | sets to rotate and scale about a point | 112| <a href="#SkMatrix_setSkew">setSkew</a> | sets to skew about a point | 113| <a href="#SkMatrix_setSkewX">setSkewX</a> | sets horizontal skew factor | 114| <a href="#SkMatrix_setSkewY">setSkewY</a> | sets vertical skew factor | 115| <a href="#SkMatrix_setTranslate">setTranslate</a> | sets to translate in x and y | 116| <a href="#SkMatrix_setTranslateX">setTranslateX</a> | sets horizontal translation | 117| <a href="#SkMatrix_setTranslateY">setTranslateY</a> | sets vertical translation | 118| <a href="#SkMatrix_toString">toString</a> | converts <a href="#Matrix">Matrix</a> to machine readable form | 119 120## <a name="Related_Function"></a> Related Function 121 122| name | description | 123| --- | --- | 124| <a href="#Property">Property</a> | values and attributes | 125| <a href="#Set">Set</a> | set one or more matrix values | 126| <a href="#Transform">Transform</a> | map points with <a href="#Matrix">Matrix</a> | 127| <a href="#Utility">Utility</a> | rarely called management functions | 128 129## <a name="Constructor"></a> Constructor 130 131| name | description | 132| --- | --- | 133| I | returns a reference to a const identity <a href="#Matrix">Matrix</a> | 134| <a href="#SkMatrix_InvalidMatrix">InvalidMatrix</a> | returns a reference to a const invalid <a href="#Matrix">Matrix</a> | 135| <a href="#SkMatrix_MakeAll">MakeAll</a> | constructs all nine values | 136| <a href="#SkMatrix_MakeRectToRect">MakeRectToRect</a> | constructs from source <a href="SkRect_Reference#Rect">Rect</a> to destination <a href="SkRect_Reference#Rect">Rect</a> | 137| <a href="#SkMatrix_MakeScale">MakeScale</a> | constructs from scale in x and y | 138| | <a href="#SkMatrix_MakeScale">MakeScale(SkScalar sx, SkScalar sy)</a> | 139| | <a href="#SkMatrix_MakeScale_2">MakeScale(SkScalar scale)</a> | 140| <a href="#SkMatrix_MakeTrans">MakeTrans</a> | constructs from translate in x and y | 141| <a href="#SkMatrix_SetAffineIdentity">SetAffineIdentity</a> | sets 3x2 array to identity | 142| <a href="#SkMatrix_asAffine">asAffine</a> | copies to 3x2 array | 143| <a href="#SkMatrix_reset">reset</a> | sets <a href="#Matrix">Matrix</a> to identity | 144| <a href="#SkMatrix_setAffine">setAffine</a> | sets left two columns | 145| <a href="#SkMatrix_setConcat">setConcat</a> | sets to <a href="#Matrix">Matrix</a> parameter multiplied by <a href="#Matrix">Matrix</a> parameter | 146| <a href="#SkMatrix_setIdentity">setIdentity</a> | sets <a href="#Matrix">Matrix</a> to identity | 147| <a href="#SkMatrix_setRSXform">setRSXform</a> | sets to rotate, scale, and translate | 148| <a href="#SkMatrix_setRotate">setRotate</a> | sets to rotate about a point | 149| | <a href="#SkMatrix_setRotate">setRotate(SkScalar degrees, SkScalar px, SkScalar py)</a> | 150| | <a href="#SkMatrix_setRotate_2">setRotate(SkScalar degrees)</a> | 151| <a href="#SkMatrix_setScale">setScale</a> | sets to scale about a point | 152| | <a href="#SkMatrix_setScale">setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)</a> | 153| | <a href="#SkMatrix_setScale_2">setScale(SkScalar sx, SkScalar sy)</a> | 154| <a href="#SkMatrix_setScaleTranslate">setScaleTranslate</a> | sets to scale and translate | 155| <a href="#SkMatrix_setSinCos">setSinCos</a> | sets to rotate and scale about a point | 156| | <a href="#SkMatrix_setSinCos">setSinCos(SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py)</a> | 157| | <a href="#SkMatrix_setSinCos_2">setSinCos(SkScalar sinValue, SkScalar cosValue)</a> | 158| <a href="#SkMatrix_setSkew">setSkew</a> | sets to skew about a point | 159| | <a href="#SkMatrix_setSkew">setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)</a> | 160| | <a href="#SkMatrix_setSkew_2">setSkew(SkScalar kx, SkScalar ky)</a> | 161| <a href="#SkMatrix_setTranslate">setTranslate</a> | sets to translate in x and y | 162| | <a href="#SkMatrix_setTranslate">setTranslate(SkScalar dx, SkScalar dy)</a> | 163| | <a href="#SkMatrix_setTranslate_2">setTranslate(const SkVector& v)</a> | 164 165<a name="SkMatrix_MakeScale"></a> 166## MakeScale 167 168<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 169static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar sx, SkScalar sy) 170</pre> 171 172Sets <a href="#Matrix">Matrix</a> to scale by (<a href="#SkMatrix_MakeScale_sx">sx</a>, <a href="#SkMatrix_MakeScale_sy">sy</a>). Returned matrix is: 173 174<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 175| sx 0 0 | 176| 0 sy 0 | 177| 0 0 1 |</pre> 178 179### Parameters 180 181<table> <tr> <td><a name="SkMatrix_MakeScale_sx"> <code><strong>sx </strong></code> </a></td> <td> 182horizontal scale factor</td> 183 </tr> <tr> <td><a name="SkMatrix_MakeScale_sy"> <code><strong>sy </strong></code> </a></td> <td> 184vertical scale factor</td> 185 </tr> 186</table> 187 188### Return Value 189 190<a href="#Matrix">Matrix</a> with scale 191 192### Example 193 194<div><fiddle-embed name="7ff17718111df6d6f95381d8a8f1b389"></fiddle-embed></div> 195 196### See Also 197 198<a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> <a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> 199 200--- 201 202<a name="SkMatrix_MakeScale_2"></a> 203 204<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 205static SkMatrix SK_WARN_UNUSED_RESULT MakeScale(SkScalar scale) 206</pre> 207 208Sets <a href="#Matrix">Matrix</a> to <a href="#SkMatrix_MakeScale_2_scale">scale</a> by (<a href="#SkMatrix_MakeScale_2_scale">scale</a>, <a href="#SkMatrix_MakeScale_2_scale">scale</a>). Returned matrix is: 209 210<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 211| scale 0 0 | 212| 0 scale 0 | 213| 0 0 1 |</pre> 214 215### Parameters 216 217<table> <tr> <td><a name="SkMatrix_MakeScale_2_scale"> <code><strong>scale </strong></code> </a></td> <td> 218horizontal and vertical <a href="#SkMatrix_MakeScale_2_scale">scale</a> factor</td> 219 </tr> 220</table> 221 222### Return Value 223 224<a href="#Matrix">Matrix</a> with <a href="#SkMatrix_MakeScale_2_scale">scale</a> 225 226### Example 227 228<div><fiddle-embed name="2956aeb50fa862cdb13995e1e56a4bc8"></fiddle-embed></div> 229 230### See Also 231 232<a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> <a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> 233 234--- 235 236<a name="SkMatrix_MakeTrans"></a> 237## MakeTrans 238 239<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 240static SkMatrix SK_WARN_UNUSED_RESULT MakeTrans(SkScalar dx, SkScalar dy) 241</pre> 242 243Sets <a href="#Matrix">Matrix</a> to translate by (<a href="#SkMatrix_MakeTrans_dx">dx</a>, <a href="#SkMatrix_MakeTrans_dy">dy</a>). Returned matrix is: 244 245<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 246| 1 0 dx | 247| 0 1 dy | 248| 0 0 1 |</pre> 249 250### Parameters 251 252<table> <tr> <td><a name="SkMatrix_MakeTrans_dx"> <code><strong>dx </strong></code> </a></td> <td> 253horizontal translation</td> 254 </tr> <tr> <td><a name="SkMatrix_MakeTrans_dy"> <code><strong>dy </strong></code> </a></td> <td> 255vertical translation</td> 256 </tr> 257</table> 258 259### Return Value 260 261<a href="#Matrix">Matrix</a> with translation 262 263### Example 264 265<div><fiddle-embed name="b2479df0d9cf296ff64ac31e36684557"></fiddle-embed></div> 266 267### See Also 268 269<a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_postTranslate">postTranslate</a> <a href="#SkMatrix_preTranslate">preTranslate</a> 270 271--- 272 273<a name="SkMatrix_MakeAll"></a> 274## MakeAll 275 276<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 277static SkMatrix SK_WARN_UNUSED_RESULT MakeAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, 278 SkScalar skewY, SkScalar scaleY, SkScalar transY, 279 SkScalar pers0, SkScalar pers1, SkScalar pers2) 280</pre> 281 282Sets <a href="#Matrix">Matrix</a> to: 283 284<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 285| scaleX skewX transX | 286| skewY scaleY transY | 287| pers0 pers1 pers2 |</pre> 288 289### Parameters 290 291<table> <tr> <td><a name="SkMatrix_MakeAll_scaleX"> <code><strong>scaleX </strong></code> </a></td> <td> 292horizontal scale factor</td> 293 </tr> <tr> <td><a name="SkMatrix_MakeAll_skewX"> <code><strong>skewX </strong></code> </a></td> <td> 294horizontal skew factor</td> 295 </tr> <tr> <td><a name="SkMatrix_MakeAll_transX"> <code><strong>transX </strong></code> </a></td> <td> 296horizontal translation</td> 297 </tr> <tr> <td><a name="SkMatrix_MakeAll_skewY"> <code><strong>skewY </strong></code> </a></td> <td> 298vertical skew factor</td> 299 </tr> <tr> <td><a name="SkMatrix_MakeAll_scaleY"> <code><strong>scaleY </strong></code> </a></td> <td> 300vertical scale factor</td> 301 </tr> <tr> <td><a name="SkMatrix_MakeAll_transY"> <code><strong>transY </strong></code> </a></td> <td> 302vertical translation</td> 303 </tr> <tr> <td><a name="SkMatrix_MakeAll_pers0"> <code><strong>pers0 </strong></code> </a></td> <td> 304input x perspective factor</td> 305 </tr> <tr> <td><a name="SkMatrix_MakeAll_pers1"> <code><strong>pers1 </strong></code> </a></td> <td> 306input y perspective factor</td> 307 </tr> <tr> <td><a name="SkMatrix_MakeAll_pers2"> <code><strong>pers2 </strong></code> </a></td> <td> 308perspective scale factor</td> 309 </tr> 310</table> 311 312### Return Value 313 314<a href="#Matrix">Matrix</a> constructed from parameters 315 316### Example 317 318<div><fiddle-embed name="6bad83b64de9266e323c29d550e04188"></fiddle-embed></div> 319 320### See Also 321 322<a href="#SkMatrix_setAll">setAll</a> <a href="#SkMatrix_set9">set9</a> <a href="#SkMatrix_postConcat">postConcat</a> <a href="#SkMatrix_preConcat">preConcat</a> 323 324--- 325 326## <a name="SkMatrix_TypeMask"></a> Enum SkMatrix::TypeMask 327 328<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 329enum <a href="#SkMatrix_TypeMask">TypeMask</a> { 330<a href="#SkMatrix_kIdentity_Mask">kIdentity Mask</a> = 0, 331<a href="#SkMatrix_kTranslate_Mask">kTranslate Mask</a> = 0x01, 332<a href="#SkMatrix_kScale_Mask">kScale Mask</a> = 0x02, 333<a href="#SkMatrix_kAffine_Mask">kAffine Mask</a> = 0x04, 334<a href="#SkMatrix_kPerspective_Mask">kPerspective Mask</a> = 0x08, 335};</pre> 336 337Enum of bit fields for mask returned by <a href="#SkMatrix_getType">getType</a>. 338Used to identify the complexity of <a href="#Matrix">Matrix</a>, to optimize performance. 339 340### Constants 341 342<table> 343 <tr> 344 <td><a name="SkMatrix_kIdentity_Mask"> <code><strong>SkMatrix::kIdentity_Mask </strong></code> </a></td><td>0</td><td>all bits clear if <a href="#Matrix">Matrix</a> is identity</td> 345 </tr> 346 <tr> 347 <td><a name="SkMatrix_kTranslate_Mask"> <code><strong>SkMatrix::kTranslate_Mask </strong></code> </a></td><td>1</td><td>set if <a href="#Matrix">Matrix</a> has translation</td> 348 </tr> 349 <tr> 350 <td><a name="SkMatrix_kScale_Mask"> <code><strong>SkMatrix::kScale_Mask </strong></code> </a></td><td>2</td><td>set if <a href="#Matrix">Matrix</a> has x or y scale</td> 351 </tr> 352 <tr> 353 <td><a name="SkMatrix_kAffine_Mask"> <code><strong>SkMatrix::kAffine_Mask </strong></code> </a></td><td>4</td><td>set if <a href="#Matrix">Matrix</a> skews or rotates</td> 354 </tr> 355 <tr> 356 <td><a name="SkMatrix_kPerspective_Mask"> <code><strong>SkMatrix::kPerspective_Mask </strong></code> </a></td><td>8</td><td>set if <a href="#Matrix">Matrix</a> has perspective</td> 357 </tr> 358</table> 359 360### Example 361 362<div><fiddle-embed name="ba19b36df8cd78586f3dff54e2d4c093"> 363 364#### Example Output 365 366~~~~ 367after reset: kIdentity_Mask 368after postTranslate: kTranslate_Mask 369after postScale: kTranslate_Mask kScale_Mask 370after postScale: kTranslate_Mask kScale_Mask kAffine_Mask 371after setPolyToPoly: kTranslate_Mask kScale_Mask kAffine_Mask kPerspective_Mask 372~~~~ 373 374</fiddle-embed></div> 375 376### See Also 377 378<a href="#SkMatrix_getType">getType</a> 379 380 381 382## <a name="Property"></a> Property 383 384| name | description | 385| --- | --- | 386| <a href="#SkMatrix_decomposeScale">decomposeScale</a> | separates scale if possible | 387| <a href="#SkMatrix_fixedStepInX">fixedStepInX</a> | returns step in x for a position in y | 388| <a href="#SkMatrix_get">get</a> | returns one of nine <a href="#Matrix">Matrix</a> values | 389| <a href="#SkMatrix_get9">get9</a> | returns all nine <a href="#Matrix">Matrix</a> values | 390| <a href="#SkMatrix_getMaxScale">getMaxScale</a> | returns maximum scaling, if possible | 391| <a href="#SkMatrix_getMinMaxScales">getMinMaxScales</a> | returns minimum and maximum scaling, if possible | 392| <a href="#SkMatrix_getMinScale">getMinScale</a> | returns minimum scaling, if possible | 393| <a href="#SkMatrix_getPerspX">getPerspX</a> | returns input x perspective factor | 394| <a href="#SkMatrix_getPerspY">getPerspY</a> | returns input y perspective factor | 395| <a href="#SkMatrix_getScaleX">getScaleX</a> | returns horizontal scale factor | 396| <a href="#SkMatrix_getScaleY">getScaleY</a> | returns vertical scale factor | 397| <a href="#SkMatrix_getSkewX">getSkewX</a> | returns horizontal skew factor | 398| <a href="#SkMatrix_getSkewY">getSkewY</a> | returns vertical skew factor | 399| <a href="#SkMatrix_getTranslateX">getTranslateX</a> | returns horizontal translation | 400| <a href="#SkMatrix_getTranslateY">getTranslateY</a> | returns vertical translation | 401| <a href="#SkMatrix_getType">getType</a> | returns transform complexity | 402| <a href="#SkMatrix_hasPerspective">hasPerspective</a> | returns if transform includes perspective | 403| <a href="#SkMatrix_isFinite">isFinite</a> | returns if all <a href="#Matrix">Matrix</a> values are not infinity, NaN | 404| <a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> | returns if transformation supports fixed step in x | 405| <a href="#SkMatrix_isIdentity">isIdentity</a> | returns if matrix equals the identity <a href="#Matrix">Matrix</a> | 406| <a href="#SkMatrix_isScaleTranslate">isScaleTranslate</a> | returns if transform is limited to scale and translate | 407| <a href="#SkMatrix_isSimilarity">isSimilarity</a> | returns if transform is limited to square scale and rotation | 408| <a href="#SkMatrix_isTranslate">isTranslate</a> | returns if transform is limited to translate | 409| <a href="#SkMatrix_preservesAxisAlignment">preservesAxisAlignment</a> | returns if mapping restricts to 90 degree multiples and mirroring | 410| <a href="#SkMatrix_preservesRightAngles">preservesRightAngles</a> | returns if mapped 90 angle remains 90 degrees | 411| <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> | returns if mapped <a href="SkRect_Reference#Rect">Rect</a> can be represented by another <a href="SkRect_Reference#Rect">Rect</a> | 412 413<a name="SkMatrix_getType"></a> 414## getType 415 416<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 417TypeMask getType() const 418</pre> 419 420Returns a bit field describing the transformations the matrix may 421perform. The bit field is computed conservatively, so it may include 422false positives. For example, when <a href="#SkMatrix_kPerspective_Mask">kPerspective Mask</a> is set, all 423other bits are set. 424 425### Return Value 426 427<a href="#SkMatrix_kIdentity_Mask">kIdentity Mask</a>, or combinations of: <a href="#SkMatrix_kTranslate_Mask">kTranslate Mask</a>, <a href="#SkMatrix_kScale_Mask">kScale Mask</a>, 428<a href="#SkMatrix_kAffine_Mask">kAffine Mask</a>, <a href="#SkMatrix_kPerspective_Mask">kPerspective Mask</a> 429 430### Example 431 432<div><fiddle-embed name="8e45fe2dd52731bb2d4318686257e1d7"> 433 434#### Example Output 435 436~~~~ 437identity flags hex: 0 decimal: 0 438set all flags hex: f decimal: 15 439~~~~ 440 441</fiddle-embed></div> 442 443### See Also 444 445<a href="#SkMatrix_TypeMask">TypeMask</a> 446 447--- 448 449<a name="SkMatrix_isIdentity"></a> 450## isIdentity 451 452<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 453bool isIdentity() const 454</pre> 455 456Returns true if <a href="#Matrix">Matrix</a> is identity. Identity matrix is: 457 458<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 459| 1 0 0 | 460| 0 1 0 | 461| 0 0 1 |</pre> 462 463### Return Value 464 465true if <a href="#Matrix">Matrix</a> has no effect 466 467### Example 468 469<div><fiddle-embed name="780ab376325b3cfa889ea26c0769ec11"> 470 471#### Example Output 472 473~~~~ 474is identity: true 475is identity: false 476~~~~ 477 478</fiddle-embed></div> 479 480### See Also 481 482<a href="#SkMatrix_reset">reset</a> <a href="#SkMatrix_setIdentity">setIdentity</a> <a href="#SkMatrix_getType">getType</a> 483 484--- 485 486<a name="SkMatrix_isScaleTranslate"></a> 487## isScaleTranslate 488 489<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 490bool isScaleTranslate() const 491</pre> 492 493Returns true if <a href="#Matrix">Matrix</a> at most scales and translates. <a href="#Matrix">Matrix</a> may be identity, 494contain only scale elements, only translate elements, or both. <a href="#Matrix">Matrix</a> form is: 495 496<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 497| scale-x 0 translate-x | 498| 0 scale-y translate-y | 499| 0 0 1 |</pre> 500 501### Return Value 502 503true if <a href="#Matrix">Matrix</a> is identity; or scales, translates, or both 504 505### Example 506 507<div><fiddle-embed name="6287e29674a487eb94174992d45b9a34"> 508 509#### Example Output 510 511~~~~ 512is scale-translate: true 513is scale-translate: true 514is scale-translate: true 515is scale-translate: true 516~~~~ 517 518</fiddle-embed></div> 519 520### See Also 521 522<a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_isTranslate">isTranslate</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_getType">getType</a> 523 524--- 525 526<a name="SkMatrix_isTranslate"></a> 527## isTranslate 528 529<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 530bool isTranslate() const 531</pre> 532 533Returns true if <a href="#Matrix">Matrix</a> is identity, or translates. <a href="#Matrix">Matrix</a> form is: 534 535<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 536| 1 0 translate-x | 537| 0 1 translate-y | 538| 0 0 1 |</pre> 539 540### Return Value 541 542true if <a href="#Matrix">Matrix</a> is identity, or translates 543 544### Example 545 546<div><fiddle-embed name="73ac71a8a30841873577c11c6c9b38ee"> 547 548#### Example Output 549 550~~~~ 551is translate: true 552is translate: true 553is translate: false 554is translate: false 555~~~~ 556 557</fiddle-embed></div> 558 559### See Also 560 561<a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_getType">getType</a> 562 563--- 564 565<a name="SkMatrix_rectStaysRect"></a> 566## rectStaysRect 567 568<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 569bool rectStaysRect() const 570</pre> 571 572Returns true <a href="#Matrix">Matrix</a> maps <a href="SkRect_Reference#Rect">Rect</a> to another <a href="SkRect_Reference#Rect">Rect</a>. If true, <a href="#Matrix">Matrix</a> is identity, 573or scales, or rotates a multiple of 90 degrees, or mirrors in x or y. In all 574cases, <a href="#Matrix">Matrix</a> may also have translation. <a href="#Matrix">Matrix</a> form is either: 575 576<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 577| scale-x 0 translate-x | 578| 0 scale-y translate-y | 579| 0 0 1 |</pre> 580 581or 582 583<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 584| 0 rotate-x translate-x | 585| rotate-y 0 translate-y | 586| 0 0 1 |</pre> 587 588for non-zero values of scale-x, scale-y, rotate-x, and rotate-y. 589 590Also called <a href="#SkMatrix_preservesAxisAlignment">preservesAxisAlignment</a>; use the one that provides better inline 591documentation. 592 593### Return Value 594 595true if <a href="#Matrix">Matrix</a> maps one <a href="SkRect_Reference#Rect">Rect</a> into another 596 597### Example 598 599<div><fiddle-embed name="ce5319c036c9b5086da8a0009fe409f8"> 600 601#### Example Output 602 603~~~~ 604rectStaysRect: true 605rectStaysRect: true 606rectStaysRect: true 607rectStaysRect: true 608~~~~ 609 610</fiddle-embed></div> 611 612### See Also 613 614<a href="#SkMatrix_preservesAxisAlignment">preservesAxisAlignment</a> <a href="#SkMatrix_preservesRightAngles">preservesRightAngles</a> 615 616--- 617 618<a name="SkMatrix_preservesAxisAlignment"></a> 619## preservesAxisAlignment 620 621<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 622bool preservesAxisAlignment() const 623</pre> 624 625Returns true <a href="#Matrix">Matrix</a> maps <a href="SkRect_Reference#Rect">Rect</a> to another <a href="SkRect_Reference#Rect">Rect</a>. If true, <a href="#Matrix">Matrix</a> is identity, 626or scales, or rotates a multiple of 90 degrees, or mirrors in x or y. In all 627cases, <a href="#Matrix">Matrix</a> may also have translation. <a href="#Matrix">Matrix</a> form is either: 628 629<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 630| scale-x 0 translate-x | 631| 0 scale-y translate-y | 632| 0 0 1 |</pre> 633 634or 635 636<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 637| 0 rotate-x translate-x | 638| rotate-y 0 translate-y | 639| 0 0 1 |</pre> 640 641for non-zero values of scale-x, scale-y, rotate-x, and rotate-y. 642 643Also called <a href="#SkMatrix_rectStaysRect">rectStaysRect</a>; use the one that provides better inline 644documentation. 645 646### Return Value 647 648true if <a href="#Matrix">Matrix</a> maps one <a href="SkRect_Reference#Rect">Rect</a> into another 649 650### Example 651 652<div><fiddle-embed name="7a234c96608fb7cb8135b9940b0b15f7"> 653 654#### Example Output 655 656~~~~ 657preservesAxisAlignment: true 658preservesAxisAlignment: true 659preservesAxisAlignment: true 660preservesAxisAlignment: true 661~~~~ 662 663</fiddle-embed></div> 664 665### See Also 666 667<a href="#SkMatrix_rectStaysRect">rectStaysRect</a> <a href="#SkMatrix_preservesRightAngles">preservesRightAngles</a> 668 669--- 670 671<a name="SkMatrix_hasPerspective"></a> 672## hasPerspective 673 674<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 675bool hasPerspective() const 676</pre> 677 678Returns true if the matrix contains perspective elements. <a href="#Matrix">Matrix</a> form is: 679 680<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 681| -- -- -- | 682| -- -- -- | 683| perspective-x perspective-y perspective-scale |</pre> 684 685where perspective-x or perspective-y is non-zero, or perspective-scale is 686not one. All other elements may have any value. 687 688### Return Value 689 690true if <a href="#Matrix">Matrix</a> is in most general form 691 692### Example 693 694<div><fiddle-embed name="688123908c733169bbbfaf11f41ecff6"></fiddle-embed></div> 695 696### See Also 697 698<a href="#SkMatrix_setAll">setAll</a> <a href="#SkMatrix_set9">set9</a> <a href="#SkMatrix_MakeAll">MakeAll</a> 699 700--- 701 702<a name="SkMatrix_isSimilarity"></a> 703## isSimilarity 704 705<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 706bool isSimilarity(SkScalar tol = SK_ScalarNearlyZero) const 707</pre> 708 709Returns true if <a href="#Matrix">Matrix</a> contains only translation, rotation, reflection, and 710uniform scale. 711Returns false if <a href="#Matrix">Matrix</a> contains different scales, skewing, perspective, or 712degenerate forms that collapse to a line or point. 713 714Describes that the <a href="#Matrix">Matrix</a> makes rendering with and without the matrix are 715visually alike; a transformed circle remains a circle. Mathematically, this is 716referred to as similarity of a Euclidean_Space, or a similarity transformation. 717 718Preserves right angles, keeping the arms of the angle equal lengths. 719 720### Parameters 721 722<table> <tr> <td><a name="SkMatrix_isSimilarity_tol"> <code><strong>tol </strong></code> </a></td> <td> 723to be deprecated</td> 724 </tr> 725</table> 726 727### Return Value 728 729true if <a href="#Matrix">Matrix</a> only rotates, uniformly scales, translates 730 731### Example 732 733<div><fiddle-embed name="98d60230ad633ae74d851de3a65d72d6"><div><a href="undocumented#String">String</a> is drawn four times through but only two are visible. Drawing the pair 734with <a href="#SkMatrix_isSimilarity">isSimilarity</a> false reveals the pair not visible through the matrix.</div></fiddle-embed></div> 735 736### See Also 737 738<a href="#SkMatrix_isScaleTranslate">isScaleTranslate</a> <a href="#SkMatrix_preservesRightAngles">preservesRightAngles</a> <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> <a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> 739 740--- 741 742<a name="SkMatrix_preservesRightAngles"></a> 743## preservesRightAngles 744 745<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 746bool preservesRightAngles(SkScalar tol = SK_ScalarNearlyZero) const 747</pre> 748 749Returns true if <a href="#Matrix">Matrix</a> contains only translation, rotation, reflection, and 750scale. Scale may differ along rotated axes. 751Returns false if <a href="#Matrix">Matrix</a> skewing, perspective, or degenerate forms that collapse 752to a line or point. 753 754Preserves right angles, but not requiring that the arms of the angle 755retain equal lengths. 756 757### Parameters 758 759<table> <tr> <td><a name="SkMatrix_preservesRightAngles_tol"> <code><strong>tol </strong></code> </a></td> <td> 760to be deprecated</td> 761 </tr> 762</table> 763 764### Return Value 765 766true if <a href="#Matrix">Matrix</a> only rotates, scales, translates 767 768### Example 769 770<div><fiddle-embed name="a3d5bfebc1c3423fb983d30aaf4ac5f4"><div>Equal scale is both similar and preserves right angles. 771Unequal scale is not similar but preserves right angles. 772Skews are not similar and do not preserve right angles.</div></fiddle-embed></div> 773 774### See Also 775 776<a href="#SkMatrix_isScaleTranslate">isScaleTranslate</a> <a href="#SkMatrix_isSimilarity">isSimilarity</a> <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> <a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> 777 778--- 779 780## <a name="SkMatrix__anonymous"></a> Enum SkMatrix::_anonymous 781 782<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 783enum { 784<a href="#SkMatrix_kMScaleX">kMScaleX</a>, 785<a href="#SkMatrix_kMSkewX">kMSkewX</a>, 786<a href="#SkMatrix_kMTransX">kMTransX</a>, 787<a href="#SkMatrix_kMSkewY">kMSkewY</a>, 788<a href="#SkMatrix_kMScaleY">kMScaleY</a>, 789<a href="#SkMatrix_kMTransY">kMTransY</a>, 790<a href="#SkMatrix_kMPersp0">kMPersp0</a>, 791<a href="#SkMatrix_kMPersp1">kMPersp1</a>, 792<a href="#SkMatrix_kMPersp2">kMPersp2</a>, 793};</pre> 794 795<a href="#Matrix">Matrix</a> organizes its values in row order. These members correspond to 796each value in <a href="#Matrix">Matrix</a>. 797 798### Constants 799 800<table> 801 <tr> 802 <td><a name="SkMatrix_kMScaleX"> <code><strong>SkMatrix::kMScaleX </strong></code> </a></td><td>0</td><td>horizontal scale factor</td> 803 </tr> 804 <tr> 805 <td><a name="SkMatrix_kMSkewX"> <code><strong>SkMatrix::kMSkewX </strong></code> </a></td><td>1</td><td>horizontal skew factor</td> 806 </tr> 807 <tr> 808 <td><a name="SkMatrix_kMTransX"> <code><strong>SkMatrix::kMTransX </strong></code> </a></td><td>2</td><td>horizontal translation</td> 809 </tr> 810 <tr> 811 <td><a name="SkMatrix_kMSkewY"> <code><strong>SkMatrix::kMSkewY </strong></code> </a></td><td>3</td><td>vertical skew factor</td> 812 </tr> 813 <tr> 814 <td><a name="SkMatrix_kMScaleY"> <code><strong>SkMatrix::kMScaleY </strong></code> </a></td><td>4</td><td>vertical scale factor</td> 815 </tr> 816 <tr> 817 <td><a name="SkMatrix_kMTransY"> <code><strong>SkMatrix::kMTransY </strong></code> </a></td><td>5</td><td>vertical translation</td> 818 </tr> 819 <tr> 820 <td><a name="SkMatrix_kMPersp0"> <code><strong>SkMatrix::kMPersp0 </strong></code> </a></td><td>6</td><td>input x perspective factor</td> 821 </tr> 822 <tr> 823 <td><a name="SkMatrix_kMPersp1"> <code><strong>SkMatrix::kMPersp1 </strong></code> </a></td><td>7</td><td>input y perspective factor</td> 824 </tr> 825 <tr> 826 <td><a name="SkMatrix_kMPersp2"> <code><strong>SkMatrix::kMPersp2 </strong></code> </a></td><td>8</td><td>perspective bias</td> 827 </tr> 828</table> 829 830### Example 831 832<div><fiddle-embed name="3bbf75f4748420810aa2586e3c8548d9"></fiddle-embed></div> 833 834### See Also 835 836<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_set">set</a> 837 838 839 840## <a name="SkMatrix__anonymous_2"></a> Enum SkMatrix::_anonymous_2 841 842<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 843enum { 844<a href="#SkMatrix_kAScaleX">kAScaleX</a>, 845<a href="#SkMatrix_kASkewY">kASkewY</a>, 846<a href="#SkMatrix_kASkewX">kASkewX</a>, 847<a href="#SkMatrix_kAScaleY">kAScaleY</a>, 848<a href="#SkMatrix_kATransX">kATransX</a>, 849<a href="#SkMatrix_kATransY">kATransY</a>, 850};</pre> 851 852Affine arrays are in column major order to match the matrix used by 853PDF and XPS. 854 855### Constants 856 857<table> 858 <tr> 859 <td><a name="SkMatrix_kAScaleX"> <code><strong>SkMatrix::kAScaleX </strong></code> </a></td><td>0</td><td>horizontal scale factor</td> 860 </tr> 861 <tr> 862 <td><a name="SkMatrix_kASkewY"> <code><strong>SkMatrix::kASkewY </strong></code> </a></td><td>1</td><td>vertical skew factor</td> 863 </tr> 864 <tr> 865 <td><a name="SkMatrix_kASkewX"> <code><strong>SkMatrix::kASkewX </strong></code> </a></td><td>2</td><td>horizontal skew factor</td> 866 </tr> 867 <tr> 868 <td><a name="SkMatrix_kAScaleY"> <code><strong>SkMatrix::kAScaleY </strong></code> </a></td><td>3</td><td>vertical scale factor</td> 869 </tr> 870 <tr> 871 <td><a name="SkMatrix_kATransX"> <code><strong>SkMatrix::kATransX </strong></code> </a></td><td>4</td><td>horizontal translation</td> 872 </tr> 873 <tr> 874 <td><a name="SkMatrix_kATransY"> <code><strong>SkMatrix::kATransY </strong></code> </a></td><td>5</td><td>vertical translation</td> 875 </tr> 876</table> 877 878### See Also 879 880<a href="#SkMatrix_SetAffineIdentity">SetAffineIdentity</a> <a href="#SkMatrix_asAffine">asAffine</a> <a href="#SkMatrix_setAffine">setAffine</a> 881 882 883 884## <a name="Operator"></a> Operator 885 886| name | description | 887| --- | --- | 888| <a href="#SkMatrix_Concat">Concat</a> | returns the concatenation of <a href="#Matrix">Matrix</a> pair | 889| <a href="#SkMatrix_cheapEqualTo">cheapEqualTo</a> | compares <a href="#Matrix">Matrix</a> pair using memcmp() | 890| <a href="#SkMatrix_invert">invert</a> | returns inverse, if possible | 891| <a href="#SkMatrix_notequal_operator">operator!=(const SkMatrix& a, const SkMatrix& b)</a> | returns true if members are unequal | 892| <a href="#SkMatrix_equal_operator">operator==(const SkMatrix& a, const SkMatrix& b)</a> | returns true if members are equal | 893| <a href="#SkMatrix_array1_operator">operator[](int index)</a> | returns writable reference to <a href="#Matrix">Matrix</a> value | 894| <a href="#SkMatrix_array_operator">operator[](int index) const</a> | returns <a href="#Matrix">Matrix</a> value | 895 896<a name="SkMatrix_array_operator"></a> 897## operator[] 898 899<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 900SkScalar operator[](int index) _const 901</pre> 902 903Returns one matrix value. Asserts if <a href="#SkMatrix_array_operator_index">index</a> is out of range and SK_DEBUG is 904defined. 905 906### Parameters 907 908<table> <tr> <td><a name="SkMatrix_array_operator_index"> <code><strong>index </strong></code> </a></td> <td> 909one of: <a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, 910<a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, <a href="#SkMatrix_kMPersp2">kMPersp2</a></td> 911 </tr> 912</table> 913 914### Return Value 915 916value corresponding to <a href="#SkMatrix_array_operator_index">index</a> 917 918### Example 919 920<div><fiddle-embed name="e8740493abdf0c6341762db9cee56b89"> 921 922#### Example Output 923 924~~~~ 925matrix[SkMatrix::kMScaleX] == 42 926matrix[SkMatrix::kMScaleY] == 24 927~~~~ 928 929</fiddle-embed></div> 930 931### See Also 932 933<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_set">set</a> 934 935--- 936 937<a name="SkMatrix_get"></a> 938## get 939 940<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 941SkScalar get(int index) const 942</pre> 943 944Returns one matrix value. Asserts if <a href="#SkMatrix_get_index">index</a> is out of range and SK_DEBUG is 945defined. 946 947### Parameters 948 949<table> <tr> <td><a name="SkMatrix_get_index"> <code><strong>index </strong></code> </a></td> <td> 950one of: <a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, 951<a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, <a href="#SkMatrix_kMPersp2">kMPersp2</a></td> 952 </tr> 953</table> 954 955### Return Value 956 957value corresponding to <a href="#SkMatrix_get_index">index</a> 958 959### Example 960 961<div><fiddle-embed name="f5ed382bd04fa7d50b2398cce2fca23a"> 962 963#### Example Output 964 965~~~~ 966matrix.get(SkMatrix::kMSkewX) == 42 967matrix.get(SkMatrix::kMSkewY) == 24 968~~~~ 969 970</fiddle-embed></div> 971 972### See Also 973 974<a href="#SkMatrix_array1_operator">operator[](int index)</a> <a href="#SkMatrix_set">set</a> 975 976--- 977 978<a name="SkMatrix_getScaleX"></a> 979## getScaleX 980 981<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 982SkScalar getScaleX() const 983</pre> 984 985Returns scale factor multiplied by x input, contributing to x output. 986With <a href="#SkMatrix_mapPoints">mapPoints</a>, scales <a href="SkPoint_Reference#Point">Points</a> along the x-axis. 987 988### Return Value 989 990horizontal scale factor 991 992### Example 993 994<div><fiddle-embed name="ab746d9be63975041ae8e50cba84dc3d"> 995 996#### Example Output 997 998~~~~ 999matrix.getScaleX() == 42 1000~~~~ 1001 1002</fiddle-embed></div> 1003 1004### See Also 1005 1006<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getScaleY">getScaleY</a> <a href="#SkMatrix_setScaleX">setScaleX</a> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> 1007 1008--- 1009 1010<a name="SkMatrix_getScaleY"></a> 1011## getScaleY 1012 1013<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1014SkScalar getScaleY() const 1015</pre> 1016 1017Returns scale factor multiplied by y input, contributing to y output. 1018With <a href="#SkMatrix_mapPoints">mapPoints</a>, scales <a href="SkPoint_Reference#Point">Points</a> along the y-axis. 1019 1020### Return Value 1021 1022vertical scale factor 1023 1024### Example 1025 1026<div><fiddle-embed name="708b1a548a2f8661b2ab570782fbc751"> 1027 1028#### Example Output 1029 1030~~~~ 1031matrix.getScaleY() == 24 1032~~~~ 1033 1034</fiddle-embed></div> 1035 1036### See Also 1037 1038<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getScaleX">getScaleX</a> <a href="#SkMatrix_setScaleY">setScaleY</a> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> 1039 1040--- 1041 1042<a name="SkMatrix_getSkewY"></a> 1043## getSkewY 1044 1045<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1046SkScalar getSkewY() const 1047</pre> 1048 1049Returns scale factor multiplied by x input, contributing to y output. 1050With <a href="#SkMatrix_mapPoints">mapPoints</a>, skews <a href="SkPoint_Reference#Point">Points</a> along the y-axis. 1051Skew x and y together can rotate <a href="SkPoint_Reference#Point">Points</a>. 1052 1053### Return Value 1054 1055vertical skew factor 1056 1057### Example 1058 1059<div><fiddle-embed name="6be5704506d029ffc91ba03b1d3e674b"> 1060 1061#### Example Output 1062 1063~~~~ 1064matrix.getSkewY() == 24 1065~~~~ 1066 1067</fiddle-embed></div> 1068 1069### See Also 1070 1071<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getSkewX">getSkewX</a> <a href="#SkMatrix_setSkewY">setSkewY</a> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 1072 1073--- 1074 1075<a name="SkMatrix_getSkewX"></a> 1076## getSkewX 1077 1078<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1079SkScalar getSkewX() const 1080</pre> 1081 1082Returns scale factor multiplied by y input, contributing to x output. 1083With <a href="#SkMatrix_mapPoints">mapPoints</a>, skews <a href="SkPoint_Reference#Point">Points</a> along the x-axis. 1084Skew x and y together can rotate <a href="SkPoint_Reference#Point">Points</a>. 1085 1086### Return Value 1087 1088horizontal scale factor 1089 1090### Example 1091 1092<div><fiddle-embed name="df3a5d3c688e7597eae1e4e07bf91ae6"> 1093 1094#### Example Output 1095 1096~~~~ 1097matrix.getSkewX() == 42 1098~~~~ 1099 1100</fiddle-embed></div> 1101 1102### See Also 1103 1104<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getSkewY">getSkewY</a> <a href="#SkMatrix_setSkewX">setSkewX</a> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 1105 1106--- 1107 1108<a name="SkMatrix_getTranslateX"></a> 1109## getTranslateX 1110 1111<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1112SkScalar getTranslateX() const 1113</pre> 1114 1115Returns translation contributing to x output. 1116With <a href="#SkMatrix_mapPoints">mapPoints</a>, moves <a href="SkPoint_Reference#Point">Points</a> along the x-axis. 1117 1118### Return Value 1119 1120horizontal translation factor 1121 1122### Example 1123 1124<div><fiddle-embed name="6236f7f2b91aff977a66ba2ee2558ca4"> 1125 1126#### Example Output 1127 1128~~~~ 1129matrix.getTranslateX() == 42 1130~~~~ 1131 1132</fiddle-embed></div> 1133 1134### See Also 1135 1136<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getTranslateY">getTranslateY</a> <a href="#SkMatrix_setTranslateX">setTranslateX</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> 1137 1138--- 1139 1140<a name="SkMatrix_getTranslateY"></a> 1141## getTranslateY 1142 1143<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1144SkScalar getTranslateY() const 1145</pre> 1146 1147Returns translation contributing to y output. 1148With <a href="#SkMatrix_mapPoints">mapPoints</a>, moves <a href="SkPoint_Reference#Point">Points</a> along the y-axis. 1149 1150### Return Value 1151 1152vertical translation factor 1153 1154### Example 1155 1156<div><fiddle-embed name="08464e32d22421d2b254c71a84545ef5"> 1157 1158#### Example Output 1159 1160~~~~ 1161matrix.getTranslateY() == 24 1162~~~~ 1163 1164</fiddle-embed></div> 1165 1166### See Also 1167 1168<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_getTranslateX">getTranslateX</a> <a href="#SkMatrix_setTranslateY">setTranslateY</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> 1169 1170--- 1171 1172<a name="SkMatrix_getPerspX"></a> 1173## getPerspX 1174 1175<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1176SkScalar getPerspX() const 1177</pre> 1178 1179Returns factor scaling input x relative to input y. 1180 1181### Return Value 1182 1183input x perspective factor 1184 1185### Example 1186 1187<div><fiddle-embed name="a0f5bf4b55e8c33bfda29bf67e34306f"></fiddle-embed></div> 1188 1189### See Also 1190 1191<a href="#SkMatrix_kMPersp0">kMPersp0</a> <a href="#SkMatrix_getPerspY">getPerspY</a> 1192 1193--- 1194 1195<a name="SkMatrix_getPerspY"></a> 1196## getPerspY 1197 1198<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1199SkScalar getPerspY() const 1200</pre> 1201 1202Returns factor scaling input y relative to input x. 1203 1204### Return Value 1205 1206input y perspective factor 1207 1208### Example 1209 1210<div><fiddle-embed name="424a00a73675dbd99ad20feb0267442b"></fiddle-embed></div> 1211 1212### See Also 1213 1214<a href="#SkMatrix_kMPersp1">kMPersp1</a> <a href="#SkMatrix_getPerspX">getPerspX</a> 1215 1216--- 1217 1218<a name="SkMatrix_array1_operator"></a> 1219## operator[] 1220 1221<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1222SkScalar& operator[](int index) 1223</pre> 1224 1225Returns writable <a href="#Matrix">Matrix</a> value. Asserts if <a href="#SkMatrix_array1_operator_index">index</a> is out of range and SK_DEBUG is 1226defined. Clears internal cache anticipating that caller will change <a href="#Matrix">Matrix</a> value. 1227 1228Next call to read <a href="#Matrix">Matrix</a> state may recompute cache; subsequent writes to <a href="#Matrix">Matrix</a> 1229value must be followed by <a href="#SkMatrix_dirtyMatrixTypeCache">dirtyMatrixTypeCache</a>. 1230 1231### Parameters 1232 1233<table> <tr> <td><a name="SkMatrix_array1_operator_index"> <code><strong>index </strong></code> </a></td> <td> 1234one of: <a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, 1235<a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, <a href="#SkMatrix_kMPersp2">kMPersp2</a></td> 1236 </tr> 1237</table> 1238 1239### Return Value 1240 1241writable value corresponding to <a href="#SkMatrix_array1_operator_index">index</a> 1242 1243### Example 1244 1245<div><fiddle-embed name="f4365ef332f51f7fd25040e0771ba9a2"> 1246 1247#### Example Output 1248 1249~~~~ 1250with identity matrix: x = 24 1251after skew x mod: x = 24 1252after 2nd skew x mod: x = 24 1253after dirty cache: x = 66 1254~~~~ 1255 1256</fiddle-embed></div> 1257 1258### See Also 1259 1260<a href="#SkMatrix_get">get</a> <a href="#SkMatrix_dirtyMatrixTypeCache">dirtyMatrixTypeCache</a> <a href="#SkMatrix_set">set</a> 1261 1262--- 1263 1264## <a name="Set"></a> Set 1265 1266| name | description | 1267| --- | --- | 1268| <a href="#SkMatrix_postConcat">postConcat</a> | post-multiplies <a href="#Matrix">Matrix</a> by <a href="#Matrix">Matrix</a> parameter | 1269| <a href="#SkMatrix_postIDiv">postIDiv</a> | post-multiplies <a href="#Matrix">Matrix</a> by inverse scale | 1270| <a href="#SkMatrix_postRotate">postRotate</a> | post-multiplies <a href="#Matrix">Matrix</a> by rotation | 1271| | <a href="#SkMatrix_postRotate">postRotate(SkScalar degrees, SkScalar px, SkScalar py)</a> | 1272| | <a href="#SkMatrix_postRotate_2">postRotate(SkScalar degrees)</a> | 1273| <a href="#SkMatrix_postScale">postScale</a> | post-multiplies <a href="#Matrix">Matrix</a> by scale | 1274| | <a href="#SkMatrix_postScale">postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)</a> | 1275| | <a href="#SkMatrix_postScale_2">postScale(SkScalar sx, SkScalar sy)</a> | 1276| <a href="#SkMatrix_postSkew">postSkew</a> | post-multiplies <a href="#Matrix">Matrix</a> by skew | 1277| | <a href="#SkMatrix_postSkew">postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)</a> | 1278| | <a href="#SkMatrix_postSkew_2">postSkew(SkScalar kx, SkScalar ky)</a> | 1279| <a href="#SkMatrix_postTranslate">postTranslate</a> | post-multiplies <a href="#Matrix">Matrix</a> by translation | 1280| <a href="#SkMatrix_preConcat">preConcat</a> | pre-multiplies <a href="#Matrix">Matrix</a> by <a href="#Matrix">Matrix</a> parameter | 1281| <a href="#SkMatrix_preRotate">preRotate</a> | pre-multiplies <a href="#Matrix">Matrix</a> by rotation | 1282| | <a href="#SkMatrix_preRotate">preRotate(SkScalar degrees, SkScalar px, SkScalar py)</a> | 1283| | <a href="#SkMatrix_preRotate_2">preRotate(SkScalar degrees)</a> | 1284| <a href="#SkMatrix_preScale">preScale</a> | pre-multiplies <a href="#Matrix">Matrix</a> by scale | 1285| | <a href="#SkMatrix_preScale">preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)</a> | 1286| | <a href="#SkMatrix_preScale_2">preScale(SkScalar sx, SkScalar sy)</a> | 1287| <a href="#SkMatrix_preSkew">preSkew</a> | pre-multiplies <a href="#Matrix">Matrix</a> by skew | 1288| | <a href="#SkMatrix_preSkew">preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)</a> | 1289| | <a href="#SkMatrix_preSkew_2">preSkew(SkScalar kx, SkScalar ky)</a> | 1290| <a href="#SkMatrix_preTranslate">preTranslate</a> | pre-multiplies <a href="#Matrix">Matrix</a> by translation | 1291| <a href="#SkMatrix_set">set</a> | sets one value | 1292| <a href="#SkMatrix_set9">set9</a> | sets all values from <a href="undocumented#Scalar">Scalar</a> array | 1293| <a href="#SkMatrix_setAll">setAll</a> | sets all values from parameters | 1294| <a href="#SkMatrix_setPerspX">setPerspX</a> | sets input x perspective factor | 1295| <a href="#SkMatrix_setPerspY">setPerspY</a> | sets input y perspective factor | 1296| <a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> | sets to map one to four points to an equal array of points | 1297| <a href="#SkMatrix_setRectToRect">setRectToRect</a> | sets to map one <a href="SkRect_Reference#Rect">Rect</a> to another | 1298| <a href="#SkMatrix_setScaleX">setScaleX</a> | sets horizontal scale factor | 1299| <a href="#SkMatrix_setScaleY">setScaleY</a> | sets vertical scale factor | 1300| <a href="#SkMatrix_setSkewX">setSkewX</a> | sets horizontal skew factor | 1301| <a href="#SkMatrix_setSkewY">setSkewY</a> | sets vertical skew factor | 1302| <a href="#SkMatrix_setTranslateX">setTranslateX</a> | sets horizontal translation | 1303| <a href="#SkMatrix_setTranslateY">setTranslateY</a> | sets vertical translation | 1304 1305<a name="SkMatrix_set"></a> 1306## set 1307 1308<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1309void set(int index, SkScalar value) 1310</pre> 1311 1312Sets <a href="#Matrix">Matrix</a> <a href="#SkMatrix_set_value">value</a>. Asserts if <a href="#SkMatrix_set_index">index</a> is out of range and SK_DEBUG is 1313defined. Safer than operator[]; internal cache is always maintained. 1314 1315### Parameters 1316 1317<table> <tr> <td><a name="SkMatrix_set_index"> <code><strong>index </strong></code> </a></td> <td> 1318one of: <a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, 1319<a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, <a href="#SkMatrix_kMPersp2">kMPersp2</a></td> 1320 </tr> <tr> <td><a name="SkMatrix_set_value"> <code><strong>value </strong></code> </a></td> <td> 1321<a href="undocumented#Scalar">Scalar</a> to store in <a href="#Matrix">Matrix</a></td> 1322 </tr> 1323</table> 1324 1325### Example 1326 1327<div><fiddle-embed name="1d400a92ca826cc89bcb88ea051f28c8"> 1328 1329#### Example Output 1330 1331~~~~ 1332with identity matrix: x = 24 1333after skew x mod: x = 24 1334after 2nd skew x mod: x = 66 1335~~~~ 1336 1337</fiddle-embed></div> 1338 1339### See Also 1340 1341operator[] <a href="#SkMatrix_get">get</a> 1342 1343--- 1344 1345<a name="SkMatrix_setScaleX"></a> 1346## setScaleX 1347 1348<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1349void setScaleX(SkScalar v) 1350</pre> 1351 1352Sets horizontal scale factor. 1353 1354### Parameters 1355 1356<table> <tr> <td><a name="SkMatrix_setScaleX_v"> <code><strong>v </strong></code> </a></td> <td> 1357horizontal scale factor to store</td> 1358 </tr> 1359</table> 1360 1361### Example 1362 1363<div><fiddle-embed name="a39dfed98c3c3c3a56be9ad59fe4e21e"></fiddle-embed></div> 1364 1365### See Also 1366 1367<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_setScaleY">setScaleY</a> 1368 1369--- 1370 1371<a name="SkMatrix_setScaleY"></a> 1372## setScaleY 1373 1374<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1375void setScaleY(SkScalar v) 1376</pre> 1377 1378Sets vertical scale factor. 1379 1380### Parameters 1381 1382<table> <tr> <td><a name="SkMatrix_setScaleY_v"> <code><strong>v </strong></code> </a></td> <td> 1383vertical scale factor to store</td> 1384 </tr> 1385</table> 1386 1387### Example 1388 1389<div><fiddle-embed name="f040c6dd85a02e94eaca00d5c2832604"></fiddle-embed></div> 1390 1391### See Also 1392 1393<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_setScaleX">setScaleX</a> 1394 1395--- 1396 1397<a name="SkMatrix_setSkewY"></a> 1398## setSkewY 1399 1400<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1401void setSkewY(SkScalar v) 1402</pre> 1403 1404Sets vertical skew factor. 1405 1406### Parameters 1407 1408<table> <tr> <td><a name="SkMatrix_setSkewY_v"> <code><strong>v </strong></code> </a></td> <td> 1409vertical skew factor to store</td> 1410 </tr> 1411</table> 1412 1413### Example 1414 1415<div><fiddle-embed name="b418d15df9829aefcc6aca93a37428bb"></fiddle-embed></div> 1416 1417### See Also 1418 1419<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkewX">setSkewX</a> 1420 1421--- 1422 1423<a name="SkMatrix_setSkewX"></a> 1424## setSkewX 1425 1426<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1427void setSkewX(SkScalar v) 1428</pre> 1429 1430Sets horizontal skew factor. 1431 1432### Parameters 1433 1434<table> <tr> <td><a name="SkMatrix_setSkewX_v"> <code><strong>v </strong></code> </a></td> <td> 1435horizontal skew factor to store</td> 1436 </tr> 1437</table> 1438 1439### Example 1440 1441<div><fiddle-embed name="c7177a6fbc1545be95a5ebca87e0cd0d"></fiddle-embed></div> 1442 1443### See Also 1444 1445<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkewX">setSkewX</a> 1446 1447--- 1448 1449<a name="SkMatrix_setTranslateX"></a> 1450## setTranslateX 1451 1452<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1453void setTranslateX(SkScalar v) 1454</pre> 1455 1456Sets horizontal translation. 1457 1458### Parameters 1459 1460<table> <tr> <td><a name="SkMatrix_setTranslateX_v"> <code><strong>v </strong></code> </a></td> <td> 1461horizontal translation to store</td> 1462 </tr> 1463</table> 1464 1465### Example 1466 1467<div><fiddle-embed name="a18bc2e3607ac3a8e438bcb61fb13130"></fiddle-embed></div> 1468 1469### See Also 1470 1471<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_setTranslateY">setTranslateY</a> 1472 1473--- 1474 1475<a name="SkMatrix_setTranslateY"></a> 1476## setTranslateY 1477 1478<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1479void setTranslateY(SkScalar v) 1480</pre> 1481 1482Sets vertical translation. 1483 1484### Parameters 1485 1486<table> <tr> <td><a name="SkMatrix_setTranslateY_v"> <code><strong>v </strong></code> </a></td> <td> 1487vertical translation to store</td> 1488 </tr> 1489</table> 1490 1491### Example 1492 1493<div><fiddle-embed name="34e3c70a72b836abf7f4858d35eecc98"></fiddle-embed></div> 1494 1495### See Also 1496 1497<a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_setTranslateX">setTranslateX</a> 1498 1499--- 1500 1501<a name="SkMatrix_setPerspX"></a> 1502## setPerspX 1503 1504<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1505void setPerspX(SkScalar v) 1506</pre> 1507 1508Sets input x perspective factor, which causes <a href="#SkMatrix_mapXY">mapXY</a> to vary input x inversely 1509proportional to input y. 1510 1511### Parameters 1512 1513<table> <tr> <td><a name="SkMatrix_setPerspX_v"> <code><strong>v </strong></code> </a></td> <td> 1514perspective factor</td> 1515 </tr> 1516</table> 1517 1518### Example 1519 1520<div><fiddle-embed name="830a9e4e4bb93d25afd83b2fea63929e"></fiddle-embed></div> 1521 1522### See Also 1523 1524<a href="#SkMatrix_getPerspX">getPerspX</a> <a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setAll">setAll</a> <a href="#SkMatrix_set9">set9</a> <a href="#SkMatrix_MakeAll">MakeAll</a> 1525 1526--- 1527 1528<a name="SkMatrix_setPerspY"></a> 1529## setPerspY 1530 1531<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1532void setPerspY(SkScalar v) 1533</pre> 1534 1535Sets input y perspective factor, which causes <a href="#SkMatrix_mapXY">mapXY</a> to vary input y inversely 1536proportional to input x. 1537 1538### Parameters 1539 1540<table> <tr> <td><a name="SkMatrix_setPerspY_v"> <code><strong>v </strong></code> </a></td> <td> 1541perspective factor</td> 1542 </tr> 1543</table> 1544 1545### Example 1546 1547<div><fiddle-embed name="aeb258b7922c1a11b698b00f562182ec"></fiddle-embed></div> 1548 1549### See Also 1550 1551<a href="#SkMatrix_getPerspY">getPerspY</a> <a href="#SkMatrix_set">set</a> <a href="#SkMatrix_setAll">setAll</a> <a href="#SkMatrix_set9">set9</a> <a href="#SkMatrix_MakeAll">MakeAll</a> 1552 1553--- 1554 1555<a name="SkMatrix_setAll"></a> 1556## setAll 1557 1558<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1559void setAll(SkScalar scaleX, SkScalar skewX, SkScalar transX, SkScalar skewY, SkScalar scaleY, 1560 SkScalar transY, SkScalar persp0, SkScalar persp1, SkScalar persp2) 1561</pre> 1562 1563Sets all values from parameters. Sets matrix to: 1564 1565<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1566| scaleX skewX transX | 1567| skewY scaleY transY | 1568| persp0 persp1 persp2 |</pre> 1569 1570### Parameters 1571 1572<table> <tr> <td><a name="SkMatrix_setAll_scaleX"> <code><strong>scaleX </strong></code> </a></td> <td> 1573horizontal scale factor to store</td> 1574 </tr> <tr> <td><a name="SkMatrix_setAll_skewX"> <code><strong>skewX </strong></code> </a></td> <td> 1575horizontal skew factor to store</td> 1576 </tr> <tr> <td><a name="SkMatrix_setAll_transX"> <code><strong>transX </strong></code> </a></td> <td> 1577horizontal translation to store</td> 1578 </tr> <tr> <td><a name="SkMatrix_setAll_skewY"> <code><strong>skewY </strong></code> </a></td> <td> 1579vertical skew factor to store</td> 1580 </tr> <tr> <td><a name="SkMatrix_setAll_scaleY"> <code><strong>scaleY </strong></code> </a></td> <td> 1581vertical scale factor to store</td> 1582 </tr> <tr> <td><a name="SkMatrix_setAll_transY"> <code><strong>transY </strong></code> </a></td> <td> 1583vertical translation to store</td> 1584 </tr> <tr> <td><a name="SkMatrix_setAll_persp0"> <code><strong>persp0 </strong></code> </a></td> <td> 1585input x perspective factor to store</td> 1586 </tr> <tr> <td><a name="SkMatrix_setAll_persp1"> <code><strong>persp1 </strong></code> </a></td> <td> 1587input y perspective factor to store</td> 1588 </tr> <tr> <td><a name="SkMatrix_setAll_persp2"> <code><strong>persp2 </strong></code> </a></td> <td> 1589perspective scale factor to store</td> 1590 </tr> 1591</table> 1592 1593### Example 1594 1595<div><fiddle-embed name="95ccfc2a89ce593e6b7a9f992a844bc0"></fiddle-embed></div> 1596 1597### See Also 1598 1599<a href="#SkMatrix_set9">set9</a> <a href="#SkMatrix_MakeAll">MakeAll</a> 1600 1601--- 1602 1603<a name="SkMatrix_get9"></a> 1604## get9 1605 1606<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1607void get9(SkScalar buffer[9]) const 1608</pre> 1609 1610Copies nine <a href="undocumented#Scalar">Scalar</a> values contained by <a href="#Matrix">Matrix</a> into <a href="#SkMatrix_get9_buffer">buffer</a>, in member value 1611ascending order: <a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, 1612<a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, <a href="#SkMatrix_kMPersp2">kMPersp2</a>. 1613 1614### Parameters 1615 1616<table> <tr> <td><a name="SkMatrix_get9_buffer"> <code><strong>buffer </strong></code> </a></td> <td> 1617storage for nine <a href="undocumented#Scalar">Scalar</a> values</td> 1618 </tr> 1619</table> 1620 1621### Example 1622 1623<div><fiddle-embed name="df509d73b47cb98b0475e4465db7b246"> 1624 1625#### Example Output 1626 1627~~~~ 1628{4, 0, 3}, 1629{0, 5, 4}, 1630{0, 0, 1} 1631~~~~ 1632 1633</fiddle-embed></div> 1634 1635### See Also 1636 1637<a href="#SkMatrix_set9">set9</a> 1638 1639--- 1640 1641<a name="SkMatrix_set9"></a> 1642## set9 1643 1644<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1645void set9(const SkScalar buffer[9]) 1646</pre> 1647 1648Sets <a href="#Matrix">Matrix</a> to nine <a href="undocumented#Scalar">Scalar</a> values in <a href="#SkMatrix_set9_buffer">buffer</a>, in member value ascending order: 1649<a href="#SkMatrix_kMScaleX">kMScaleX</a>, <a href="#SkMatrix_kMSkewX">kMSkewX</a>, <a href="#SkMatrix_kMTransX">kMTransX</a>, <a href="#SkMatrix_kMSkewY">kMSkewY</a>, <a href="#SkMatrix_kMScaleY">kMScaleY</a>, <a href="#SkMatrix_kMTransY">kMTransY</a>, <a href="#SkMatrix_kMPersp0">kMPersp0</a>, <a href="#SkMatrix_kMPersp1">kMPersp1</a>, 1650<a href="#SkMatrix_kMPersp2">kMPersp2</a>. 1651 1652Sets matrix to: 1653 1654<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1655| buffer[0] buffer[1] buffer[2] | 1656| buffer[3] buffer[4] buffer[5] | 1657| buffer[6] buffer[7] buffer[8] |</pre> 1658 1659In the future, <a href="#SkMatrix_set9">set9</a> followed by <a href="#SkMatrix_get9">get9</a> may not return the same values. Since <a href="#Matrix">Matrix</a> 1660maps non-homogeneous coordinates, scaling all nine values produces an equivalent 1661transformation, possibly improving precision. 1662 1663### Parameters 1664 1665<table> <tr> <td><a name="SkMatrix_set9_buffer"> <code><strong>buffer </strong></code> </a></td> <td> 1666nine <a href="undocumented#Scalar">Scalar</a> values</td> 1667 </tr> 1668</table> 1669 1670### Example 1671 1672<div><fiddle-embed name="ec5de0d23e5fe28ba7628625d1402e85"></fiddle-embed></div> 1673 1674### See Also 1675 1676<a href="#SkMatrix_setAll">setAll</a> <a href="#SkMatrix_get9">get9</a> <a href="#SkMatrix_MakeAll">MakeAll</a> 1677 1678--- 1679 1680<a name="SkMatrix_reset"></a> 1681## reset 1682 1683<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1684void reset() 1685</pre> 1686 1687Sets <a href="#Matrix">Matrix</a> to identity; which has no effect on mapped <a href="SkPoint_Reference#Point">Points</a>. Sets <a href="#Matrix">Matrix</a> to: 1688 1689<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1690| 1 0 0 | 1691| 0 1 0 | 1692| 0 0 1 |</pre> 1693 1694Also called <a href="#SkMatrix_setIdentity">setIdentity</a>; use the one that provides better inline 1695documentation. 1696 1697### Example 1698 1699<div><fiddle-embed name="ca94f7922bc37ef03bbc51ad70536fcf"> 1700 1701#### Example Output 1702 1703~~~~ 1704m.isIdentity(): true 1705~~~~ 1706 1707</fiddle-embed></div> 1708 1709### See Also 1710 1711<a href="#SkMatrix_isIdentity">isIdentity</a> <a href="#SkMatrix_setIdentity">setIdentity</a> 1712 1713--- 1714 1715<a name="SkMatrix_setIdentity"></a> 1716## setIdentity 1717 1718<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1719void setIdentity() 1720</pre> 1721 1722Sets <a href="#Matrix">Matrix</a> to identity; which has no effect on mapped <a href="SkPoint_Reference#Point">Points</a>. Sets <a href="#Matrix">Matrix</a> to: 1723 1724<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1725| 1 0 0 | 1726| 0 1 0 | 1727| 0 0 1 |</pre> 1728 1729Also called <a href="#SkMatrix_reset">reset</a>; use the one that provides better inline 1730documentation. 1731 1732### Example 1733 1734<div><fiddle-embed name="3979c865bb482e6ef1fafc71e56bbb91"> 1735 1736#### Example Output 1737 1738~~~~ 1739m.isIdentity(): true 1740~~~~ 1741 1742</fiddle-embed></div> 1743 1744### See Also 1745 1746<a href="#SkMatrix_isIdentity">isIdentity</a> <a href="#SkMatrix_reset">reset</a> 1747 1748--- 1749 1750<a name="SkMatrix_setTranslate"></a> 1751## setTranslate 1752 1753<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1754void setTranslate(SkScalar dx, SkScalar dy) 1755</pre> 1756 1757Sets <a href="#Matrix">Matrix</a> to translate by (<a href="#SkMatrix_setTranslate_dx">dx</a>, <a href="#SkMatrix_setTranslate_dy">dy</a>). 1758 1759### Parameters 1760 1761<table> <tr> <td><a name="SkMatrix_setTranslate_dx"> <code><strong>dx </strong></code> </a></td> <td> 1762horizontal translation</td> 1763 </tr> <tr> <td><a name="SkMatrix_setTranslate_dy"> <code><strong>dy </strong></code> </a></td> <td> 1764vertical translation</td> 1765 </tr> 1766</table> 1767 1768### Example 1769 1770<div><fiddle-embed name="63ca62985741b1bccb5e8b9cf734874e"></fiddle-embed></div> 1771 1772### See Also 1773 1774<a href="#SkMatrix_setTranslateX">setTranslateX</a> <a href="#SkMatrix_setTranslateY">setTranslateY</a> 1775 1776--- 1777 1778<a name="SkMatrix_setTranslate_2"></a> 1779 1780<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1781void setTranslate(const SkVector& v) 1782</pre> 1783 1784Sets <a href="#Matrix">Matrix</a> to translate by (<a href="#SkMatrix_setTranslate_2_v">v</a>.fX, <a href="#SkMatrix_setTranslate_2_v">v</a>.fY). 1785 1786### Parameters 1787 1788<table> <tr> <td><a name="SkMatrix_setTranslate_2_v"> <code><strong>v </strong></code> </a></td> <td> 1789<a href="SkPoint_Reference#Vector">Vector</a> containing horizontal and vertical translation</td> 1790 </tr> 1791</table> 1792 1793### Example 1794 1795<div><fiddle-embed name="ccfc734aff2ddea0b097c83f5621de5e"></fiddle-embed></div> 1796 1797### See Also 1798 1799<a href="#SkMatrix_setTranslateX">setTranslateX</a> <a href="#SkMatrix_setTranslateY">setTranslateY</a> <a href="#SkMatrix_MakeTrans">MakeTrans</a> 1800 1801--- 1802 1803<a name="SkMatrix_setScale"></a> 1804## setScale 1805 1806<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1807void setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) 1808</pre> 1809 1810Sets <a href="#Matrix">Matrix</a> to scale by <a href="#SkMatrix_setScale_sx">sx</a> and <a href="#SkMatrix_setScale_sy">sy</a>, about a pivot point at (<a href="#SkMatrix_setScale_px">px</a>, <a href="#SkMatrix_setScale_py">py</a>). 1811The pivot point is unchanged when mapped with <a href="#Matrix">Matrix</a>. 1812 1813### Parameters 1814 1815<table> <tr> <td><a name="SkMatrix_setScale_sx"> <code><strong>sx </strong></code> </a></td> <td> 1816horizontal scale factor</td> 1817 </tr> <tr> <td><a name="SkMatrix_setScale_sy"> <code><strong>sy </strong></code> </a></td> <td> 1818vertical scale factor</td> 1819 </tr> <tr> <td><a name="SkMatrix_setScale_px"> <code><strong>px </strong></code> </a></td> <td> 1820pivot x</td> 1821 </tr> <tr> <td><a name="SkMatrix_setScale_py"> <code><strong>py </strong></code> </a></td> <td> 1822pivot y</td> 1823 </tr> 1824</table> 1825 1826### Example 1827 1828<div><fiddle-embed name="4565a0792058178c88e0a129a87272d6"></fiddle-embed></div> 1829 1830### See Also 1831 1832<a href="#SkMatrix_setScaleX">setScaleX</a> <a href="#SkMatrix_setScaleY">setScaleY</a> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> <a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> <a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> 1833 1834--- 1835 1836<a name="SkMatrix_setScale_2"></a> 1837 1838<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1839void setScale(SkScalar sx, SkScalar sy) 1840</pre> 1841 1842Sets <a href="#Matrix">Matrix</a> to scale by <a href="#SkMatrix_setScale_2_sx">sx</a> and <a href="#SkMatrix_setScale_2_sy">sy</a> about at pivot point at (0, 0). 1843 1844### Parameters 1845 1846<table> <tr> <td><a name="SkMatrix_setScale_2_sx"> <code><strong>sx </strong></code> </a></td> <td> 1847horizontal scale factor</td> 1848 </tr> <tr> <td><a name="SkMatrix_setScale_2_sy"> <code><strong>sy </strong></code> </a></td> <td> 1849vertical scale factor</td> 1850 </tr> 1851</table> 1852 1853### Example 1854 1855<div><fiddle-embed name="1579d0cc109c26e69f66f73abd35fb0e"></fiddle-embed></div> 1856 1857### See Also 1858 1859<a href="#SkMatrix_setScaleX">setScaleX</a> <a href="#SkMatrix_setScaleY">setScaleY</a> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> <a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> <a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> 1860 1861--- 1862 1863<a name="SkMatrix_setRotate"></a> 1864## setRotate 1865 1866<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1867void setRotate(SkScalar degrees, SkScalar px, SkScalar py) 1868</pre> 1869 1870Sets <a href="#Matrix">Matrix</a> to rotate by <a href="#SkMatrix_setRotate_degrees">degrees</a> about a pivot point at (<a href="#SkMatrix_setRotate_px">px</a>, <a href="#SkMatrix_setRotate_py">py</a>). 1871The pivot point is unchanged when mapped with <a href="#Matrix">Matrix</a>. 1872 1873Positive <a href="#SkMatrix_setRotate_degrees">degrees</a> rotates clockwise. 1874 1875### Parameters 1876 1877<table> <tr> <td><a name="SkMatrix_setRotate_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 1878angle of axes relative to upright axes</td> 1879 </tr> <tr> <td><a name="SkMatrix_setRotate_px"> <code><strong>px </strong></code> </a></td> <td> 1880pivot x</td> 1881 </tr> <tr> <td><a name="SkMatrix_setRotate_py"> <code><strong>py </strong></code> </a></td> <td> 1882pivot y</td> 1883 </tr> 1884</table> 1885 1886### Example 1887 1888<div><fiddle-embed name="8c28db3add9cd0177225088f6df6bbb5"></fiddle-embed></div> 1889 1890### See Also 1891 1892<a href="#SkMatrix_setSinCos">setSinCos</a><sup><a href="#SkMatrix_setSinCos_2">[2]</a></sup> <a href="#SkMatrix_preRotate">preRotate</a><sup><a href="#SkMatrix_preRotate_2">[2]</a></sup> <a href="#SkMatrix_postRotate">postRotate</a><sup><a href="#SkMatrix_postRotate_2">[2]</a></sup> 1893 1894--- 1895 1896<a name="SkMatrix_setRotate_2"></a> 1897 1898<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1899void setRotate(SkScalar degrees) 1900</pre> 1901 1902Sets <a href="#Matrix">Matrix</a> to rotate by <a href="#SkMatrix_setRotate_2_degrees">degrees</a> about a pivot point at (0, 0). 1903Positive <a href="#SkMatrix_setRotate_2_degrees">degrees</a> rotates clockwise. 1904 1905### Parameters 1906 1907<table> <tr> <td><a name="SkMatrix_setRotate_2_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 1908angle of axes relative to upright axes</td> 1909 </tr> 1910</table> 1911 1912### Example 1913 1914<div><fiddle-embed name="93efb9d191bf1b9710c173513e014d6c"></fiddle-embed></div> 1915 1916### See Also 1917 1918<a href="#SkMatrix_setSinCos">setSinCos</a><sup><a href="#SkMatrix_setSinCos_2">[2]</a></sup> <a href="#SkMatrix_preRotate">preRotate</a><sup><a href="#SkMatrix_preRotate_2">[2]</a></sup> <a href="#SkMatrix_postRotate">postRotate</a><sup><a href="#SkMatrix_postRotate_2">[2]</a></sup> 1919 1920--- 1921 1922<a name="SkMatrix_setSinCos"></a> 1923## setSinCos 1924 1925<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1926void setSinCos(SkScalar sinValue, SkScalar cosValue, SkScalar px, SkScalar py) 1927</pre> 1928 1929Sets <a href="#Matrix">Matrix</a> to rotate by <a href="#SkMatrix_setSinCos_sinValue">sinValue</a> and <a href="#SkMatrix_setSinCos_cosValue">cosValue</a>, about a pivot point at (<a href="#SkMatrix_setSinCos_px">px</a>, <a href="#SkMatrix_setSinCos_py">py</a>). 1930The pivot point is unchanged when mapped with <a href="#Matrix">Matrix</a>. 1931 1932<a href="SkPoint_Reference#Vector">Vector</a> (<a href="#SkMatrix_setSinCos_sinValue">sinValue</a>, <a href="#SkMatrix_setSinCos_cosValue">cosValue</a>) describes the angle of rotation relative to (0, 1). 1933<a href="SkPoint_Reference#Vector">Vector</a> length specifies scale. 1934 1935### Parameters 1936 1937<table> <tr> <td><a name="SkMatrix_setSinCos_sinValue"> <code><strong>sinValue </strong></code> </a></td> <td> 1938rotation vector x component</td> 1939 </tr> <tr> <td><a name="SkMatrix_setSinCos_cosValue"> <code><strong>cosValue </strong></code> </a></td> <td> 1940rotation vector y component</td> 1941 </tr> <tr> <td><a name="SkMatrix_setSinCos_px"> <code><strong>px </strong></code> </a></td> <td> 1942pivot x</td> 1943 </tr> <tr> <td><a name="SkMatrix_setSinCos_py"> <code><strong>py </strong></code> </a></td> <td> 1944pivot y</td> 1945 </tr> 1946</table> 1947 1948### Example 1949 1950<div><fiddle-embed name="187e1d9228e2e4341ef820bd77b6fda9"></fiddle-embed></div> 1951 1952### See Also 1953 1954<a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_setRSXform">setRSXform</a> 1955 1956--- 1957 1958<a name="SkMatrix_setSinCos_2"></a> 1959 1960<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1961void setSinCos(SkScalar sinValue, SkScalar cosValue) 1962</pre> 1963 1964Sets <a href="#Matrix">Matrix</a> to rotate by <a href="#SkMatrix_setSinCos_2_sinValue">sinValue</a> and <a href="#SkMatrix_setSinCos_2_cosValue">cosValue</a>, about a pivot point at (0, 0). 1965 1966<a href="SkPoint_Reference#Vector">Vector</a> (<a href="#SkMatrix_setSinCos_2_sinValue">sinValue</a>, <a href="#SkMatrix_setSinCos_2_cosValue">cosValue</a>) describes the angle of rotation relative to (0, 1). 1967<a href="SkPoint_Reference#Vector">Vector</a> length specifies scale. 1968 1969### Parameters 1970 1971<table> <tr> <td><a name="SkMatrix_setSinCos_2_sinValue"> <code><strong>sinValue </strong></code> </a></td> <td> 1972rotation vector x component</td> 1973 </tr> <tr> <td><a name="SkMatrix_setSinCos_2_cosValue"> <code><strong>cosValue </strong></code> </a></td> <td> 1974rotation vector y component</td> 1975 </tr> 1976</table> 1977 1978### Example 1979 1980<div><fiddle-embed name="e37a94a53c959951b059fcd624639ef6"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> needs offset after applying <a href="#Matrix">Matrix</a> to pivot about <a href="SkRect_Reference#Rect">Rect</a> center.</div></fiddle-embed></div> 1981 1982### See Also 1983 1984<a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_setRSXform">setRSXform</a> 1985 1986--- 1987 1988<a name="SkMatrix_setRSXform"></a> 1989## setRSXform 1990 1991<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 1992SkMatrix& setRSXform(const SkRSXform& rsxForm) 1993</pre> 1994 1995Sets <a href="#Matrix">Matrix</a> to rotate, scale, and translate using a compressed matrix form. 1996 1997<a href="SkPoint_Reference#Vector">Vector</a> (<a href="#SkMatrix_setRSXform_rsxForm">rsxForm</a>.fSSin, <a href="#SkMatrix_setRSXform_rsxForm">rsxForm</a>.fSCos) describes the angle of rotation relative 1998to (0, 1). <a href="SkPoint_Reference#Vector">Vector</a> length specifies scale. Mapped point is rotated and scaled 1999by <a href="SkPoint_Reference#Vector">Vector</a>, then translated by (<a href="#SkMatrix_setRSXform_rsxForm">rsxForm</a>.fTx, <a href="#SkMatrix_setRSXform_rsxForm">rsxForm</a>.fTy). 2000 2001### Parameters 2002 2003<table> <tr> <td><a name="SkMatrix_setRSXform_rsxForm"> <code><strong>rsxForm </strong></code> </a></td> <td> 2004compressed <a href="undocumented#RSXform">RSXform</a> matrix</td> 2005 </tr> 2006</table> 2007 2008### Return Value 2009 2010reference to <a href="#Matrix">Matrix</a> 2011 2012### Example 2013 2014<div><fiddle-embed name="c3f5faddca466f78278b32b88fd5f5eb"><div><a href="SkCanvas_Reference#Canvas">Canvas</a> needs offset after applying <a href="#Matrix">Matrix</a> to pivot about <a href="SkRect_Reference#Rect">Rect</a> center.</div></fiddle-embed></div> 2015 2016### See Also 2017 2018<a href="#SkMatrix_setSinCos">setSinCos</a><sup><a href="#SkMatrix_setSinCos_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> 2019 2020--- 2021 2022<a name="SkMatrix_setSkew"></a> 2023## setSkew 2024 2025<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2026void setSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) 2027</pre> 2028 2029Sets <a href="#Matrix">Matrix</a> to skew by <a href="#SkMatrix_setSkew_kx">kx</a> and <a href="#SkMatrix_setSkew_ky">ky</a>, about a pivot point at (<a href="#SkMatrix_setSkew_px">px</a>, <a href="#SkMatrix_setSkew_py">py</a>). 2030The pivot point is unchanged when mapped with <a href="#Matrix">Matrix</a>. 2031 2032### Parameters 2033 2034<table> <tr> <td><a name="SkMatrix_setSkew_kx"> <code><strong>kx </strong></code> </a></td> <td> 2035horizontal skew factor</td> 2036 </tr> <tr> <td><a name="SkMatrix_setSkew_ky"> <code><strong>ky </strong></code> </a></td> <td> 2037vertical skew factor</td> 2038 </tr> <tr> <td><a name="SkMatrix_setSkew_px"> <code><strong>px </strong></code> </a></td> <td> 2039pivot x</td> 2040 </tr> <tr> <td><a name="SkMatrix_setSkew_py"> <code><strong>py </strong></code> </a></td> <td> 2041pivot y</td> 2042 </tr> 2043</table> 2044 2045### Example 2046 2047<div><fiddle-embed name="55e0431adc6c5b1987ebb8123cc10342"></fiddle-embed></div> 2048 2049### See Also 2050 2051<a href="#SkMatrix_setSkewX">setSkewX</a> <a href="#SkMatrix_setSkewY">setSkewY</a> <a href="#SkMatrix_preSkew">preSkew</a><sup><a href="#SkMatrix_preSkew_2">[2]</a></sup> <a href="#SkMatrix_postSkew">postSkew</a><sup><a href="#SkMatrix_postSkew_2">[2]</a></sup> 2052 2053--- 2054 2055<a name="SkMatrix_setSkew_2"></a> 2056 2057<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2058void setSkew(SkScalar kx, SkScalar ky) 2059</pre> 2060 2061Sets <a href="#Matrix">Matrix</a> to skew by <a href="#SkMatrix_setSkew_2_kx">kx</a> and <a href="#SkMatrix_setSkew_2_ky">ky</a>, about a pivot point at (0, 0). 2062 2063### Parameters 2064 2065<table> <tr> <td><a name="SkMatrix_setSkew_2_kx"> <code><strong>kx </strong></code> </a></td> <td> 2066horizontal skew factor</td> 2067 </tr> <tr> <td><a name="SkMatrix_setSkew_2_ky"> <code><strong>ky </strong></code> </a></td> <td> 2068vertical skew factor</td> 2069 </tr> 2070</table> 2071 2072### Example 2073 2074<div><fiddle-embed name="05be7844e9afdd7b9bfc31c5423a70a2"></fiddle-embed></div> 2075 2076### See Also 2077 2078<a href="#SkMatrix_setSkewX">setSkewX</a> <a href="#SkMatrix_setSkewY">setSkewY</a> <a href="#SkMatrix_preSkew">preSkew</a><sup><a href="#SkMatrix_preSkew_2">[2]</a></sup> <a href="#SkMatrix_postSkew">postSkew</a><sup><a href="#SkMatrix_postSkew_2">[2]</a></sup> 2079 2080--- 2081 2082<a name="SkMatrix_setConcat"></a> 2083## setConcat 2084 2085<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2086void setConcat(const SkMatrix& a, const SkMatrix& b) 2087</pre> 2088 2089Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> <a href="#SkMatrix_setConcat_a">a</a> multiplied by <a href="#Matrix">Matrix</a> <a href="#SkMatrix_setConcat_b">b</a>. Either <a href="#SkMatrix_setConcat_a">a</a> or <a href="#SkMatrix_setConcat_b">b</a> may be this. 2090 2091Given: 2092 2093<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2094 | A B C | | J K L | 2095a = | D E F |, b = | M N O | 2096 | G H I | | P Q R |</pre> 2097 2098sets <a href="#Matrix">Matrix</a> to: 2099 2100<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2101 | A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | 2102a * b = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | 2103 | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |</pre> 2104 2105### Parameters 2106 2107<table> <tr> <td><a name="SkMatrix_setConcat_a"> <code><strong>a </strong></code> </a></td> <td> 2108<a href="#Matrix">Matrix</a> on left side of multiply expression</td> 2109 </tr> <tr> <td><a name="SkMatrix_setConcat_b"> <code><strong>b </strong></code> </a></td> <td> 2110<a href="#Matrix">Matrix</a> on right side of multiply expression</td> 2111 </tr> 2112</table> 2113 2114### Example 2115 2116<div><fiddle-embed name="0381a10ac69bdefdf9d15b47cbb9fefe"><div><a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> creates perspective matrices, one the inverse of the other. 2117Multiplying the matrix by its inverse turns into an identity matrix.</div></fiddle-embed></div> 2118 2119### See Also 2120 2121<a href="#SkMatrix_Concat">Concat</a> <a href="#SkMatrix_preConcat">preConcat</a> <a href="#SkMatrix_postConcat">postConcat</a> <a href="SkCanvas_Reference#SkCanvas_concat">SkCanvas::concat</a> 2122 2123--- 2124 2125<a name="SkMatrix_preTranslate"></a> 2126## preTranslate 2127 2128<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2129void preTranslate(SkScalar dx, SkScalar dy) 2130</pre> 2131 2132Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from translation (<a href="#SkMatrix_preTranslate_dx">dx</a>, <a href="#SkMatrix_preTranslate_dy">dy</a>). 2133This can be thought of as moving the point to be mapped before applying <a href="#Matrix">Matrix</a>. 2134 2135Given: 2136 2137<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2138 | A B C | | 1 0 dx | 2139Matrix = | D E F |, T(dx, dy) = | 0 1 dy | 2140 | G H I | | 0 0 1 |</pre> 2141 2142sets <a href="#Matrix">Matrix</a> to: 2143 2144<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2145 | A B C | | 1 0 dx | | A B A*dx+B*dy+C | 2146Matrix * T(dx, dy) = | D E F | | 0 1 dy | = | D E D*dx+E*dy+F | 2147 | G H I | | 0 0 1 | | G H G*dx+H*dy+I |</pre> 2148 2149### Parameters 2150 2151<table> <tr> <td><a name="SkMatrix_preTranslate_dx"> <code><strong>dx </strong></code> </a></td> <td> 2152x translation before applying <a href="#Matrix">Matrix</a></td> 2153 </tr> <tr> <td><a name="SkMatrix_preTranslate_dy"> <code><strong>dy </strong></code> </a></td> <td> 2154y translation before applying <a href="#Matrix">Matrix</a></td> 2155 </tr> 2156</table> 2157 2158### Example 2159 2160<div><fiddle-embed name="08f6749933f4ce541073077ab506fd9b"></fiddle-embed></div> 2161 2162### See Also 2163 2164<a href="#SkMatrix_postTranslate">postTranslate</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_MakeTrans">MakeTrans</a> 2165 2166--- 2167 2168<a name="SkMatrix_preScale"></a> 2169## preScale 2170 2171<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2172void preScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) 2173</pre> 2174 2175Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from scaling by (<a href="#SkMatrix_preScale_sx">sx</a>, <a href="#SkMatrix_preScale_sy">sy</a>) 2176about pivot point (<a href="#SkMatrix_preScale_px">px</a>, <a href="#SkMatrix_preScale_py">py</a>). 2177This can be thought of as scaling about a pivot point before applying <a href="#Matrix">Matrix</a>. 2178 2179Given: 2180 2181<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2182 | A B C | | sx 0 dx | 2183Matrix = | D E F |, S(sx, sy, px, py) = | 0 sy dy | 2184 | G H I | | 0 0 1 |</pre> 2185 2186where 2187 2188<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2189dx = px - sx * px 2190dy = py - sy * py</pre> 2191 2192sets <a href="#Matrix">Matrix</a> to: 2193 2194<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2195 | A B C | | sx 0 dx | | A*sx B*sy A*dx+B*dy+C | 2196Matrix * S(sx, sy, px, py) = | D E F | | 0 sy dy | = | D*sx E*sy D*dx+E*dy+F | 2197 | G H I | | 0 0 1 | | G*sx H*sy G*dx+H*dy+I |</pre> 2198 2199### Parameters 2200 2201<table> <tr> <td><a name="SkMatrix_preScale_sx"> <code><strong>sx </strong></code> </a></td> <td> 2202horizontal scale factor</td> 2203 </tr> <tr> <td><a name="SkMatrix_preScale_sy"> <code><strong>sy </strong></code> </a></td> <td> 2204vertical scale factor</td> 2205 </tr> <tr> <td><a name="SkMatrix_preScale_px"> <code><strong>px </strong></code> </a></td> <td> 2206pivot x</td> 2207 </tr> <tr> <td><a name="SkMatrix_preScale_py"> <code><strong>py </strong></code> </a></td> <td> 2208pivot y</td> 2209 </tr> 2210</table> 2211 2212### Example 2213 2214<div><fiddle-embed name="2531f8d1e05d7b6dc22f3efcd2fb84e4"></fiddle-embed></div> 2215 2216### See Also 2217 2218<a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 2219 2220--- 2221 2222<a name="SkMatrix_preScale_2"></a> 2223 2224<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2225void preScale(SkScalar sx, SkScalar sy) 2226</pre> 2227 2228Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from scaling by (<a href="#SkMatrix_preScale_2_sx">sx</a>, <a href="#SkMatrix_preScale_2_sy">sy</a>) 2229about pivot point (0, 0). 2230This can be thought of as scaling about the origin before applying <a href="#Matrix">Matrix</a>. 2231 2232Given: 2233 2234<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2235 | A B C | | sx 0 0 | 2236Matrix = | D E F |, S(sx, sy) = | 0 sy 0 | 2237 | G H I | | 0 0 1 |</pre> 2238 2239sets <a href="#Matrix">Matrix</a> to: 2240 2241<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2242 | A B C | | sx 0 0 | | A*sx B*sy C | 2243Matrix * S(sx, sy) = | D E F | | 0 sy 0 | = | D*sx E*sy F | 2244 | G H I | | 0 0 1 | | G*sx H*sy I |</pre> 2245 2246### Parameters 2247 2248<table> <tr> <td><a name="SkMatrix_preScale_2_sx"> <code><strong>sx </strong></code> </a></td> <td> 2249horizontal scale factor</td> 2250 </tr> <tr> <td><a name="SkMatrix_preScale_2_sy"> <code><strong>sy </strong></code> </a></td> <td> 2251vertical scale factor</td> 2252 </tr> 2253</table> 2254 2255### Example 2256 2257<div><fiddle-embed name="3edbdea8e43d06086abf33ec4a9b415b"></fiddle-embed></div> 2258 2259### See Also 2260 2261<a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 2262 2263--- 2264 2265<a name="SkMatrix_preRotate"></a> 2266## preRotate 2267 2268<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2269void preRotate(SkScalar degrees, SkScalar px, SkScalar py) 2270</pre> 2271 2272Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from rotating by <a href="#SkMatrix_preRotate_degrees">degrees</a> 2273about pivot point (<a href="#SkMatrix_preRotate_px">px</a>, <a href="#SkMatrix_preRotate_py">py</a>). 2274This can be thought of as rotating about a pivot point before applying <a href="#Matrix">Matrix</a>. 2275 2276Positive <a href="#SkMatrix_preRotate_degrees">degrees</a> rotates clockwise. 2277 2278Given: 2279 2280<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2281 | A B C | | c -s dx | 2282Matrix = | D E F |, R(degrees, px, py) = | s c dy | 2283 | G H I | | 0 0 1 |</pre> 2284 2285where 2286 2287<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2288c = cos(degrees) 2289s = sin(degrees) 2290dx = s * py + (1 - c) * px 2291dy = -s * px + (1 - c) * py</pre> 2292 2293sets <a href="#Matrix">Matrix</a> to: 2294 2295<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2296 | A B C | | c -s dx | | Ac+Bs -As+Bc A*dx+B*dy+C | 2297Matrix * R(degrees, px, py) = | D E F | | s c dy | = | Dc+Es -Ds+Ec D*dx+E*dy+F | 2298 | G H I | | 0 0 1 | | Gc+Hs -Gs+Hc G*dx+H*dy+I |</pre> 2299 2300### Parameters 2301 2302<table> <tr> <td><a name="SkMatrix_preRotate_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 2303angle of axes relative to upright axes</td> 2304 </tr> <tr> <td><a name="SkMatrix_preRotate_px"> <code><strong>px </strong></code> </a></td> <td> 2305pivot x</td> 2306 </tr> <tr> <td><a name="SkMatrix_preRotate_py"> <code><strong>py </strong></code> </a></td> <td> 2307pivot y</td> 2308 </tr> 2309</table> 2310 2311### Example 2312 2313<div><fiddle-embed name="a70bb18d67c06a20ab514e7a47924e5a"></fiddle-embed></div> 2314 2315### See Also 2316 2317<a href="#SkMatrix_postRotate">postRotate</a><sup><a href="#SkMatrix_postRotate_2">[2]</a></sup> <a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> 2318 2319--- 2320 2321<a name="SkMatrix_preRotate_2"></a> 2322 2323<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2324void preRotate(SkScalar degrees) 2325</pre> 2326 2327Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from rotating by <a href="#SkMatrix_preRotate_2_degrees">degrees</a> 2328about pivot point (0, 0). 2329This can be thought of as rotating about the origin before applying <a href="#Matrix">Matrix</a>. 2330 2331Positive <a href="#SkMatrix_preRotate_2_degrees">degrees</a> rotates clockwise. 2332 2333Given: 2334 2335<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2336 | A B C | | c -s 0 | 2337Matrix = | D E F |, R(degrees, px, py) = | s c 0 | 2338 | G H I | | 0 0 1 |</pre> 2339 2340where 2341 2342<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2343c = cos(degrees) 2344s = sin(degrees)</pre> 2345 2346sets <a href="#Matrix">Matrix</a> to: 2347 2348<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2349 | A B C | | c -s 0 | | Ac+Bs -As+Bc C | 2350Matrix * R(degrees, px, py) = | D E F | | s c 0 | = | Dc+Es -Ds+Ec F | 2351 | G H I | | 0 0 1 | | Gc+Hs -Gs+Hc I |</pre> 2352 2353### Parameters 2354 2355<table> <tr> <td><a name="SkMatrix_preRotate_2_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 2356angle of axes relative to upright axes</td> 2357 </tr> 2358</table> 2359 2360### Example 2361 2362<div><fiddle-embed name="5acd49bd931c79a808dd6c7cc0e92f72"></fiddle-embed></div> 2363 2364### See Also 2365 2366<a href="#SkMatrix_postRotate">postRotate</a><sup><a href="#SkMatrix_postRotate_2">[2]</a></sup> <a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> 2367 2368--- 2369 2370<a name="SkMatrix_preSkew"></a> 2371## preSkew 2372 2373<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2374void preSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) 2375</pre> 2376 2377Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from skewing by (<a href="#SkMatrix_preSkew_kx">kx</a>, <a href="#SkMatrix_preSkew_ky">ky</a>) 2378about pivot point (<a href="#SkMatrix_preSkew_px">px</a>, <a href="#SkMatrix_preSkew_py">py</a>). 2379This can be thought of as skewing about a pivot point before applying <a href="#Matrix">Matrix</a>. 2380 2381Given: 2382 2383<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2384 | A B C | | 1 kx dx | 2385Matrix = | D E F |, K(kx, ky, px, py) = | ky 1 dy | 2386 | G H I | | 0 0 1 |</pre> 2387 2388where 2389 2390<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2391dx = -kx * py 2392dy = -ky * px</pre> 2393 2394sets <a href="#Matrix">Matrix</a> to: 2395 2396<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2397 | A B C | | 1 kx dx | | A+B*ky A*kx+B A*dx+B*dy+C | 2398Matrix * K(kx, ky, px, py) = | D E F | | ky 1 dy | = | D+E*ky D*kx+E D*dx+E*dy+F | 2399 | G H I | | 0 0 1 | | G+H*ky G*kx+H G*dx+H*dy+I |</pre> 2400 2401### Parameters 2402 2403<table> <tr> <td><a name="SkMatrix_preSkew_kx"> <code><strong>kx </strong></code> </a></td> <td> 2404horizontal skew factor</td> 2405 </tr> <tr> <td><a name="SkMatrix_preSkew_ky"> <code><strong>ky </strong></code> </a></td> <td> 2406vertical skew factor</td> 2407 </tr> <tr> <td><a name="SkMatrix_preSkew_px"> <code><strong>px </strong></code> </a></td> <td> 2408pivot x</td> 2409 </tr> <tr> <td><a name="SkMatrix_preSkew_py"> <code><strong>py </strong></code> </a></td> <td> 2410pivot y</td> 2411 </tr> 2412</table> 2413 2414### Example 2415 2416<div><fiddle-embed name="199a18ad61d702664ce6df1d7037aa48"></fiddle-embed></div> 2417 2418### See Also 2419 2420<a href="#SkMatrix_postSkew">postSkew</a><sup><a href="#SkMatrix_postSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 2421 2422--- 2423 2424<a name="SkMatrix_preSkew_2"></a> 2425 2426<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2427void preSkew(SkScalar kx, SkScalar ky) 2428</pre> 2429 2430Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> constructed from skewing by (<a href="#SkMatrix_preSkew_2_kx">kx</a>, <a href="#SkMatrix_preSkew_2_ky">ky</a>) 2431about pivot point (0, 0). 2432This can be thought of as skewing about the origin before applying <a href="#Matrix">Matrix</a>. 2433 2434Given: 2435 2436<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2437 | A B C | | 1 kx 0 | 2438Matrix = | D E F |, K(kx, ky) = | ky 1 0 | 2439 | G H I | | 0 0 1 |</pre> 2440 2441sets <a href="#Matrix">Matrix</a> to: 2442 2443<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2444 | A B C | | 1 kx 0 | | A+B*ky A*kx+B C | 2445Matrix * K(kx, ky) = | D E F | | ky 1 0 | = | D+E*ky D*kx+E F | 2446 | G H I | | 0 0 1 | | G+H*ky G*kx+H I |</pre> 2447 2448### Parameters 2449 2450<table> <tr> <td><a name="SkMatrix_preSkew_2_kx"> <code><strong>kx </strong></code> </a></td> <td> 2451horizontal skew factor</td> 2452 </tr> <tr> <td><a name="SkMatrix_preSkew_2_ky"> <code><strong>ky </strong></code> </a></td> <td> 2453vertical skew factor</td> 2454 </tr> 2455</table> 2456 2457### Example 2458 2459<div><fiddle-embed name="e100c543869fe8fd516ba69de79444ba"></fiddle-embed></div> 2460 2461### See Also 2462 2463<a href="#SkMatrix_postSkew">postSkew</a><sup><a href="#SkMatrix_postSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 2464 2465--- 2466 2467<a name="SkMatrix_preConcat"></a> 2468## preConcat 2469 2470<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2471void preConcat(const SkMatrix& other) 2472</pre> 2473 2474Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> multiplied by <a href="#Matrix">Matrix</a> <a href="#SkMatrix_preConcat_other">other</a>. 2475This can be thought of mapping by <a href="#SkMatrix_preConcat_other">other</a> before applying <a href="#Matrix">Matrix</a>. 2476 2477Given: 2478 2479<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2480 | A B C | | J K L | 2481Matrix = | D E F |, other = | M N O | 2482 | G H I | | P Q R |</pre> 2483 2484sets <a href="#Matrix">Matrix</a> to: 2485 2486<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2487 | A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | 2488Matrix * other = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | 2489 | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |</pre> 2490 2491### Parameters 2492 2493<table> <tr> <td><a name="SkMatrix_preConcat_other"> <code><strong>other </strong></code> </a></td> <td> 2494<a href="#Matrix">Matrix</a> on right side of multiply expression</td> 2495 </tr> 2496</table> 2497 2498### Example 2499 2500<div><fiddle-embed name="b07e62298e7b0ab5683db199faffceb2"><div><a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> creates perspective matrices, one the inverse of the <a href="#SkMatrix_preConcat_other">other</a>. 2501Multiplying the matrix by its inverse turns into an identity matrix.</div></fiddle-embed></div> 2502 2503### See Also 2504 2505<a href="#SkMatrix_postConcat">postConcat</a> <a href="#SkMatrix_setConcat">setConcat</a> <a href="#SkMatrix_Concat">Concat</a> 2506 2507--- 2508 2509<a name="SkMatrix_postTranslate"></a> 2510## postTranslate 2511 2512<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2513void postTranslate(SkScalar dx, SkScalar dy) 2514</pre> 2515 2516Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from translation (<a href="#SkMatrix_postTranslate_dx">dx</a>, <a href="#SkMatrix_postTranslate_dy">dy</a>) multiplied by <a href="#Matrix">Matrix</a>. 2517This can be thought of as moving the point to be mapped after applying <a href="#Matrix">Matrix</a>. 2518 2519Given: 2520 2521<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2522 | J K L | | 1 0 dx | 2523Matrix = | M N O |, T(dx, dy) = | 0 1 dy | 2524 | P Q R | | 0 0 1 |</pre> 2525 2526sets <a href="#Matrix">Matrix</a> to: 2527 2528<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2529 | 1 0 dx | | J K L | | J+dx*P K+dx*Q L+dx*R | 2530T(dx, dy) * Matrix = | 0 1 dy | | M N O | = | M+dy*P N+dy*Q O+dy*R | 2531 | 0 0 1 | | P Q R | | P Q R |</pre> 2532 2533### Parameters 2534 2535<table> <tr> <td><a name="SkMatrix_postTranslate_dx"> <code><strong>dx </strong></code> </a></td> <td> 2536x translation after applying <a href="#Matrix">Matrix</a></td> 2537 </tr> <tr> <td><a name="SkMatrix_postTranslate_dy"> <code><strong>dy </strong></code> </a></td> <td> 2538y translation after applying <a href="#Matrix">Matrix</a></td> 2539 </tr> 2540</table> 2541 2542### Example 2543 2544<div><fiddle-embed name="57e4cff302c0d754ac6c66050d741772"><div>Compare with <a href="#SkMatrix_preTranslate">preTranslate</a> example.</div></fiddle-embed></div> 2545 2546### See Also 2547 2548<a href="#SkMatrix_preTranslate">preTranslate</a> <a href="#SkMatrix_setTranslate">setTranslate</a><sup><a href="#SkMatrix_setTranslate_2">[2]</a></sup> <a href="#SkMatrix_MakeTrans">MakeTrans</a> 2549 2550--- 2551 2552<a name="SkMatrix_postScale"></a> 2553## postScale 2554 2555<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2556void postScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py) 2557</pre> 2558 2559Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from scaling by (<a href="#SkMatrix_postScale_sx">sx</a>, <a href="#SkMatrix_postScale_sy">sy</a>) about pivot point 2560(<a href="#SkMatrix_postScale_px">px</a>, <a href="#SkMatrix_postScale_py">py</a>), multiplied by <a href="#Matrix">Matrix</a>. 2561This can be thought of as scaling about a pivot point after applying <a href="#Matrix">Matrix</a>. 2562 2563Given: 2564 2565<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2566 | J K L | | sx 0 dx | 2567Matrix = | M N O |, S(sx, sy, px, py) = | 0 sy dy | 2568 | P Q R | | 0 0 1 |</pre> 2569 2570where 2571 2572<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2573dx = px - sx * px 2574dy = py - sy * py</pre> 2575 2576sets <a href="#Matrix">Matrix</a> to: 2577 2578<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2579 | sx 0 dx | | J K L | | sx*J+dx*P sx*K+dx*Q sx*L+dx+R | 2580S(sx, sy, px, py) * Matrix = | 0 sy dy | | M N O | = | sy*M+dy*P sy*N+dy*Q sy*O+dy*R | 2581 | 0 0 1 | | P Q R | | P Q R |</pre> 2582 2583### Parameters 2584 2585<table> <tr> <td><a name="SkMatrix_postScale_sx"> <code><strong>sx </strong></code> </a></td> <td> 2586horizontal scale factor</td> 2587 </tr> <tr> <td><a name="SkMatrix_postScale_sy"> <code><strong>sy </strong></code> </a></td> <td> 2588vertical scale factor</td> 2589 </tr> <tr> <td><a name="SkMatrix_postScale_px"> <code><strong>px </strong></code> </a></td> <td> 2590pivot x</td> 2591 </tr> <tr> <td><a name="SkMatrix_postScale_py"> <code><strong>py </strong></code> </a></td> <td> 2592pivot y</td> 2593 </tr> 2594</table> 2595 2596### Example 2597 2598<div><fiddle-embed name="ed3aa18ba0ea95c85cc49aa3829fe384"></fiddle-embed></div> 2599 2600### See Also 2601 2602<a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 2603 2604--- 2605 2606<a name="SkMatrix_postScale_2"></a> 2607 2608<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2609void postScale(SkScalar sx, SkScalar sy) 2610</pre> 2611 2612Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from scaling by (<a href="#SkMatrix_postScale_2_sx">sx</a>, <a href="#SkMatrix_postScale_2_sy">sy</a>) about pivot point 2613(0, 0), multiplied by <a href="#Matrix">Matrix</a>. 2614This can be thought of as scaling about the origin after applying <a href="#Matrix">Matrix</a>. 2615 2616Given: 2617 2618<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2619 | J K L | | sx 0 0 | 2620Matrix = | M N O |, S(sx, sy) = | 0 sy 0 | 2621 | P Q R | | 0 0 1 |</pre> 2622 2623sets <a href="#Matrix">Matrix</a> to: 2624 2625<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2626 | sx 0 0 | | J K L | | sx*J sx*K sx*L | 2627S(sx, sy) * Matrix = | 0 sy 0 | | M N O | = | sy*M sy*N sy*O | 2628 | 0 0 1 | | P Q R | | P Q R |</pre> 2629 2630### Parameters 2631 2632<table> <tr> <td><a name="SkMatrix_postScale_2_sx"> <code><strong>sx </strong></code> </a></td> <td> 2633horizontal scale factor</td> 2634 </tr> <tr> <td><a name="SkMatrix_postScale_2_sy"> <code><strong>sy </strong></code> </a></td> <td> 2635vertical scale factor</td> 2636 </tr> 2637</table> 2638 2639### Example 2640 2641<div><fiddle-embed name="1931017698766a67d3a26423453b8095"></fiddle-embed></div> 2642 2643### See Also 2644 2645<a href="#SkMatrix_preScale">preScale</a><sup><a href="#SkMatrix_preScale_2">[2]</a></sup> <a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 2646 2647--- 2648 2649<a name="SkMatrix_postIDiv"></a> 2650## postIDiv 2651 2652<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2653bool postIDiv(int divx, int divy) 2654</pre> 2655 2656Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from scaling by(1/<a href="#SkMatrix_postIDiv_divx">divx</a>, 1/<a href="#SkMatrix_postIDiv_divy">divy</a>)about pivot point (px, py), multiplied by <a href="#Matrix">Matrix</a>. 2657 2658Returns false if either <a href="#SkMatrix_postIDiv_divx">divx</a> or <a href="#SkMatrix_postIDiv_divy">divy</a> is zero. 2659 2660Given: 2661 2662<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2663 | J K L | | sx 0 0 | 2664Matrix = | M N O |, I(divx, divy) = | 0 sy 0 | 2665 | P Q R | | 0 0 1 |</pre> 2666 2667where 2668 2669<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2670sx = 1 / divx 2671sy = 1 / divy</pre> 2672 2673sets <a href="#Matrix">Matrix</a> to: 2674 2675<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2676 | sx 0 0 | | J K L | | sx*J sx*K sx*L | 2677I(divx, divy) * Matrix = | 0 sy 0 | | M N O | = | sy*M sy*N sy*O | 2678 | 0 0 1 | | P Q R | | P Q R |</pre> 2679 2680### Parameters 2681 2682<table> <tr> <td><a name="SkMatrix_postIDiv_divx"> <code><strong>divx </strong></code> </a></td> <td> 2683integer divisor for inverse scale in x</td> 2684 </tr> <tr> <td><a name="SkMatrix_postIDiv_divy"> <code><strong>divy </strong></code> </a></td> <td> 2685integer divisor for inverse scale in y</td> 2686 </tr> 2687</table> 2688 2689### Return Value 2690 2691true on successful scale 2692 2693### Example 2694 2695<div><fiddle-embed name="58c844b8f0c36acdbc8211e8c929c253"></fiddle-embed></div> 2696 2697### See Also 2698 2699<a href="#SkMatrix_postScale">postScale</a><sup><a href="#SkMatrix_postScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 2700 2701--- 2702 2703<a name="SkMatrix_postRotate"></a> 2704## postRotate 2705 2706<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2707void postRotate(SkScalar degrees, SkScalar px, SkScalar py) 2708</pre> 2709 2710Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from rotating by <a href="#SkMatrix_postRotate_degrees">degrees</a> about pivot point 2711(<a href="#SkMatrix_postRotate_px">px</a>, <a href="#SkMatrix_postRotate_py">py</a>), multiplied by <a href="#Matrix">Matrix</a>. 2712This can be thought of as rotating about a pivot point after applying <a href="#Matrix">Matrix</a>. 2713 2714Positive <a href="#SkMatrix_postRotate_degrees">degrees</a> rotates clockwise. 2715 2716Given: 2717 2718<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2719 | J K L | | c -s dx | 2720Matrix = | M N O |, R(degrees, px, py) = | s c dy | 2721 | P Q R | | 0 0 1 |</pre> 2722 2723where 2724 2725<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2726c = cos(degrees) 2727s = sin(degrees) 2728dx = s * py + (1 - c) * px 2729dy = -s * px + (1 - c) * py</pre> 2730 2731sets <a href="#Matrix">Matrix</a> to: 2732 2733<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2734 |c -s dx| |J K L| |cJ-sM+dx*P cK-sN+dx*Q cL-sO+dx+R| 2735R(degrees, px, py) * Matrix = |s c dy| |M N O| = |sJ+cM+dy*P sK+cN+dy*Q sL+cO+dy*R| 2736 |0 0 1| |P Q R| | P Q R|</pre> 2737 2738### Parameters 2739 2740<table> <tr> <td><a name="SkMatrix_postRotate_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 2741angle of axes relative to upright axes</td> 2742 </tr> <tr> <td><a name="SkMatrix_postRotate_px"> <code><strong>px </strong></code> </a></td> <td> 2743pivot x</td> 2744 </tr> <tr> <td><a name="SkMatrix_postRotate_py"> <code><strong>py </strong></code> </a></td> <td> 2745pivot y</td> 2746 </tr> 2747</table> 2748 2749### Example 2750 2751<div><fiddle-embed name="e09194ee48a81e7b375ade473d340f0d"></fiddle-embed></div> 2752 2753### See Also 2754 2755<a href="#SkMatrix_preRotate">preRotate</a><sup><a href="#SkMatrix_preRotate_2">[2]</a></sup> <a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> 2756 2757--- 2758 2759<a name="SkMatrix_postRotate_2"></a> 2760 2761<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2762void postRotate(SkScalar degrees) 2763</pre> 2764 2765Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from rotating by <a href="#SkMatrix_postRotate_2_degrees">degrees</a> about pivot point 2766(0, 0), multiplied by <a href="#Matrix">Matrix</a>. 2767This can be thought of as rotating about the origin after applying <a href="#Matrix">Matrix</a>. 2768 2769Positive <a href="#SkMatrix_postRotate_2_degrees">degrees</a> rotates clockwise. 2770 2771Given: 2772 2773<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2774 | J K L | | c -s 0 | 2775Matrix = | M N O |, R(degrees, px, py) = | s c 0 | 2776 | P Q R | | 0 0 1 |</pre> 2777 2778where 2779 2780<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2781c = cos(degrees) 2782s = sin(degrees)</pre> 2783 2784sets <a href="#Matrix">Matrix</a> to: 2785 2786<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2787 | c -s dx | | J K L | | cJ-sM cK-sN cL-sO | 2788R(degrees, px, py) * Matrix = | s c dy | | M N O | = | sJ+cM sK+cN sL+cO | 2789 | 0 0 1 | | P Q R | | P Q R |</pre> 2790 2791### Parameters 2792 2793<table> <tr> <td><a name="SkMatrix_postRotate_2_degrees"> <code><strong>degrees </strong></code> </a></td> <td> 2794angle of axes relative to upright axes</td> 2795 </tr> 2796</table> 2797 2798### Example 2799 2800<div><fiddle-embed name="52e4c53e26971af5576b30de60fa70c2"></fiddle-embed></div> 2801 2802### See Also 2803 2804<a href="#SkMatrix_preRotate">preRotate</a><sup><a href="#SkMatrix_preRotate_2">[2]</a></sup> <a href="#SkMatrix_setRotate">setRotate</a><sup><a href="#SkMatrix_setRotate_2">[2]</a></sup> 2805 2806--- 2807 2808<a name="SkMatrix_postSkew"></a> 2809## postSkew 2810 2811<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2812void postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py) 2813</pre> 2814 2815Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from skewing by (<a href="#SkMatrix_postSkew_kx">kx</a>, <a href="#SkMatrix_postSkew_ky">ky</a>) about pivot point 2816(<a href="#SkMatrix_postSkew_px">px</a>, <a href="#SkMatrix_postSkew_py">py</a>), multiplied by <a href="#Matrix">Matrix</a>. 2817This can be thought of as skewing about a pivot point after applying <a href="#Matrix">Matrix</a>. 2818 2819Given: 2820 2821<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2822 | J K L | | 1 kx dx | 2823Matrix = | M N O |, K(kx, ky, px, py) = | ky 1 dy | 2824 | P Q R | | 0 0 1 |</pre> 2825 2826where 2827 2828<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2829dx = -kx * py 2830dy = -ky * px</pre> 2831 2832sets <a href="#Matrix">Matrix</a> to: 2833 2834<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2835 | 1 kx dx| |J K L| |J+kx*M+dx*P K+kx*N+dx*Q L+kx*O+dx+R| 2836K(kx, ky, px, py) * Matrix = |ky 1 dy| |M N O| = |ky*J+M+dy*P ky*K+N+dy*Q ky*L+O+dy*R| 2837 | 0 0 1| |P Q R| | P Q R|</pre> 2838 2839### Parameters 2840 2841<table> <tr> <td><a name="SkMatrix_postSkew_kx"> <code><strong>kx </strong></code> </a></td> <td> 2842horizontal skew factor</td> 2843 </tr> <tr> <td><a name="SkMatrix_postSkew_ky"> <code><strong>ky </strong></code> </a></td> <td> 2844vertical skew factor</td> 2845 </tr> <tr> <td><a name="SkMatrix_postSkew_px"> <code><strong>px </strong></code> </a></td> <td> 2846pivot x</td> 2847 </tr> <tr> <td><a name="SkMatrix_postSkew_py"> <code><strong>py </strong></code> </a></td> <td> 2848pivot y</td> 2849 </tr> 2850</table> 2851 2852### Example 2853 2854<div><fiddle-embed name="8c34ae3a2b7e2742bb969819737365ec"></fiddle-embed></div> 2855 2856### See Also 2857 2858<a href="#SkMatrix_preSkew">preSkew</a><sup><a href="#SkMatrix_preSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 2859 2860--- 2861 2862<a name="SkMatrix_postSkew_2"></a> 2863 2864<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2865void postSkew(SkScalar kx, SkScalar ky) 2866</pre> 2867 2868Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> constructed from skewing by (<a href="#SkMatrix_postSkew_2_kx">kx</a>, <a href="#SkMatrix_postSkew_2_ky">ky</a>) about pivot point 2869(0, 0), multiplied by <a href="#Matrix">Matrix</a>. 2870This can be thought of as skewing about the origin after applying <a href="#Matrix">Matrix</a>. 2871 2872Given: 2873 2874<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2875 | J K L | | 1 kx 0 | 2876Matrix = | M N O |, K(kx, ky) = | ky 1 0 | 2877 | P Q R | | 0 0 1 |</pre> 2878 2879sets <a href="#Matrix">Matrix</a> to: 2880 2881<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2882 | 1 kx 0 | | J K L | | J+kx*M K+kx*N L+kx*O | 2883K(kx, ky) * Matrix = | ky 1 0 | | M N O | = | ky*J+M ky*K+N ky*L+O | 2884 | 0 0 1 | | P Q R | | P Q R |</pre> 2885 2886### Parameters 2887 2888<table> <tr> <td><a name="SkMatrix_postSkew_2_kx"> <code><strong>kx </strong></code> </a></td> <td> 2889horizontal skew factor</td> 2890 </tr> <tr> <td><a name="SkMatrix_postSkew_2_ky"> <code><strong>ky </strong></code> </a></td> <td> 2891vertical skew factor</td> 2892 </tr> 2893</table> 2894 2895### Example 2896 2897<div><fiddle-embed name="3aa2603225dff72ac53dd359f897f494"></fiddle-embed></div> 2898 2899### See Also 2900 2901<a href="#SkMatrix_preSkew">preSkew</a><sup><a href="#SkMatrix_preSkew_2">[2]</a></sup> <a href="#SkMatrix_setSkew">setSkew</a><sup><a href="#SkMatrix_setSkew_2">[2]</a></sup> 2902 2903--- 2904 2905<a name="SkMatrix_postConcat"></a> 2906## postConcat 2907 2908<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2909void postConcat(const SkMatrix& other) 2910</pre> 2911 2912Sets <a href="#Matrix">Matrix</a> to <a href="#Matrix">Matrix</a> <a href="#SkMatrix_postConcat_other">other</a> multiplied by <a href="#Matrix">Matrix</a>. 2913This can be thought of mapping by <a href="#SkMatrix_postConcat_other">other</a> after applying <a href="#Matrix">Matrix</a>. 2914 2915Given: 2916 2917<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2918 | J K L | | A B C | 2919Matrix = | M N O |, other = | D E F | 2920 | P Q R | | G H I |</pre> 2921 2922sets <a href="#Matrix">Matrix</a> to: 2923 2924<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2925 | A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | 2926other * Matrix = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | 2927 | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |</pre> 2928 2929### Parameters 2930 2931<table> <tr> <td><a name="SkMatrix_postConcat_other"> <code><strong>other </strong></code> </a></td> <td> 2932<a href="#Matrix">Matrix</a> on left side of multiply expression</td> 2933 </tr> 2934</table> 2935 2936### Example 2937 2938<div><fiddle-embed name="0a4214289249c77f48d59227c4ac4d9e"></fiddle-embed></div> 2939 2940### See Also 2941 2942<a href="#SkMatrix_preConcat">preConcat</a> <a href="#SkMatrix_setConcat">setConcat</a> <a href="#SkMatrix_Concat">Concat</a> 2943 2944--- 2945 2946## <a name="SkMatrix_ScaleToFit"></a> Enum SkMatrix::ScaleToFit 2947 2948<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 2949enum <a href="#SkMatrix_ScaleToFit">ScaleToFit</a> { 2950<a href="#SkMatrix_kFill_ScaleToFit">kFill ScaleToFit</a>, 2951<a href="#SkMatrix_kStart_ScaleToFit">kStart ScaleToFit</a>, 2952<a href="#SkMatrix_kCenter_ScaleToFit">kCenter ScaleToFit</a>, 2953<a href="#SkMatrix_kEnd_ScaleToFit">kEnd ScaleToFit</a>, 2954};</pre> 2955 2956<a href="#SkMatrix_ScaleToFit">ScaleToFit</a> describes how <a href="#Matrix">Matrix</a> is constructed to map one <a href="SkRect_Reference#Rect">Rect</a> to another. 2957<a href="#SkMatrix_ScaleToFit">ScaleToFit</a> may allow <a href="#Matrix">Matrix</a> to have unequal horizontal and vertical scaling, 2958or may restrict <a href="#Matrix">Matrix</a> to square scaling. If restricted, <a href="#SkMatrix_ScaleToFit">ScaleToFit</a> specifies 2959how <a href="#Matrix">Matrix</a> maps to the side or center of the destination <a href="SkRect_Reference#Rect">Rect</a>. 2960 2961### Constants 2962 2963<table> 2964 <tr> 2965 <td><a name="SkMatrix_kFill_ScaleToFit"> <code><strong>SkMatrix::kFill_ScaleToFit </strong></code> </a></td><td>0</td><td>Computes <a href="#Matrix">Matrix</a> that scales in x and y independently, so that source <a href="SkRect_Reference#Rect">Rect</a> is 2966mapped to completely fill destination <a href="SkRect_Reference#Rect">Rect</a>. The aspect ratio of source <a href="SkRect_Reference#Rect">Rect</a> 2967may change.</td> 2968 </tr> 2969 <tr> 2970 <td><a name="SkMatrix_kStart_ScaleToFit"> <code><strong>SkMatrix::kStart_ScaleToFit </strong></code> </a></td><td>1</td><td>Computes <a href="#Matrix">Matrix</a> that maintains source <a href="SkRect_Reference#Rect">Rect</a> aspect ratio, mapping source <a href="SkRect_Reference#Rect">Rect</a> 2971width or height to destination <a href="SkRect_Reference#Rect">Rect</a>. Aligns mapping to left and top edges 2972of destination <a href="SkRect_Reference#Rect">Rect</a>.</td> 2973 </tr> 2974 <tr> 2975 <td><a name="SkMatrix_kCenter_ScaleToFit"> <code><strong>SkMatrix::kCenter_ScaleToFit </strong></code> </a></td><td>2</td><td>Computes <a href="#Matrix">Matrix</a> that maintains source <a href="SkRect_Reference#Rect">Rect</a> aspect ratio, mapping source <a href="SkRect_Reference#Rect">Rect</a> 2976width or height to destination <a href="SkRect_Reference#Rect">Rect</a>. Aligns mapping to center of destination 2977<a href="SkRect_Reference#Rect">Rect</a>.</td> 2978 </tr> 2979 <tr> 2980 <td><a name="SkMatrix_kEnd_ScaleToFit"> <code><strong>SkMatrix::kEnd_ScaleToFit </strong></code> </a></td><td>3</td><td>Computes <a href="#Matrix">Matrix</a> that maintains source <a href="SkRect_Reference#Rect">Rect</a> aspect ratio, mapping source <a href="SkRect_Reference#Rect">Rect</a> 2981width or height to destination <a href="SkRect_Reference#Rect">Rect</a>. Aligns mapping to right and bottom 2982edges of destination <a href="SkRect_Reference#Rect">Rect</a>.</td> 2983 </tr> 2984</table> 2985 2986### Example 2987 2988<div><fiddle-embed name="17c3070b31b700ea8f52e48af9a66b6e"></fiddle-embed></div> 2989 2990### See Also 2991 2992<a href="#SkMatrix_setRectToRect">setRectToRect</a> <a href="#SkMatrix_MakeRectToRect">MakeRectToRect</a> <a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> 2993 2994 2995 2996<a name="SkMatrix_setRectToRect"></a> 2997## setRectToRect 2998 2999<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3000bool setRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf) 3001</pre> 3002 3003Sets <a href="#Matrix">Matrix</a> to scale and translate <a href="#SkMatrix_setRectToRect_src">src</a> <a href="SkRect_Reference#Rect">Rect</a> to <a href="#SkMatrix_setRectToRect_dst">dst</a> <a href="SkRect_Reference#Rect">Rect</a>. <a href="#SkMatrix_setRectToRect_stf">stf</a> selects whether 3004mapping completely fills <a href="#SkMatrix_setRectToRect_dst">dst</a> or preserves the aspect ratio, and how to align 3005<a href="#SkMatrix_setRectToRect_src">src</a> within <a href="#SkMatrix_setRectToRect_dst">dst</a>. Returns false if <a href="#SkMatrix_setRectToRect_src">src</a> is empty, and sets <a href="#Matrix">Matrix</a> to identity. 3006Returns true if <a href="#SkMatrix_setRectToRect_dst">dst</a> is empty, and sets <a href="#Matrix">Matrix</a> to: 3007 3008<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3009| 0 0 0 | 3010| 0 0 0 | 3011| 0 0 1 |</pre> 3012 3013### Parameters 3014 3015<table> <tr> <td><a name="SkMatrix_setRectToRect_src"> <code><strong>src </strong></code> </a></td> <td> 3016<a href="SkRect_Reference#Rect">Rect</a> to map from</td> 3017 </tr> <tr> <td><a name="SkMatrix_setRectToRect_dst"> <code><strong>dst </strong></code> </a></td> <td> 3018<a href="SkRect_Reference#Rect">Rect</a> to map to</td> 3019 </tr> <tr> <td><a name="SkMatrix_setRectToRect_stf"> <code><strong>stf </strong></code> </a></td> <td> 3020one of: <a href="#SkMatrix_kFill_ScaleToFit">kFill ScaleToFit</a>, <a href="#SkMatrix_kStart_ScaleToFit">kStart ScaleToFit</a>, 3021<a href="#SkMatrix_kCenter_ScaleToFit">kCenter ScaleToFit</a>, <a href="#SkMatrix_kEnd_ScaleToFit">kEnd ScaleToFit</a></td> 3022 </tr> 3023</table> 3024 3025### Return Value 3026 3027true if <a href="#Matrix">Matrix</a> can represent <a href="SkRect_Reference#Rect">Rect</a> mapping 3028 3029### Example 3030 3031<div><fiddle-embed name="69cdea599dcaaec35efcb24403f4287b"> 3032 3033#### Example Output 3034 3035~~~~ 3036src: 0, 0, 0, 0 dst: 0, 0, 0, 0 success: false 3037[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 3038src: 0, 0, 0, 0 dst: 5, 6, 8, 9 success: false 3039[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 3040src: 1, 2, 3, 4 dst: 0, 0, 0, 0 success: true 3041[ 0.0000 0.0000 0.0000][ 0.0000 0.0000 0.0000][ 0.0000 0.0000 1.0000] 3042src: 1, 2, 3, 4 dst: 5, 6, 8, 9 success: true 3043[ 1.5000 0.0000 3.5000][ 0.0000 1.5000 3.0000][ 0.0000 0.0000 1.0000] 3044~~~~ 3045 3046</fiddle-embed></div> 3047 3048### See Also 3049 3050<a href="#SkMatrix_MakeRectToRect">MakeRectToRect</a> <a href="#SkMatrix_ScaleToFit">ScaleToFit</a> <a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> <a href="SkRect_Reference#SkRect_isEmpty">SkRect::isEmpty</a> 3051 3052--- 3053 3054<a name="SkMatrix_MakeRectToRect"></a> 3055## MakeRectToRect 3056 3057<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3058static SkMatrix MakeRectToRect(const SkRect& src, const SkRect& dst, ScaleToFit stf) 3059</pre> 3060 3061Returns <a href="#Matrix">Matrix</a> set to scale and translate <a href="#SkMatrix_MakeRectToRect_src">src</a> <a href="SkRect_Reference#Rect">Rect</a> to <a href="#SkMatrix_MakeRectToRect_dst">dst</a> <a href="SkRect_Reference#Rect">Rect</a>. <a href="#SkMatrix_MakeRectToRect_stf">stf</a> selects 3062whether mapping completely fills <a href="#SkMatrix_MakeRectToRect_dst">dst</a> or preserves the aspect ratio, and how to 3063align <a href="#SkMatrix_MakeRectToRect_src">src</a> within <a href="#SkMatrix_MakeRectToRect_dst">dst</a>. Returns the identity <a href="#Matrix">Matrix</a> if <a href="#SkMatrix_MakeRectToRect_src">src</a> is empty. If <a href="#SkMatrix_MakeRectToRect_dst">dst</a> is 3064empty, returns <a href="#Matrix">Matrix</a> set to: 3065 3066<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3067| 0 0 0 | 3068| 0 0 0 | 3069| 0 0 1 |</pre> 3070 3071### Parameters 3072 3073<table> <tr> <td><a name="SkMatrix_MakeRectToRect_src"> <code><strong>src </strong></code> </a></td> <td> 3074<a href="SkRect_Reference#Rect">Rect</a> to map from</td> 3075 </tr> <tr> <td><a name="SkMatrix_MakeRectToRect_dst"> <code><strong>dst </strong></code> </a></td> <td> 3076<a href="SkRect_Reference#Rect">Rect</a> to map to</td> 3077 </tr> <tr> <td><a name="SkMatrix_MakeRectToRect_stf"> <code><strong>stf </strong></code> </a></td> <td> 3078one of: <a href="#SkMatrix_kFill_ScaleToFit">kFill ScaleToFit</a>, <a href="#SkMatrix_kStart_ScaleToFit">kStart ScaleToFit</a>, 3079<a href="#SkMatrix_kCenter_ScaleToFit">kCenter ScaleToFit</a>, <a href="#SkMatrix_kEnd_ScaleToFit">kEnd ScaleToFit</a></td> 3080 </tr> 3081</table> 3082 3083### Return Value 3084 3085<a href="#Matrix">Matrix</a> mapping <a href="#SkMatrix_MakeRectToRect_src">src</a> to <a href="#SkMatrix_MakeRectToRect_dst">dst</a> 3086 3087### Example 3088 3089<div><fiddle-embed name="a1d6a6721b39350f81021f71a1b93208"> 3090 3091#### Example Output 3092 3093~~~~ 3094src: 0, 0, 0, 0 dst: 0, 0, 0, 0 3095[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 3096src: 0, 0, 0, 0 dst: 5, 6, 8, 9 3097[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 3098src: 1, 2, 3, 4 dst: 0, 0, 0, 0 3099[ 0.0000 0.0000 0.0000][ 0.0000 0.0000 0.0000][ 0.0000 0.0000 1.0000] 3100src: 1, 2, 3, 4 dst: 5, 6, 8, 9 3101[ 1.5000 0.0000 3.5000][ 0.0000 1.5000 3.0000][ 0.0000 0.0000 1.0000] 3102~~~~ 3103 3104</fiddle-embed></div> 3105 3106### See Also 3107 3108<a href="#SkMatrix_setRectToRect">setRectToRect</a> <a href="#SkMatrix_ScaleToFit">ScaleToFit</a> <a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> <a href="SkRect_Reference#SkRect_isEmpty">SkRect::isEmpty</a> 3109 3110--- 3111 3112<a name="SkMatrix_setPolyToPoly"></a> 3113## setPolyToPoly 3114 3115<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3116bool setPolyToPoly(const SkPoint src[], const SkPoint dst[], int count) 3117</pre> 3118 3119Sets <a href="#Matrix">Matrix</a> to map <a href="#SkMatrix_setPolyToPoly_src">src</a> to <a href="#SkMatrix_setPolyToPoly_dst">dst</a>. <a href="#SkMatrix_setPolyToPoly_count">count</a> must be zero or greater, and four or less. 3120 3121If <a href="#SkMatrix_setPolyToPoly_count">count</a> is zero, sets <a href="#Matrix">Matrix</a> to identity and returns true. 3122If <a href="#SkMatrix_setPolyToPoly_count">count</a> is one, sets <a href="#Matrix">Matrix</a> to translate and returns true. 3123If <a href="#SkMatrix_setPolyToPoly_count">count</a> is two or more, sets <a href="#Matrix">Matrix</a> to map <a href="SkPoint_Reference#Point">Points</a> if possible; returns false 3124if <a href="#Matrix">Matrix</a> cannot be constructed. If <a href="#SkMatrix_setPolyToPoly_count">count</a> is four, <a href="#Matrix">Matrix</a> may include 3125perspective. 3126 3127### Parameters 3128 3129<table> <tr> <td><a name="SkMatrix_setPolyToPoly_src"> <code><strong>src </strong></code> </a></td> <td> 3130<a href="SkPoint_Reference#Point">Points</a> to map from</td> 3131 </tr> <tr> <td><a name="SkMatrix_setPolyToPoly_dst"> <code><strong>dst </strong></code> </a></td> <td> 3132<a href="SkPoint_Reference#Point">Points</a> to map to</td> 3133 </tr> <tr> <td><a name="SkMatrix_setPolyToPoly_count"> <code><strong>count </strong></code> </a></td> <td> 3134number of <a href="SkPoint_Reference#Point">Points</a> in <a href="#SkMatrix_setPolyToPoly_src">src</a> and <a href="#SkMatrix_setPolyToPoly_dst">dst</a></td> 3135 </tr> 3136</table> 3137 3138### Return Value 3139 3140true if <a href="#Matrix">Matrix</a> was constructed successfully 3141 3142### Example 3143 3144<div><fiddle-embed name="c851d1313e8909aaea4f0591699fdb7b"></fiddle-embed></div> 3145 3146### See Also 3147 3148<a href="#SkMatrix_setRectToRect">setRectToRect</a> <a href="#SkMatrix_MakeRectToRect">MakeRectToRect</a> 3149 3150--- 3151 3152<a name="SkMatrix_invert"></a> 3153## invert 3154 3155<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3156bool SK_WARN_UNUSED_RESULT invert(SkMatrix* inverse) const 3157</pre> 3158 3159Sets <a href="#SkMatrix_invert_inverse">inverse</a> to reciprocal matrix, returning true if <a href="#Matrix">Matrix</a> can be inverted. 3160Geometrically, if <a href="#Matrix">Matrix</a> maps from source to destination, <a href="#SkMatrix_invert_inverse">inverse</a> <a href="#Matrix">Matrix</a> 3161maps from destination to source. If <a href="#Matrix">Matrix</a> can not be inverted, <a href="#SkMatrix_invert_inverse">inverse</a> is 3162unchanged. 3163 3164### Parameters 3165 3166<table> <tr> <td><a name="SkMatrix_invert_inverse"> <code><strong>inverse </strong></code> </a></td> <td> 3167storage for inverted <a href="#Matrix">Matrix</a>; may be nullptr</td> 3168 </tr> 3169</table> 3170 3171### Return Value 3172 3173true if <a href="#Matrix">Matrix</a> can be inverted 3174 3175### Example 3176 3177<div><fiddle-embed name="10a10c5bf2ac7ec88e84204441fc83b6"></fiddle-embed></div> 3178 3179### See Also 3180 3181<a href="#SkMatrix_Concat">Concat</a> 3182 3183--- 3184 3185<a name="SkMatrix_SetAffineIdentity"></a> 3186## SetAffineIdentity 3187 3188<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3189static void SetAffineIdentity(SkScalar affine[6]) 3190</pre> 3191 3192Fills <a href="#SkMatrix_SetAffineIdentity_affine">affine</a> with identity values in column major order. 3193Sets <a href="#SkMatrix_SetAffineIdentity_affine">affine</a> to: 3194 3195<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3196| 1 0 0 | 3197| 0 1 0 |</pre> 3198 3199Affine 3x2 matrices in column major order are used by OpenGL and XPS. 3200 3201### Parameters 3202 3203<table> <tr> <td><a name="SkMatrix_SetAffineIdentity_affine"> <code><strong>affine </strong></code> </a></td> <td> 3204storage for 3x2 <a href="#SkMatrix_SetAffineIdentity_affine">affine</a> matrix</td> 3205 </tr> 3206</table> 3207 3208### Example 3209 3210<div><fiddle-embed name="e10adbd0bcc940c5d4d872db0e78e892"> 3211 3212#### Example Output 3213 3214~~~~ 3215ScaleX: 1 SkewY: 0 SkewX: 0 ScaleY: 1 TransX: 0 TransY: 0 3216~~~~ 3217 3218</fiddle-embed></div> 3219 3220### See Also 3221 3222<a href="#SkMatrix_setAffine">setAffine</a> <a href="#SkMatrix_asAffine">asAffine</a> 3223 3224--- 3225 3226<a name="SkMatrix_asAffine"></a> 3227## asAffine 3228 3229<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3230bool SK_WARN_UNUSED_RESULT asAffine(SkScalar affine[6]) const 3231</pre> 3232 3233Fills <a href="#SkMatrix_asAffine_affine">affine</a> in column major order. Sets <a href="#SkMatrix_asAffine_affine">affine</a> to: 3234 3235<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3236| scale-x skew-x translate-x | 3237| skew-y scale-y translate-y |</pre> 3238 3239If <a href="#Matrix">Matrix</a> contains perspective, returns false and leaves <a href="#SkMatrix_asAffine_affine">affine</a> unchanged. 3240 3241### Parameters 3242 3243<table> <tr> <td><a name="SkMatrix_asAffine_affine"> <code><strong>affine </strong></code> </a></td> <td> 3244storage for 3x2 <a href="#SkMatrix_asAffine_affine">affine</a> matrix; may be nullptr</td> 3245 </tr> 3246</table> 3247 3248### Return Value 3249 3250true if <a href="#Matrix">Matrix</a> does not contain perspective 3251 3252### Example 3253 3254<div><fiddle-embed name="752e4a48ed1dae05765a2499c390f277"> 3255 3256#### Example Output 3257 3258~~~~ 3259ScaleX: 2 SkewY: 5 SkewX: 3 ScaleY: 6 TransX: 4 TransY: 7 3260~~~~ 3261 3262</fiddle-embed></div> 3263 3264### See Also 3265 3266<a href="#SkMatrix_setAffine">setAffine</a> <a href="#SkMatrix_SetAffineIdentity">SetAffineIdentity</a> 3267 3268--- 3269 3270<a name="SkMatrix_setAffine"></a> 3271## setAffine 3272 3273<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3274void setAffine(const SkScalar affine[6]) 3275</pre> 3276 3277Sets <a href="#Matrix">Matrix</a> to <a href="#SkMatrix_setAffine_affine">affine</a> values, passed in column major order. Given <a href="#SkMatrix_setAffine_affine">affine</a>, 3278column, then row, as: 3279 3280<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3281| scale-x skew-x translate-x | 3282| skew-y scale-y translate-y |</pre> 3283 3284<a href="#Matrix">Matrix</a> is set, row, then column, to: 3285 3286<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3287| scale-x skew-x translate-x | 3288| skew-y scale-y translate-y | 3289| 0 0 1 |</pre> 3290 3291### Parameters 3292 3293<table> <tr> <td><a name="SkMatrix_setAffine_affine"> <code><strong>affine </strong></code> </a></td> <td> 32943x2 <a href="#SkMatrix_setAffine_affine">affine</a> matrix</td> 3295 </tr> 3296</table> 3297 3298### Example 3299 3300<div><fiddle-embed name="403370bd53526f59020a7141955d70b0"> 3301 3302#### Example Output 3303 3304~~~~ 3305ScaleX: 2 SkewY: 5 SkewX: 3 ScaleY: 6 TransX: 4 TransY: 7 3306[ 2.0000 3.0000 4.0000][ 5.0000 6.0000 7.0000][ 0.0000 0.0000 1.0000] 3307~~~~ 3308 3309</fiddle-embed></div> 3310 3311### See Also 3312 3313<a href="#SkMatrix_asAffine">asAffine</a> <a href="#SkMatrix_SetAffineIdentity">SetAffineIdentity</a> 3314 3315--- 3316 3317## <a name="Transform"></a> Transform 3318 3319| name | description | 3320| --- | --- | 3321| <a href="#SkMatrix_mapHomogeneousPoints">mapHomogeneousPoints</a> | maps <a href="undocumented#Point3">Point3</a> array | 3322| <a href="#SkMatrix_mapPoints">mapPoints</a> | maps <a href="SkPoint_Reference#Point">Point</a> array | 3323| | <a href="#SkMatrix_mapPoints">mapPoints(SkPoint dst[], const SkPoint src[], int count)</a> const | 3324| | <a href="#SkMatrix_mapPoints_2">mapPoints(SkPoint pts[], int count)</a> const | 3325| <a href="#SkMatrix_mapRadius">mapRadius</a> | returns mean radius of mapped <a href="undocumented#Circle">Circle</a> | 3326| <a href="#SkMatrix_mapRect">mapRect</a> | returns bounds of mapped <a href="SkRect_Reference#Rect">Rect</a> | 3327| | <a href="#SkMatrix_mapRect">mapRect(SkRect* dst, const SkRect& src)</a> const | 3328| | <a href="#SkMatrix_mapRect_2">mapRect(SkRect* rect)</a> const | 3329| <a href="#SkMatrix_mapRectScaleTranslate">mapRectScaleTranslate</a> | returns bounds of mapped <a href="SkRect_Reference#Rect">Rect</a> | 3330| <a href="#SkMatrix_mapRectToQuad">mapRectToQuad</a> | maps <a href="SkRect_Reference#Rect">Rect</a> to <a href="SkPoint_Reference#Point">Point</a> array | 3331| <a href="#SkMatrix_mapVector">mapVector</a> | maps <a href="SkPoint_Reference#Vector">Vector</a> | 3332| | <a href="#SkMatrix_mapVector">mapVector(SkScalar dx, SkScalar dy, SkVector* result)</a> const | 3333| | <a href="#SkMatrix_mapVector_2">mapVector(SkScalar dx, SkScalar dy)</a> const | 3334| <a href="#SkMatrix_mapVectors">mapVectors</a> | maps <a href="SkPoint_Reference#Vector">Vector</a> array | 3335| | <a href="#SkMatrix_mapVectors">mapVectors(SkVector dst[], const SkVector src[], int count)</a> const | 3336| | <a href="#SkMatrix_mapVectors_2">mapVectors(SkVector vecs[], int count)</a> const | 3337| <a href="#SkMatrix_mapXY">mapXY</a> | maps <a href="SkPoint_Reference#Point">Point</a> | 3338| | <a href="#SkMatrix_mapXY">mapXY(SkScalar x, SkScalar y, SkPoint* result)</a> const | 3339| | <a href="#SkMatrix_mapXY_2">mapXY(SkScalar x, SkScalar y)</a> const | 3340 3341<a name="SkMatrix_mapPoints"></a> 3342## mapPoints 3343 3344<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3345void mapPoints(SkPoint dst[], const SkPoint src[], int count) const 3346</pre> 3347 3348Maps <a href="#SkMatrix_mapPoints_src">src</a> <a href="SkPoint_Reference#Point">Point</a> array of length <a href="#SkMatrix_mapPoints_count">count</a> to <a href="#SkMatrix_mapPoints_dst">dst</a> <a href="SkPoint_Reference#Point">Point</a> array of equal or greater 3349length. <a href="SkPoint_Reference#Point">Points</a> are mapped by multiplying each <a href="SkPoint_Reference#Point">Point</a> by <a href="#Matrix">Matrix</a>. Given: 3350 3351<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3352 | A B C | | x | 3353Matrix = | D E F |, pt = | y | 3354 | G H I | | 1 |</pre> 3355 3356where 3357 3358<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3359for (i = 0; i < count; ++i) { 3360 x = src[i].fX 3361 y = src[i].fY 3362}</pre> 3363 3364each <a href="#SkMatrix_mapPoints_dst">dst</a> <a href="SkPoint_Reference#Point">Point</a> is computed as: 3365 3366<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3367 |A B C| |x| Ax+By+C Dx+Ey+F 3368Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- 3369 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3370 3371<a href="#SkMatrix_mapPoints_src">src</a> and <a href="#SkMatrix_mapPoints_dst">dst</a> may point to the same storage. 3372 3373### Parameters 3374 3375<table> <tr> <td><a name="SkMatrix_mapPoints_dst"> <code><strong>dst </strong></code> </a></td> <td> 3376storage for mapped <a href="SkPoint_Reference#Point">Points</a></td> 3377 </tr> <tr> <td><a name="SkMatrix_mapPoints_src"> <code><strong>src </strong></code> </a></td> <td> 3378<a href="SkPoint_Reference#Point">Points</a> to transform</td> 3379 </tr> <tr> <td><a name="SkMatrix_mapPoints_count"> <code><strong>count </strong></code> </a></td> <td> 3380number of <a href="SkPoint_Reference#Point">Points</a> to transform</td> 3381 </tr> 3382</table> 3383 3384### Example 3385 3386<div><fiddle-embed name="f99dcb00296d0c56b6c0e178e94b3534"></fiddle-embed></div> 3387 3388### See Also 3389 3390<a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> <a href="#SkMatrix_mapHomogeneousPoints">mapHomogeneousPoints</a> <a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> 3391 3392--- 3393 3394<a name="SkMatrix_mapPoints_2"></a> 3395 3396<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3397void mapPoints(SkPoint pts[], int count) const 3398</pre> 3399 3400Maps <a href="#SkMatrix_mapPoints_2_pts">pts</a> <a href="SkPoint_Reference#Point">Point</a> array of length <a href="#SkMatrix_mapPoints_2_count">count</a> in place. <a href="SkPoint_Reference#Point">Points</a> are mapped by multiplying 3401each <a href="SkPoint_Reference#Point">Point</a> by <a href="#Matrix">Matrix</a>. Given: 3402 3403<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3404 | A B C | | x | 3405Matrix = | D E F |, pt = | y | 3406 | G H I | | 1 |</pre> 3407 3408where 3409 3410<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3411for (i = 0; i < count; ++i) { 3412 x = pts[i].fX 3413 y = pts[i].fY 3414}</pre> 3415 3416each resulting <a href="#SkMatrix_mapPoints_2_pts">pts</a> <a href="SkPoint_Reference#Point">Point</a> is computed as: 3417 3418<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3419 |A B C| |x| Ax+By+C Dx+Ey+F 3420Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- 3421 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3422 3423### Parameters 3424 3425<table> <tr> <td><a name="SkMatrix_mapPoints_2_pts"> <code><strong>pts </strong></code> </a></td> <td> 3426storage for mapped <a href="SkPoint_Reference#Point">Points</a></td> 3427 </tr> <tr> <td><a name="SkMatrix_mapPoints_2_count"> <code><strong>count </strong></code> </a></td> <td> 3428number of <a href="SkPoint_Reference#Point">Points</a> to transform</td> 3429 </tr> 3430</table> 3431 3432### Example 3433 3434<div><fiddle-embed name="428ca171ae3bd0d3f992458ac598b97b"></fiddle-embed></div> 3435 3436### See Also 3437 3438<a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> <a href="#SkMatrix_mapHomogeneousPoints">mapHomogeneousPoints</a> <a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> 3439 3440--- 3441 3442<a name="SkMatrix_mapHomogeneousPoints"></a> 3443## mapHomogeneousPoints 3444 3445<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3446void mapHomogeneousPoints(SkPoint3 dst[], const SkPoint3 src[], int count) const 3447</pre> 3448 3449Maps <a href="#SkMatrix_mapHomogeneousPoints_src">src</a> <a href="undocumented#Point3">Point3</a> array of length <a href="#SkMatrix_mapHomogeneousPoints_count">count</a> to <a href="#SkMatrix_mapHomogeneousPoints_dst">dst</a> <a href="undocumented#Point3">Point3</a> array, which must of length <a href="#SkMatrix_mapHomogeneousPoints_count">count</a> or 3450greater. <a href="undocumented#Point3">Point3</a> array is mapped by multiplying each <a href="undocumented#Point3">Point3</a> by <a href="#Matrix">Matrix</a>. Given: 3451 3452<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3453 | A B C | | x | 3454Matrix = | D E F |, src = | y | 3455 | G H I | | z |</pre> 3456 3457each resulting <a href="#SkMatrix_mapHomogeneousPoints_dst">dst</a> <a href="SkPoint_Reference#Point">Point</a> is computed as: 3458 3459<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3460 |A B C| |x| 3461Matrix * src = |D E F| |y| = |Ax+By+Cz Dx+Ey+Fz Gx+Hy+Iz| 3462 |G H I| |z|</pre> 3463 3464### Parameters 3465 3466<table> <tr> <td><a name="SkMatrix_mapHomogeneousPoints_dst"> <code><strong>dst </strong></code> </a></td> <td> 3467storage for mapped <a href="undocumented#Point3">Point3</a> array</td> 3468 </tr> <tr> <td><a name="SkMatrix_mapHomogeneousPoints_src"> <code><strong>src </strong></code> </a></td> <td> 3469<a href="undocumented#Point3">Point3</a> array to transform</td> 3470 </tr> <tr> <td><a name="SkMatrix_mapHomogeneousPoints_count"> <code><strong>count </strong></code> </a></td> <td> 3471items in <a href="undocumented#Point3">Point3</a> array to transform</td> 3472 </tr> 3473</table> 3474 3475### Example 3476 3477<div><fiddle-embed name="d56f93e4bc763c7ba4914321ed07a8b5"></fiddle-embed></div> 3478 3479### See Also 3480 3481<a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> <a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> 3482 3483--- 3484 3485<a name="SkMatrix_mapXY"></a> 3486## mapXY 3487 3488<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3489void mapXY(SkScalar x, SkScalar y, SkPoint* result) const 3490</pre> 3491 3492Maps <a href="SkPoint_Reference#Point">Point</a> (<a href="#SkMatrix_mapXY_x">x</a>, <a href="#SkMatrix_mapXY_y">y</a>) to <a href="#SkMatrix_mapXY_result">result</a>. <a href="SkPoint_Reference#Point">Point</a> is mapped by multiplying by <a href="#Matrix">Matrix</a>. Given: 3493 3494<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3495 | A B C | | x | 3496Matrix = | D E F |, pt = | y | 3497 | G H I | | 1 |</pre> 3498 3499<a href="#SkMatrix_mapXY_result">result</a> is computed as: 3500 3501<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3502 |A B C| |x| Ax+By+C Dx+Ey+F 3503Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- 3504 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3505 3506### Parameters 3507 3508<table> <tr> <td><a name="SkMatrix_mapXY_x"> <code><strong>x </strong></code> </a></td> <td> 3509<a href="#SkMatrix_mapXY_x">x</a>-coordinate of <a href="SkPoint_Reference#Point">Point</a> to map</td> 3510 </tr> <tr> <td><a name="SkMatrix_mapXY_y"> <code><strong>y </strong></code> </a></td> <td> 3511<a href="#SkMatrix_mapXY_y">y</a>-coordinate of <a href="SkPoint_Reference#Point">Point</a> to map</td> 3512 </tr> <tr> <td><a name="SkMatrix_mapXY_result"> <code><strong>result </strong></code> </a></td> <td> 3513storage for mapped <a href="SkPoint_Reference#Point">Point</a></td> 3514 </tr> 3515</table> 3516 3517### Example 3518 3519<div><fiddle-embed name="9e50185d502dc6903783679a84106089"></fiddle-embed></div> 3520 3521### See Also 3522 3523<a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> 3524 3525--- 3526 3527<a name="SkMatrix_mapXY_2"></a> 3528 3529<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3530SkPoint mapXY(SkScalar x, SkScalar y) const 3531</pre> 3532 3533Returns <a href="SkPoint_Reference#Point">Point</a> (<a href="#SkMatrix_mapXY_2_x">x</a>, <a href="#SkMatrix_mapXY_2_y">y</a>) multiplied by <a href="#Matrix">Matrix</a>. Given: 3534 3535<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3536 | A B C | | x | 3537Matrix = | D E F |, pt = | y | 3538 | G H I | | 1 |</pre> 3539 3540result is computed as: 3541 3542<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3543 |A B C| |x| Ax+By+C Dx+Ey+F 3544Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- 3545 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3546 3547### Parameters 3548 3549<table> <tr> <td><a name="SkMatrix_mapXY_2_x"> <code><strong>x </strong></code> </a></td> <td> 3550<a href="#SkMatrix_mapXY_2_x">x</a>-coordinate of <a href="SkPoint_Reference#Point">Point</a> to map</td> 3551 </tr> <tr> <td><a name="SkMatrix_mapXY_2_y"> <code><strong>y </strong></code> </a></td> <td> 3552<a href="#SkMatrix_mapXY_2_y">y</a>-coordinate of <a href="SkPoint_Reference#Point">Point</a> to map</td> 3553 </tr> 3554</table> 3555 3556### Return Value 3557 3558mapped <a href="SkPoint_Reference#Point">Point</a> 3559 3560### Example 3561 3562<div><fiddle-embed name="b1ead09c67a177ab8eace12b061610a7"></fiddle-embed></div> 3563 3564### See Also 3565 3566<a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> 3567 3568--- 3569 3570<a name="SkMatrix_mapVectors"></a> 3571## mapVectors 3572 3573<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3574void mapVectors(SkVector dst[], const SkVector src[], int count) const 3575</pre> 3576 3577Maps <a href="#SkMatrix_mapVectors_src">src</a> <a href="SkPoint_Reference#Vector">Vector</a> array of length <a href="#SkMatrix_mapVectors_count">count</a> to <a href="SkPoint_Reference#Vector">Vector</a> <a href="SkPoint_Reference#Point">Point</a> array of equal or greater 3578length. <a href="SkPoint_Reference#Vector">Vectors</a> are mapped by multiplying each <a href="SkPoint_Reference#Vector">Vector</a> by <a href="#Matrix">Matrix</a>, treating 3579<a href="#Matrix">Matrix</a> translation as zero. Given: 3580 3581<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3582 | A B 0 | | x | 3583Matrix = | D E 0 |, src = | y | 3584 | G H I | | 1 |</pre> 3585 3586where 3587 3588<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3589for (i = 0; i < count; ++i) { 3590 x = src[i].fX 3591 y = src[i].fY 3592}</pre> 3593 3594each <a href="#SkMatrix_mapVectors_dst">dst</a> <a href="SkPoint_Reference#Vector">Vector</a> is computed as: 3595 3596<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3597 |A B 0| |x| Ax+By Dx+Ey 3598Matrix * src = |D E 0| |y| = |Ax+By Dx+Ey Gx+Hy+I| = ------- , ------- 3599 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3600 3601<a href="#SkMatrix_mapVectors_src">src</a> and <a href="#SkMatrix_mapVectors_dst">dst</a> may point to the same storage. 3602 3603### Parameters 3604 3605<table> <tr> <td><a name="SkMatrix_mapVectors_dst"> <code><strong>dst </strong></code> </a></td> <td> 3606storage for mapped <a href="SkPoint_Reference#Vector">Vectors</a></td> 3607 </tr> <tr> <td><a name="SkMatrix_mapVectors_src"> <code><strong>src </strong></code> </a></td> <td> 3608<a href="SkPoint_Reference#Vector">Vectors</a> to transform</td> 3609 </tr> <tr> <td><a name="SkMatrix_mapVectors_count"> <code><strong>count </strong></code> </a></td> <td> 3610number of <a href="SkPoint_Reference#Vector">Vectors</a> to transform</td> 3611 </tr> 3612</table> 3613 3614### Example 3615 3616<div><fiddle-embed name="918a9778c3d7d5cb306692784399f6dc"></fiddle-embed></div> 3617 3618### See Also 3619 3620<a href="#SkMatrix_mapVector">mapVector</a><sup><a href="#SkMatrix_mapVector_2">[2]</a></sup> <a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> 3621 3622--- 3623 3624<a name="SkMatrix_mapVectors_2"></a> 3625 3626<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3627void mapVectors(SkVector vecs[], int count) const 3628</pre> 3629 3630Maps <a href="#SkMatrix_mapVectors_2_vecs">vecs</a> <a href="SkPoint_Reference#Vector">Vector</a> array of length <a href="#SkMatrix_mapVectors_2_count">count</a> in place, multiplying each <a href="SkPoint_Reference#Vector">Vector</a> by 3631<a href="#Matrix">Matrix</a>, treating <a href="#Matrix">Matrix</a> translation as zero. Given: 3632 3633<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3634 | A B 0 | | x | 3635Matrix = | D E 0 |, vec = | y | 3636 | G H I | | 1 |</pre> 3637 3638where 3639 3640<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3641for (i = 0; i < count; ++i) { 3642 x = vecs[i].fX 3643 y = vecs[i].fY 3644}</pre> 3645 3646each result <a href="SkPoint_Reference#Vector">Vector</a> is computed as: 3647 3648<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3649 |A B 0| |x| Ax+By Dx+Ey 3650Matrix * vec = |D E 0| |y| = |Ax+By Dx+Ey Gx+Hy+I| = ------- , ------- 3651 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3652 3653### Parameters 3654 3655<table> <tr> <td><a name="SkMatrix_mapVectors_2_vecs"> <code><strong>vecs </strong></code> </a></td> <td> 3656<a href="SkPoint_Reference#Vector">Vectors</a> to transform, and storage for mapped <a href="SkPoint_Reference#Vector">Vectors</a></td> 3657 </tr> <tr> <td><a name="SkMatrix_mapVectors_2_count"> <code><strong>count </strong></code> </a></td> <td> 3658number of <a href="SkPoint_Reference#Vector">Vectors</a> to transform</td> 3659 </tr> 3660</table> 3661 3662### Example 3663 3664<div><fiddle-embed name="5754501a00a1323e76353fb53153e939"></fiddle-embed></div> 3665 3666### See Also 3667 3668<a href="#SkMatrix_mapVector">mapVector</a><sup><a href="#SkMatrix_mapVector_2">[2]</a></sup> <a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> 3669 3670--- 3671 3672<a name="SkMatrix_mapVector"></a> 3673## mapVector 3674 3675<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3676void mapVector(SkScalar dx, SkScalar dy, SkVector* result) const 3677</pre> 3678 3679Maps <a href="SkPoint_Reference#Vector">Vector</a> (x, y) to <a href="#SkMatrix_mapVector_result">result</a>. <a href="SkPoint_Reference#Vector">Vector</a> is mapped by multiplying by <a href="#Matrix">Matrix</a>, 3680treating <a href="#Matrix">Matrix</a> translation as zero. Given: 3681 3682<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3683 | A B 0 | | dx | 3684Matrix = | D E 0 |, vec = | dy | 3685 | G H I | | 1 |</pre> 3686 3687each <a href="#SkMatrix_mapVector_result">result</a> <a href="SkPoint_Reference#Vector">Vector</a> is computed as: 3688 3689<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3690 |A B 0| |dx| A*dx+B*dy D*dx+E*dy 3691Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , ----------- 3692 |G H I| | 1| G*dx+H*dy+I G*dx+*dHy+I</pre> 3693 3694### Parameters 3695 3696<table> <tr> <td><a name="SkMatrix_mapVector_dx"> <code><strong>dx </strong></code> </a></td> <td> 3697x-coordinate of <a href="SkPoint_Reference#Vector">Vector</a> to map</td> 3698 </tr> <tr> <td><a name="SkMatrix_mapVector_dy"> <code><strong>dy </strong></code> </a></td> <td> 3699y-coordinate of <a href="SkPoint_Reference#Vector">Vector</a> to map</td> 3700 </tr> <tr> <td><a name="SkMatrix_mapVector_result"> <code><strong>result </strong></code> </a></td> <td> 3701storage for mapped <a href="SkPoint_Reference#Vector">Vector</a></td> 3702 </tr> 3703</table> 3704 3705### Example 3706 3707<div><fiddle-embed name="aed143fc6cd0bce4ed029b98d1e61f2d"></fiddle-embed></div> 3708 3709### See Also 3710 3711<a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> <a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> 3712 3713--- 3714 3715<a name="SkMatrix_mapVector_2"></a> 3716 3717<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3718SkVector mapVector(SkScalar dx, SkScalar dy) const 3719</pre> 3720 3721Returns <a href="SkPoint_Reference#Vector">Vector</a> (x, y) multiplied by <a href="#Matrix">Matrix</a>, treating <a href="#Matrix">Matrix</a> translation as zero. 3722Given: 3723 3724<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3725 | A B 0 | | dx | 3726Matrix = | D E 0 |, vec = | dy | 3727 | G H I | | 1 |</pre> 3728 3729each result <a href="SkPoint_Reference#Vector">Vector</a> is computed as: 3730 3731<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3732 |A B 0| |dx| A*dx+B*dy D*dx+E*dy 3733Matrix * vec = |D E 0| |dy| = |A*dx+B*dy D*dx+E*dy G*dx+H*dy+I| = ----------- , ----------- 3734 |G H I| | 1| G*dx+H*dy+I G*dx+*dHy+I</pre> 3735 3736### Parameters 3737 3738<table> <tr> <td><a name="SkMatrix_mapVector_2_dx"> <code><strong>dx </strong></code> </a></td> <td> 3739x-coordinate of <a href="SkPoint_Reference#Vector">Vector</a> to map</td> 3740 </tr> <tr> <td><a name="SkMatrix_mapVector_2_dy"> <code><strong>dy </strong></code> </a></td> <td> 3741y-coordinate of <a href="SkPoint_Reference#Vector">Vector</a> to map</td> 3742 </tr> 3743</table> 3744 3745### Return Value 3746 3747mapped <a href="SkPoint_Reference#Vector">Vector</a> 3748 3749### Example 3750 3751<div><fiddle-embed name="8bf1518db3f369696cd3065b541a8bd7"></fiddle-embed></div> 3752 3753### See Also 3754 3755<a href="#SkMatrix_mapVectors">mapVectors</a><sup><a href="#SkMatrix_mapVectors_2">[2]</a></sup> <a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_mapXY">mapXY</a><sup><a href="#SkMatrix_mapXY_2">[2]</a></sup> 3756 3757--- 3758 3759<a name="SkMatrix_mapRect"></a> 3760## mapRect 3761 3762<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3763bool mapRect(SkRect* dst, const SkRect& src) const 3764</pre> 3765 3766Sets <a href="#SkMatrix_mapRect_dst">dst</a> to bounds of <a href="#SkMatrix_mapRect_src">src</a> corners mapped by <a href="#Matrix">Matrix</a>. 3767Returns true if mapped corners are <a href="#SkMatrix_mapRect_dst">dst</a> corners. 3768 3769Returned value is the same as calling <a href="#SkMatrix_rectStaysRect">rectStaysRect</a>. 3770 3771### Parameters 3772 3773<table> <tr> <td><a name="SkMatrix_mapRect_dst"> <code><strong>dst </strong></code> </a></td> <td> 3774storage for bounds of mapped <a href="SkPoint_Reference#Point">Points</a></td> 3775 </tr> <tr> <td><a name="SkMatrix_mapRect_src"> <code><strong>src </strong></code> </a></td> <td> 3776<a href="SkRect_Reference#Rect">Rect</a> to map</td> 3777 </tr> 3778</table> 3779 3780### Return Value 3781 3782true if <a href="#SkMatrix_mapRect_dst">dst</a> is equivalent to mapped <a href="#SkMatrix_mapRect_src">src</a> 3783 3784### Example 3785 3786<div><fiddle-embed name="dbcf928b035a31ca69c99392e2e2cca9"></fiddle-embed></div> 3787 3788### See Also 3789 3790<a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> 3791 3792--- 3793 3794<a name="SkMatrix_mapRect_2"></a> 3795 3796<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3797bool mapRect(SkRect* rect) const 3798</pre> 3799 3800Sets <a href="#SkMatrix_mapRect_2_rect">rect</a> to bounds of <a href="#SkMatrix_mapRect_2_rect">rect</a> corners mapped by <a href="#Matrix">Matrix</a>. 3801Returns true if mapped corners are computed <a href="#SkMatrix_mapRect_2_rect">rect</a> corners. 3802 3803Returned value is the same as calling <a href="#SkMatrix_rectStaysRect">rectStaysRect</a>. 3804 3805### Parameters 3806 3807<table> <tr> <td><a name="SkMatrix_mapRect_2_rect"> <code><strong>rect </strong></code> </a></td> <td> 3808rectangle to map, and storage for bounds of mapped corners</td> 3809 </tr> 3810</table> 3811 3812### Return Value 3813 3814true if result is equivalent to mapped src 3815 3816### Example 3817 3818<div><fiddle-embed name="5fafd0bd23d1ed37425b970b4a3c6cc9"></fiddle-embed></div> 3819 3820### See Also 3821 3822<a href="#SkMatrix_mapRectScaleTranslate">mapRectScaleTranslate</a> <a href="#SkMatrix_mapPoints">mapPoints</a><sup><a href="#SkMatrix_mapPoints_2">[2]</a></sup> <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> 3823 3824--- 3825 3826<a name="SkMatrix_mapRectToQuad"></a> 3827## mapRectToQuad 3828 3829<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3830void mapRectToQuad(SkPoint dst[4], const SkRect& rect) const 3831</pre> 3832 3833Maps four corners of <a href="#SkMatrix_mapRectToQuad_rect">rect</a> to <a href="#SkMatrix_mapRectToQuad_dst">dst</a>. <a href="SkPoint_Reference#Point">Points</a> are mapped by multiplying each 3834<a href="#SkMatrix_mapRectToQuad_rect">rect</a> corner by <a href="#Matrix">Matrix</a>. <a href="#SkMatrix_mapRectToQuad_rect">rect</a> corner is processed in this order: 3835(<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fLeft, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fTop), (<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fRight, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fTop), (<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fRight, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fBottom), 3836(<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fLeft, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fBottom). 3837 3838<a href="#SkMatrix_mapRectToQuad_rect">rect</a> may be empty: <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fLeft may be greater than or equal to <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fRight; 3839<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fTop may be greater than or equal to <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fBottom. 3840 3841Given: 3842 3843<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3844 | A B C | | x | 3845Matrix = | D E F |, pt = | y | 3846 | G H I | | 1 |</pre> 3847 3848where pt is initialized from each of (<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fLeft, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fTop), 3849(<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fRight, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fTop), (<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fRight, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fBottom), (<a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fLeft, <a href="#SkMatrix_mapRectToQuad_rect">rect</a>.fBottom), 3850each <a href="#SkMatrix_mapRectToQuad_dst">dst</a> <a href="SkPoint_Reference#Point">Point</a> is computed as: 3851 3852<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3853 |A B C| |x| Ax+By+C Dx+Ey+F 3854Matrix * pt = |D E F| |y| = |Ax+By+C Dx+Ey+F Gx+Hy+I| = ------- , ------- 3855 |G H I| |1| Gx+Hy+I Gx+Hy+I</pre> 3856 3857### Parameters 3858 3859<table> <tr> <td><a name="SkMatrix_mapRectToQuad_dst"> <code><strong>dst </strong></code> </a></td> <td> 3860storage for mapped corner <a href="SkPoint_Reference#Point">Points</a></td> 3861 </tr> <tr> <td><a name="SkMatrix_mapRectToQuad_rect"> <code><strong>rect </strong></code> </a></td> <td> 3862<a href="SkRect_Reference#Rect">Rect</a> to map</td> 3863 </tr> 3864</table> 3865 3866### Example 3867 3868<div><fiddle-embed name="c69cd2a590b5733c3cbc92cb9ceed3f5"></fiddle-embed></div> 3869 3870### See Also 3871 3872<a href="#SkMatrix_mapRect">mapRect</a><sup><a href="#SkMatrix_mapRect_2">[2]</a></sup> <a href="#SkMatrix_mapRectScaleTranslate">mapRectScaleTranslate</a> 3873 3874--- 3875 3876<a name="SkMatrix_mapRectScaleTranslate"></a> 3877## mapRectScaleTranslate 3878 3879<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3880void mapRectScaleTranslate(SkRect* dst, const SkRect& src) const 3881</pre> 3882 3883Sets <a href="#SkMatrix_mapRectScaleTranslate_dst">dst</a> to bounds of <a href="#SkMatrix_mapRectScaleTranslate_src">src</a> corners mapped by <a href="#Matrix">Matrix</a>. If matrix contains 3884elements other than scale or translate: asserts if SK_DEBUG is defined; 3885otherwise, results are undefined. 3886 3887### Parameters 3888 3889<table> <tr> <td><a name="SkMatrix_mapRectScaleTranslate_dst"> <code><strong>dst </strong></code> </a></td> <td> 3890storage for bounds of mapped <a href="SkPoint_Reference#Point">Points</a></td> 3891 </tr> <tr> <td><a name="SkMatrix_mapRectScaleTranslate_src"> <code><strong>src </strong></code> </a></td> <td> 3892<a href="SkRect_Reference#Rect">Rect</a> to map</td> 3893 </tr> 3894</table> 3895 3896### Example 3897 3898<div><fiddle-embed name="62bc26989c2b4c2a54d516596a71dd97"></fiddle-embed></div> 3899 3900### See Also 3901 3902<a href="#SkMatrix_mapRect">mapRect</a><sup><a href="#SkMatrix_mapRect_2">[2]</a></sup> <a href="#SkMatrix_mapRectToQuad">mapRectToQuad</a> <a href="#SkMatrix_isScaleTranslate">isScaleTranslate</a> <a href="#SkMatrix_rectStaysRect">rectStaysRect</a> 3903 3904--- 3905 3906<a name="SkMatrix_mapRadius"></a> 3907## mapRadius 3908 3909<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3910SkScalar mapRadius(SkScalar radius) const 3911</pre> 3912 3913Returns geometric mean <a href="#SkMatrix_mapRadius_radius">radius</a> of ellipse formed by constructing <a href="undocumented#Circle">Circle</a> of 3914size <a href="#SkMatrix_mapRadius_radius">radius</a>, and mapping constructed <a href="undocumented#Circle">Circle</a> with <a href="#Matrix">Matrix</a>. The result squared is 3915equal to the major axis length times the minor axis length. 3916Result is not meaningful if <a href="#Matrix">Matrix</a> contains perspective elements. 3917 3918### Parameters 3919 3920<table> <tr> <td><a name="SkMatrix_mapRadius_radius"> <code><strong>radius </strong></code> </a></td> <td> 3921<a href="undocumented#Circle">Circle</a> size to map</td> 3922 </tr> 3923</table> 3924 3925### Return Value 3926 3927average mapped <a href="#SkMatrix_mapRadius_radius">radius</a> 3928 3929### Example 3930 3931<div><fiddle-embed name="6d6f2082fcf59d9f02bfb1758b87db69"><div>The area enclosed by a square with sides equal to mappedRadius is the same as 3932the area enclosed by the ellipse major and minor axes.</div></fiddle-embed></div> 3933 3934### See Also 3935 3936<a href="#SkMatrix_mapVector">mapVector</a><sup><a href="#SkMatrix_mapVector_2">[2]</a></sup> 3937 3938--- 3939 3940<a name="SkMatrix_isFixedStepInX"></a> 3941## isFixedStepInX 3942 3943<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3944bool isFixedStepInX() const 3945</pre> 3946 3947Returns true if a unit step in x at some y mapped through <a href="#Matrix">Matrix</a> can be 3948represented by a constant <a href="SkPoint_Reference#Vector">Vector</a>. Returns true if <a href="#SkMatrix_getType">getType</a> returns <a href="#SkMatrix_kIdentity_Mask">kIdentity Mask</a>, 3949or combinations of: <a href="#SkMatrix_kTranslate_Mask">kTranslate Mask</a>, <a href="#SkMatrix_kScale_Mask">kScale Mask</a>, and <a href="#SkMatrix_kAffine_Mask">kAffine Mask</a>. 3950 3951May return true if <a href="#SkMatrix_getType">getType</a> returns <a href="#SkMatrix_kPerspective_Mask">kPerspective Mask</a>, but only when <a href="#Matrix">Matrix</a> 3952does not include rotation or skewing along the y-axis. 3953 3954### Return Value 3955 3956true if <a href="#Matrix">Matrix</a> does not have complex perspective 3957 3958### Example 3959 3960<div><fiddle-embed name="ab57b232acef69f26de9cb23d23c8a1a"> 3961 3962#### Example Output 3963 3964~~~~ 3965[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 3966isFixedStepInX: true 3967[ 1.0000 0.0000 0.0000][ 0.0000 2.0000 0.0000][ 0.0000 0.0000 1.0000] 3968isFixedStepInX: true 3969[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.0000 0.1000 1.0000] 3970isFixedStepInX: true 3971[ 1.0000 0.0000 0.0000][ 0.0000 2.0000 0.0000][ 0.0000 0.1000 1.0000] 3972isFixedStepInX: true 3973[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.1000 0.0000 1.0000] 3974isFixedStepInX: false 3975[ 1.0000 0.0000 0.0000][ 0.0000 2.0000 0.0000][ 0.1000 0.0000 1.0000] 3976isFixedStepInX: false 3977[ 1.0000 0.0000 0.0000][ 0.0000 1.0000 0.0000][ 0.1000 0.1000 1.0000] 3978isFixedStepInX: false 3979[ 1.0000 0.0000 0.0000][ 0.0000 2.0000 0.0000][ 0.1000 0.1000 1.0000] 3980isFixedStepInX: false 3981~~~~ 3982 3983</fiddle-embed></div> 3984 3985### See Also 3986 3987<a href="#SkMatrix_fixedStepInX">fixedStepInX</a> <a href="#SkMatrix_getType">getType</a> 3988 3989--- 3990 3991<a name="SkMatrix_fixedStepInX"></a> 3992## fixedStepInX 3993 3994<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 3995SkVector fixedStepInX(SkScalar y) const 3996</pre> 3997 3998Returns <a href="SkPoint_Reference#Vector">Vector</a> representing a unit step in x at <a href="#SkMatrix_fixedStepInX_y">y</a> mapped through <a href="#Matrix">Matrix</a>. 3999If <a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> is false, returned value is undefined. 4000 4001### Parameters 4002 4003<table> <tr> <td><a name="SkMatrix_fixedStepInX_y"> <code><strong>y </strong></code> </a></td> <td> 4004position of line parallel to x-axis</td> 4005 </tr> 4006</table> 4007 4008### Return Value 4009 4010<a href="SkPoint_Reference#Vector">Vector</a> advance of mapped unit step in x 4011 4012### Example 4013 4014<div><fiddle-embed name="fad6b92b21b1e1deeae61978cec2d232"></fiddle-embed></div> 4015 4016### See Also 4017 4018<a href="#SkMatrix_isFixedStepInX">isFixedStepInX</a> <a href="#SkMatrix_getType">getType</a> 4019 4020--- 4021 4022<a name="SkMatrix_cheapEqualTo"></a> 4023## cheapEqualTo 4024 4025<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4026bool cheapEqualTo(const SkMatrix& m) const 4027</pre> 4028 4029Returns true if <a href="#Matrix">Matrix</a> equals <a href="#SkMatrix_cheapEqualTo_m">m</a>, using an efficient comparison. 4030 4031Returns false when the sign of zero values is the different; when one 4032matrix has positive zero value and the other has negative zero value. 4033 4034Returns true even when both <a href="#Matrix">Matrices</a> contain NaN. 4035 4036NaN never equals any value, including itself. To improve performance, NaN values 4037are treated as bit patterns that are equal if their bit patterns are equal. 4038 4039### Parameters 4040 4041<table> <tr> <td><a name="SkMatrix_cheapEqualTo_m"> <code><strong>m </strong></code> </a></td> <td> 4042<a href="#Matrix">Matrix</a> to compare</td> 4043 </tr> 4044</table> 4045 4046### Return Value 4047 4048true if <a href="#SkMatrix_cheapEqualTo_m">m</a> and <a href="#Matrix">Matrix</a> are represented by identical bit patterns 4049 4050### Example 4051 4052<div><fiddle-embed name="39016b3cfc6bbabb09348a53822ce508"> 4053 4054#### Example Output 4055 4056~~~~ 4057identity: a == b a.cheapEqualTo(b): true 4058neg zero: a == b a.cheapEqualTo(b): false 4059one NaN: a != b a.cheapEqualTo(b): false 4060both NaN: a != b a.cheapEqualTo(b): true 4061~~~~ 4062 4063</fiddle-embed></div> 4064 4065### See Also 4066 4067<a href="#SkMatrix_equal_operator">operator==(const SkMatrix& a, const SkMatrix& b)</a> 4068 4069--- 4070 4071<a name="SkMatrix_equal_operator"></a> 4072## operator== 4073 4074<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4075bool operator==(const SkMatrix& a, const SkMatrix& b) 4076</pre> 4077 4078Compares <a href="#SkMatrix_equal_operator_a">a</a> and <a href="#SkMatrix_equal_operator_b">b</a>; returns true if <a href="#SkMatrix_equal_operator_a">a</a> and <a href="#SkMatrix_equal_operator_b">b</a> are numerically equal. Returns true 4079even if sign of zero values are different. Returns false if either <a href="#Matrix">Matrix</a> 4080contains NaN, even if the other <a href="#Matrix">Matrix</a> also contains NaN. 4081 4082### Parameters 4083 4084<table> <tr> <td><a name="SkMatrix_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 4085<a href="#Matrix">Matrix</a> to compare</td> 4086 </tr> <tr> <td><a name="SkMatrix_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 4087<a href="#Matrix">Matrix</a> to compare</td> 4088 </tr> 4089</table> 4090 4091### Return Value 4092 4093true if <a href="#Matrix">Matrix</a> <a href="#SkMatrix_equal_operator_a">a</a> and <a href="#Matrix">Matrix</a> <a href="#SkMatrix_equal_operator_b">b</a> are numerically equal 4094 4095### Example 4096 4097<div><fiddle-embed name="3902859150b0f0c4aeb1f25d00434baa"> 4098 4099#### Example Output 4100 4101~~~~ 4102identity: a == b a.cheapEqualTo(b): true 4103~~~~ 4104 4105</fiddle-embed></div> 4106 4107### See Also 4108 4109<a href="#SkMatrix_cheapEqualTo">cheapEqualTo</a> <a href="#SkMatrix_notequal_operator">operator!=(const SkMatrix& a, const SkMatrix& b)</a> 4110 4111--- 4112 4113<a name="SkMatrix_notequal_operator"></a> 4114## operator!= 4115 4116<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4117bool operator!=(const SkMatrix& a, const SkMatrix& b) 4118</pre> 4119 4120Compares <a href="#SkMatrix_notequal_operator_a">a</a> and <a href="#SkMatrix_notequal_operator_b">b</a>; returns true if <a href="#SkMatrix_notequal_operator_a">a</a> and <a href="#SkMatrix_notequal_operator_b">b</a> are not numerically equal. Returns false 4121even if sign of zero values are different. Returns true if either <a href="#Matrix">Matrix</a> 4122contains NaN, even if the other <a href="#Matrix">Matrix</a> also contains NaN. 4123 4124### Parameters 4125 4126<table> <tr> <td><a name="SkMatrix_notequal_operator_a"> <code><strong>a </strong></code> </a></td> <td> 4127<a href="#Matrix">Matrix</a> to compare</td> 4128 </tr> <tr> <td><a name="SkMatrix_notequal_operator_b"> <code><strong>b </strong></code> </a></td> <td> 4129<a href="#Matrix">Matrix</a> to compare</td> 4130 </tr> 4131</table> 4132 4133### Return Value 4134 4135true if <a href="#Matrix">Matrix</a> <a href="#SkMatrix_notequal_operator_a">a</a> and <a href="#Matrix">Matrix</a> <a href="#SkMatrix_notequal_operator_b">b</a> are numerically not equal 4136 4137### Example 4138 4139<div><fiddle-embed name="8a8fadf5fd294daa4ee152833cc0dc0e"></fiddle-embed></div> 4140 4141### See Also 4142 4143<a href="#SkMatrix_cheapEqualTo">cheapEqualTo</a> <a href="#SkMatrix_equal_operator">operator==(const SkMatrix& a, const SkMatrix& b)</a> 4144 4145--- 4146 4147## <a name="Utility"></a> Utility 4148 4149| name | description | 4150| --- | --- | 4151| <a href="#SkMatrix_dirtyMatrixTypeCache">dirtyMatrixTypeCache</a> | sets internal cache to unknown state | 4152| <a href="#SkMatrix_dump">dump</a> | sends text representation using floats to standard output | 4153| <a href="#SkMatrix_toString">toString</a> | converts <a href="#Matrix">Matrix</a> to machine readable form | 4154 4155<a name="SkMatrix_dump"></a> 4156## dump 4157 4158<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4159void dump() const 4160</pre> 4161 4162Writes text representation of <a href="#Matrix">Matrix</a> to standard output. Floating point values 4163are written with limited precision; it may not be possible to reconstruct 4164original <a href="#Matrix">Matrix</a> from output. 4165 4166### Example 4167 4168<div><fiddle-embed name="8d72a4818e5a9188348f6c08ab5d8a40"> 4169 4170#### Example Output 4171 4172~~~~ 4173[ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] 4174[ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] 4175matrix != nearlyEqual 4176~~~~ 4177 4178</fiddle-embed></div> 4179 4180### See Also 4181 4182<a href="#SkMatrix_toString">toString</a> 4183 4184--- 4185 4186<a name="SkMatrix_toString"></a> 4187## toString 4188 4189<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4190void toString(SkString* str) const 4191</pre> 4192 4193Creates string representation of <a href="#Matrix">Matrix</a>. Floating point values 4194are written with limited precision; it may not be possible to reconstruct 4195original <a href="#Matrix">Matrix</a> from output. 4196 4197### Parameters 4198 4199<table> <tr> <td><a name="SkMatrix_toString_str"> <code><strong>str </strong></code> </a></td> <td> 4200storage for string representation of <a href="#Matrix">Matrix</a></td> 4201 </tr> 4202</table> 4203 4204### Example 4205 4206<div><fiddle-embed name="1d86e43958e42b8eaaa9b16df1baa4c8"> 4207 4208#### Example Output 4209 4210~~~~ 4211mStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] 4212neStr [ 0.7071 -0.7071 0.0000][ 0.7071 0.7071 0.0000][ 0.0000 0.0000 1.0000] 4213matrix != nearlyEqual 4214~~~~ 4215 4216</fiddle-embed></div> 4217 4218### See Also 4219 4220<a href="#SkMatrix_dump">dump</a> 4221 4222--- 4223 4224<a name="SkMatrix_getMinScale"></a> 4225## getMinScale 4226 4227<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4228SkScalar getMinScale() const 4229</pre> 4230 4231Returns the minimum scaling factor of <a href="#Matrix">Matrix</a> by decomposing the scaling and 4232skewing elements. 4233Returns -1 if scale factor overflows or <a href="#Matrix">Matrix</a> contains perspective. 4234 4235### Return Value 4236 4237minimum scale factor 4238 4239### Example 4240 4241<div><fiddle-embed name="1d6f67904c88a806c3731879e9af4ae5"> 4242 4243#### Example Output 4244 4245~~~~ 4246matrix.getMinScale() 24 4247~~~~ 4248 4249</fiddle-embed></div> 4250 4251### See Also 4252 4253<a href="#SkMatrix_getMaxScale">getMaxScale</a> <a href="#SkMatrix_getMinMaxScales">getMinMaxScales</a> 4254 4255--- 4256 4257<a name="SkMatrix_getMaxScale"></a> 4258## getMaxScale 4259 4260<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4261SkScalar getMaxScale() const 4262</pre> 4263 4264Returns the maximum scaling factor of <a href="#Matrix">Matrix</a> by decomposing the scaling and 4265skewing elements. 4266Returns -1 if scale factor overflows or <a href="#Matrix">Matrix</a> contains perspective. 4267 4268### Return Value 4269 4270maximum scale factor 4271 4272### Example 4273 4274<div><fiddle-embed name="3fee4364929899649cf9efc37897e964"> 4275 4276#### Example Output 4277 4278~~~~ 4279matrix.getMaxScale() 42 4280~~~~ 4281 4282</fiddle-embed></div> 4283 4284### See Also 4285 4286<a href="#SkMatrix_getMinScale">getMinScale</a> <a href="#SkMatrix_getMinMaxScales">getMinMaxScales</a> 4287 4288--- 4289 4290<a name="SkMatrix_getMinMaxScales"></a> 4291## getMinMaxScales 4292 4293<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4294bool SK_WARN_UNUSED_RESULT getMinMaxScales(SkScalar scaleFactors[2]) const 4295</pre> 4296 4297Sets <a href="#SkMatrix_getMinMaxScales_scaleFactors">scaleFactors</a>[0] to the minimum scaling factor, and <a href="#SkMatrix_getMinMaxScales_scaleFactors">scaleFactors</a>[1] to the 4298maximum scaling factor. Scaling factors are computed by decomposing 4299the <a href="#Matrix">Matrix</a> scaling and skewing elements. 4300 4301Returns true if <a href="#SkMatrix_getMinMaxScales_scaleFactors">scaleFactors</a> are found; otherwise, returns false and sets 4302<a href="#SkMatrix_getMinMaxScales_scaleFactors">scaleFactors</a> to undefined values. 4303 4304### Parameters 4305 4306<table> <tr> <td><a name="SkMatrix_getMinMaxScales_scaleFactors"> <code><strong>scaleFactors </strong></code> </a></td> <td> 4307storage for minimum and maximum scale factors</td> 4308 </tr> 4309</table> 4310 4311### Return Value 4312 4313true if scale factors were computed correctly 4314 4315### Example 4316 4317<div><fiddle-embed name="cd4dc63d3e04226f0b5861ba8925e223"> 4318 4319#### Example Output 4320 4321~~~~ 4322matrix.getMinMaxScales() false 2 2 4323~~~~ 4324 4325</fiddle-embed></div> 4326 4327### See Also 4328 4329<a href="#SkMatrix_getMinScale">getMinScale</a> <a href="#SkMatrix_getMaxScale">getMaxScale</a> 4330 4331--- 4332 4333<a name="SkMatrix_decomposeScale"></a> 4334## decomposeScale 4335 4336<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4337bool decomposeScale(SkSize* scale, SkMatrix* remaining = nullptr) const 4338</pre> 4339 4340Decomposes <a href="#Matrix">Matrix</a> into <a href="#SkMatrix_decomposeScale_scale">scale</a> components and whatever remains. Returns false if 4341<a href="#Matrix">Matrix</a> could not be decomposed. 4342 4343Sets <a href="#SkMatrix_decomposeScale_scale">scale</a> to portion of <a href="#Matrix">Matrix</a> that scales in x and y. Sets <a href="#SkMatrix_decomposeScale_remaining">remaining</a> to <a href="#Matrix">Matrix</a> 4344with x and y scaling factored out. <a href="#SkMatrix_decomposeScale_remaining">remaining</a> may be passed as nullptr 4345to determine if <a href="#Matrix">Matrix</a> can be decomposed without computing remainder. 4346 4347Returns true if <a href="#SkMatrix_decomposeScale_scale">scale</a> components are found. <a href="#SkMatrix_decomposeScale_scale">scale</a> and <a href="#SkMatrix_decomposeScale_remaining">remaining</a> are 4348unchanged if <a href="#Matrix">Matrix</a> contains perspective; <a href="#SkMatrix_decomposeScale_scale">scale</a> factors are not finite, or 4349are nearly zero. 4350 4351On success<a href="#Matrix">Matrix</a> = <a href="#SkMatrix_decomposeScale_scale">scale</a> * Remaining 4352 4353### Parameters 4354 4355<table> <tr> <td><a name="SkMatrix_decomposeScale_scale"> <code><strong>scale </strong></code> </a></td> <td> 4356x and y scaling factors; may be nullptr</td> 4357 </tr> <tr> <td><a name="SkMatrix_decomposeScale_remaining"> <code><strong>remaining </strong></code> </a></td> <td> 4358<a href="#Matrix">Matrix</a> without scaling; may be nullptr</td> 4359 </tr> 4360</table> 4361 4362### Return Value 4363 4364true if <a href="#SkMatrix_decomposeScale_scale">scale</a> can be computed 4365 4366### Example 4367 4368<div><fiddle-embed name="139b874da0a3ede1f3df88119085c0aa"> 4369 4370#### Example Output 4371 4372~~~~ 4373[ 0.0000 -0.2500 0.0000][ 0.5000 0.0000 0.0000][ 0.0000 0.0000 1.0000] 4374success: true scale: 0.5, 0.25 4375[ 0.0000 -0.5000 0.0000][ 2.0000 0.0000 0.0000][ 0.0000 0.0000 1.0000] 4376[ 0.0000 -0.2500 0.0000][ 0.5000 0.0000 0.0000][ 0.0000 0.0000 1.0000] 4377~~~~ 4378 4379</fiddle-embed></div> 4380 4381### See Also 4382 4383<a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_MakeScale">MakeScale</a><sup><a href="#SkMatrix_MakeScale_2">[2]</a></sup> 4384 4385--- 4386 4387<a name="SkMatrix_I"></a> 4388## I 4389 4390<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4391static const SkMatrix& I() 4392</pre> 4393 4394Returns reference to const identity <a href="#Matrix">Matrix</a>. Returned <a href="#Matrix">Matrix</a> is set to: 4395 4396<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4397| 1 0 0 | 4398| 0 1 0 | 4399| 0 0 1 |</pre> 4400 4401### Return Value 4402 4403const identity <a href="#Matrix">Matrix</a> 4404 4405### Example 4406 4407<div><fiddle-embed name="d961d91020f19037204a8c3fd8cb1060"> 4408 4409#### Example Output 4410 4411~~~~ 4412m1 == m2 4413m2 == m3 4414~~~~ 4415 4416</fiddle-embed></div> 4417 4418### See Also 4419 4420<a href="#SkMatrix_reset">reset</a> <a href="#SkMatrix_setIdentity">setIdentity</a> 4421 4422--- 4423 4424<a name="SkMatrix_InvalidMatrix"></a> 4425## InvalidMatrix 4426 4427<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4428static const SkMatrix& InvalidMatrix() 4429</pre> 4430 4431Returns reference to a const <a href="#Matrix">Matrix</a> with invalid values. Returned <a href="#Matrix">Matrix</a> is set 4432to: 4433 4434<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4435| SK_ScalarMax SK_ScalarMax SK_ScalarMax | 4436| SK_ScalarMax SK_ScalarMax SK_ScalarMax | 4437| SK_ScalarMax SK_ScalarMax SK_ScalarMax |</pre> 4438 4439### Return Value 4440 4441const invalid <a href="#Matrix">Matrix</a> 4442 4443### Example 4444 4445<div><fiddle-embed name="af0b72360c1c7a25b4754bfa47011dd5"> 4446 4447#### Example Output 4448 4449~~~~ 4450scaleX 3.40282e+38 4451~~~~ 4452 4453</fiddle-embed></div> 4454 4455### See Also 4456 4457SeeAlso <a href="#SkMatrix_getType">getType</a> 4458 4459--- 4460 4461<a name="SkMatrix_Concat"></a> 4462## Concat 4463 4464<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4465static SkMatrix Concat(const SkMatrix& a, const SkMatrix& b) 4466</pre> 4467 4468Returns <a href="#Matrix">Matrix</a> <a href="#SkMatrix_Concat_a">a</a> multiplied by <a href="#Matrix">Matrix</a> <a href="#SkMatrix_Concat_b">b</a>. 4469 4470Given: 4471 4472<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4473 | A B C | | J K L | 4474a = | D E F |, b = | M N O | 4475 | G H I | | P Q R |</pre> 4476 4477sets <a href="#Matrix">Matrix</a> to: 4478 4479<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4480 | A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR | 4481a * b = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR | 4482 | G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |</pre> 4483 4484### Parameters 4485 4486<table> <tr> <td><a name="SkMatrix_Concat_a"> <code><strong>a </strong></code> </a></td> <td> 4487<a href="#Matrix">Matrix</a> on left side of multiply expression</td> 4488 </tr> <tr> <td><a name="SkMatrix_Concat_b"> <code><strong>b </strong></code> </a></td> <td> 4489<a href="#Matrix">Matrix</a> on right side of multiply expression</td> 4490 </tr> 4491</table> 4492 4493### Return Value 4494 4495<a href="#Matrix">Matrix</a> computed from <a href="#SkMatrix_Concat_a">a</a> times <a href="#SkMatrix_Concat_b">b</a> 4496 4497### Example 4498 4499<div><fiddle-embed name="6b4562c7052da94f3d5b2412dca41946"><div><a href="#SkMatrix_setPolyToPoly">setPolyToPoly</a> creates perspective matrices, one the inverse of the other. 4500Multiplying the matrix by its inverse turns into an identity matrix.</div></fiddle-embed></div> 4501 4502### See Also 4503 4504<a href="#SkMatrix_preConcat">preConcat</a> <a href="#SkMatrix_postConcat">postConcat</a> 4505 4506--- 4507 4508<a name="SkMatrix_dirtyMatrixTypeCache"></a> 4509## dirtyMatrixTypeCache 4510 4511<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4512void dirtyMatrixTypeCache() 4513</pre> 4514 4515Sets internal cache to unknown state. Use to force update after repeated 4516modifications to <a href="#Matrix">Matrix</a> element reference returned by <a href="#SkMatrix_array1_operator">operator[](int index)</a>. 4517 4518### Example 4519 4520<div><fiddle-embed name="f4365ef332f51f7fd25040e0771ba9a2"> 4521 4522#### Example Output 4523 4524~~~~ 4525with identity matrix: x = 24 4526after skew x mod: x = 24 4527after 2nd skew x mod: x = 24 4528after dirty cache: x = 66 4529~~~~ 4530 4531</fiddle-embed></div> 4532 4533### See Also 4534 4535<a href="#SkMatrix_array1_operator">operator[](int index)</a> <a href="#SkMatrix_getType">getType</a> 4536 4537--- 4538 4539<a name="SkMatrix_setScaleTranslate"></a> 4540## setScaleTranslate 4541 4542<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4543void setScaleTranslate(SkScalar sx, SkScalar sy, SkScalar tx, SkScalar ty) 4544</pre> 4545 4546Initializes <a href="#Matrix">Matrix</a> with scale and translate elements. 4547 4548<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4549| sx 0 tx | 4550| 0 sy ty | 4551| 0 0 1 |</pre> 4552 4553### Parameters 4554 4555<table> <tr> <td><a name="SkMatrix_setScaleTranslate_sx"> <code><strong>sx </strong></code> </a></td> <td> 4556horizontal scale factor to store</td> 4557 </tr> <tr> <td><a name="SkMatrix_setScaleTranslate_sy"> <code><strong>sy </strong></code> </a></td> <td> 4558vertical scale factor to store</td> 4559 </tr> <tr> <td><a name="SkMatrix_setScaleTranslate_tx"> <code><strong>tx </strong></code> </a></td> <td> 4560horizontal translation to store</td> 4561 </tr> <tr> <td><a name="SkMatrix_setScaleTranslate_ty"> <code><strong>ty </strong></code> </a></td> <td> 4562vertical translation to store</td> 4563 </tr> 4564</table> 4565 4566### Example 4567 4568<div><fiddle-embed name="fed43797f13796529cb6731385d6f8f3"> 4569 4570#### Example Output 4571 4572~~~~ 4573[ 1.0000 0.0000 3.0000][ 0.0000 2.0000 4.0000][ 0.0000 0.0000 1.0000] 4574~~~~ 4575 4576</fiddle-embed></div> 4577 4578### See Also 4579 4580<a href="#SkMatrix_setScale">setScale</a><sup><a href="#SkMatrix_setScale_2">[2]</a></sup> <a href="#SkMatrix_preTranslate">preTranslate</a> <a href="#SkMatrix_postTranslate">postTranslate</a> 4581 4582--- 4583 4584<a name="SkMatrix_isFinite"></a> 4585## isFinite 4586 4587<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0"> 4588bool isFinite() const 4589</pre> 4590 4591Returns true if all elements of the matrix are finite. Returns false if any 4592element is infinity, or NaN. 4593 4594### Return Value 4595 4596true if matrix has only finite elements 4597 4598### Example 4599 4600<div><fiddle-embed name="bc6c6f6a5df770287120d87f81b922eb"> 4601 4602#### Example Output 4603 4604~~~~ 4605[ 1.0000 0.0000 nan][ 0.0000 1.0000 0.0000][ 0.0000 0.0000 1.0000] 4606matrix is finite: false 4607matrix != matrix 4608~~~~ 4609 4610</fiddle-embed></div> 4611 4612### See Also 4613 4614operator== 4615 4616--- 4617 4618