Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1 | #Topic Rect |
| 2 | #Alias Rects |
| 3 | #Alias Rect_Reference |
| 4 | |
| 5 | #Struct SkRect |
| 6 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 7 | SkRect holds four SkScalar coordinates describing the upper and |
| 8 | lower bounds of a rectangle. SkRect may be created from outer bounds or |
| 9 | from position, width, and height. SkRect describes an area; if its right |
| 10 | is less than or equal to its left, or if its bottom is less than or equal to |
| 11 | its top, it is considered empty. |
| 12 | |
| 13 | # move to topic about MakeIWH and friends |
| 14 | SkRect can be constructed from int values to avoid compiler warnings that |
| 15 | integer input cannot convert to SkScalar without loss of precision. |
| 16 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 17 | #Topic Overview |
| 18 | |
| 19 | #Subtopic Subtopics |
| 20 | #ToDo manually add subtopics ## |
| 21 | #Table |
| 22 | #Legend |
| 23 | # topics # description ## |
| 24 | #Legend ## |
| 25 | #Table ## |
| 26 | ## |
| 27 | |
| 28 | #Subtopic Operators |
| 29 | #Table |
| 30 | #Legend |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 31 | # description # function ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 32 | #Legend ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 33 | # bool operator!=(const SkRect& a, const SkRect& b) # Returns true if members are unequal. ## |
| 34 | # bool operator==(const SkRect& a, const SkRect& b) # Returns true if members are equal. ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 35 | #Table ## |
| 36 | #Subtopic ## |
| 37 | |
| 38 | #Subtopic Member_Functions |
| 39 | #Table |
| 40 | #Legend |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 41 | # description # function ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 42 | #Legend ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 43 | # Intersects # Returns true if areas overlap. ## |
| 44 | # Make # Constructs from ISize returning (0, 0, width, height). ## |
| 45 | # MakeEmpty # Constructs from bounds of (0, 0, 0, 0). ## |
| 46 | # MakeFromIRect # Deprecated. ## |
| 47 | # MakeIWH # Constructs from int input returning (0, 0, width, height). ## |
| 48 | # MakeLTRB # Constructs from SkScalar left, top, right, bottom. ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 49 | # MakeSize # Constructs from Size returning (0, 0, width, height). ## |
| 50 | # MakeWH # Constructs from SkScalar input returning (0, 0, width, height). ## |
| 51 | # MakeXYWH # Constructs from SkScalar input returning (x, y, width, height). ## |
| 52 | # asScalars # Returns pointer to members as array. ## |
| 53 | # bottom() # Returns larger bounds in y, if sorted. ## |
| 54 | # centerX # Returns midpoint in x. ## |
| 55 | # centerY # Returns midpoint in y. ## |
| 56 | # contains() # Returns true if points are equal or inside. ## |
| 57 | # dump() # Sends text representation using floats to standard output. ## |
| 58 | # dumpHex # Sends text representation using hexadecimal to standard output. ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 59 | # height # Returns span in y. ## |
| 60 | # inset() # Moves the sides symmetrically about the center. ## |
| 61 | # intersect() # Sets to shared area; returns true if not empty. ## |
| 62 | # intersects() # Returns true if areas overlap. ## |
| 63 | # isEmpty # Returns true if width or height are zero or negative. ## |
| 64 | # isFinite # Returns true if no member is infinite or NaN. ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 65 | # isSorted # Returns true if width or height are zero or positive. ## |
| 66 | # iset() # Sets to int input (left, top, right, bottom). ## |
| 67 | # isetWH # Sets to int input (0, 0, width, height). ## |
| 68 | # join() # Sets to union of bounds. ## |
| 69 | # joinNonEmptyArg # Sets to union of bounds, asserting that argument is not empty. ## |
| 70 | # joinPossiblyEmptyRect # Sets to union of bounds. Skips empty check for both. ## |
| 71 | # left() # Returns smaller bounds in x, if sorted. ## |
| 72 | # makeInset # Constructs from sides moved symmetrically about the center. ## |
| 73 | # makeOffset # Constructs from translated sides. ## |
| 74 | # makeOutset # Constructs from sides moved symmetrically about the center. ## |
| 75 | # makeSorted # Constructs, ordering sides from smaller to larger. ## |
| 76 | # offset() # Translates sides without changing width and height. ## |
| 77 | # offsetTo # Translates to (x, y) without changing width and height. ## |
| 78 | # outset() # Moves the sides symmetrically about the center. ## |
| 79 | # right() # Returns larger bounds in x, if sorted. ## |
| 80 | # round() # Sets members to nearest integer value. ## |
| 81 | # roundIn # Sets members to nearest integer value towards opposite. ## |
| 82 | # roundOut # Sets members to nearest integer value away from opposite. ## |
| 83 | # set() # Sets to SkScalar input (left, top, right, bottom) and others. ## |
| 84 | # setBounds # Sets to upper and lower limits of Point array. ## |
| 85 | # setBoundsCheck # Sets to upper and lower limits of Point array. ## |
| 86 | # setEmpty # Sets to (0, 0, 0, 0). ## |
| 87 | # setLTRB # Sets to SkScalar input (left, top, right, bottom). ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 88 | # setWH # Sets to SkScalar input (0, 0, width, height). ## |
| 89 | # setXYWH # Sets to SkScalar input (x, y, width, height). ## |
| 90 | # sort() # Orders sides from smaller to larger. ## |
| 91 | # toQuad # Returns four corners as Point. ## |
| 92 | # top() # Returns smaller bounds in y, if sorted. ## |
| 93 | # width() # Returns span in x. ## |
| 94 | # x() # Returns bounds left. ## |
| 95 | # y() # Returns bounds top. ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 96 | #Table ## |
| 97 | #Subtopic ## |
| 98 | |
| 99 | #Topic ## |
| 100 | |
| 101 | #Member SkScalar fLeft |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 102 | May contain any value, including infinities and NaN. The smaller of the |
| 103 | horizontal values when sorted. When equal to or greater than fRight, Rect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 104 | ## |
| 105 | |
| 106 | #Member SkScalar fTop |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 107 | May contain any value, including infinities and NaN. The smaller of the |
| 108 | vertical values when sorted. When equal to or greater than fBottom, Rect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 109 | ## |
| 110 | |
| 111 | #Member SkScalar fRight |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 112 | May contain any value, including infinities and NaN. The larger of the |
| 113 | horizontal values when sorted. When equal to or less than fLeft, Rect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 114 | ## |
| 115 | |
| 116 | #Member SkScalar fBottom |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 117 | May contain any value, including infinities and NaN. The larger of the |
| 118 | vertical values when sorted. When equal to or less than fTop, Rect is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 119 | ## |
| 120 | |
| 121 | # ------------------------------------------------------------------------------ |
| 122 | |
| 123 | #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeEmpty() |
| 124 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 125 | Returns constructed Rect set to (0, 0, 0, 0). |
| 126 | Many other rectangles are empty; if left is equal to or greater than right, |
| 127 | or if top is equal to or greater than bottom. Setting all members to zero |
| 128 | is a convenience, but does not designate a special empty rectangle. |
| 129 | |
| 130 | #Return bounds (0, 0, 0, 0) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 131 | |
| 132 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 133 | SkRect rect = SkRect::MakeEmpty(); |
| 134 | SkDebugf("MakeEmpty isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 135 | rect.offset(10, 10); |
| 136 | SkDebugf("offset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 137 | rect.inset(10, 10); |
| 138 | SkDebugf("inset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 139 | rect.outset(20, 20); |
| 140 | SkDebugf("outset rect isEmpty: %s\n", rect.isEmpty() ? "true" : "false"); |
| 141 | #StdOut |
| 142 | MakeEmpty isEmpty: true |
| 143 | offset rect isEmpty: true |
| 144 | inset rect isEmpty: true |
| 145 | outset rect isEmpty: false |
| 146 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 147 | ## |
| 148 | |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 149 | #SeeAlso isEmpty setEmpty SkIRect::MakeEmpty |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 150 | |
| 151 | ## |
| 152 | |
| 153 | # ------------------------------------------------------------------------------ |
| 154 | |
| 155 | #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeWH(SkScalar w, SkScalar h) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 156 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 157 | Returns constructed Rect set to SkScalar values (0, 0, w, h). Does not |
| 158 | validate input; w or h may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 159 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 160 | Passing integer values may generate a compiler warning since Rect cannot |
| 161 | represent 32-bit integers exactly. Use SkIRect for an exact integer rectangle. |
| 162 | |
| 163 | #Param w SkScalar width of constructed Rect ## |
| 164 | #Param h SkScalar height of constructed Rect ## |
| 165 | |
| 166 | #Return bounds (0, 0, w, h) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 167 | |
| 168 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 169 | SkRect rect1 = SkRect::MakeWH(25, 35); |
| 170 | SkRect rect2 = SkRect::MakeIWH(25, 35); |
| 171 | SkRect rect3 = SkRect::MakeXYWH(0, 0, 25, 35); |
| 172 | SkRect rect4 = SkRect::MakeLTRB(0, 0, 25, 35); |
| 173 | SkDebugf("all %s" "equal\n", rect1 == rect2 && rect2 == rect3 && rect3 == rect4 ? |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 174 | "" : "not "); |
| 175 | #StdOut |
| 176 | all equal |
| 177 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 178 | ## |
| 179 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 180 | #SeeAlso MakeSize MakeXYWH MakeIWH setWH SkIRect::MakeWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 181 | |
| 182 | ## |
| 183 | |
| 184 | # ------------------------------------------------------------------------------ |
| 185 | |
| 186 | #Method static SkRect SK_WARN_UNUSED_RESULT MakeIWH(int w, int h) |
| 187 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 188 | Returns constructed Rect set to integer values (0, 0, w, h). Does not validate |
| 189 | input; w or h may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 190 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 191 | Use to avoid a compiler warning that input may lose precision when stored. |
| 192 | Use SkIRect for an exact integer rectangle. |
| 193 | |
| 194 | #Param w integer width of constructed Rect ## |
| 195 | #Param h integer height of constructed Rect ## |
| 196 | |
| 197 | #Return bounds (0, 0, w, h) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 198 | |
| 199 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 200 | SkIRect i_rect = SkIRect::MakeWH(25, 35); |
| 201 | SkRect f_rect = SkRect::MakeIWH(25, 35); |
| 202 | SkDebugf("i_rect width: %d f_rect width:%g\n", i_rect.width(), f_rect.width()); |
| 203 | i_rect = SkIRect::MakeWH(125000111, 0); |
| 204 | f_rect = SkRect::MakeIWH(125000111, 0); |
| 205 | SkDebugf("i_rect width: %d f_rect width:%.0f\n", i_rect.width(), f_rect.width()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 206 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 207 | i_rect width: 25 f_rect width:25 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 208 | i_rect width: 125000111 f_rect width:125000112 |
| 209 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 210 | ## |
| 211 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 212 | #SeeAlso MakeXYWH MakeWH isetWH SkIRect::MakeWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 213 | |
| 214 | ## |
| 215 | |
| 216 | # ------------------------------------------------------------------------------ |
| 217 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 218 | #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeSize(const SkSize& size) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 219 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 220 | Returns constructed Rect set to (0, 0, size.width(), size.height()). Does not |
| 221 | validate input; size.width() or size.height() may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 222 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 223 | #Param size SkScalar values for Rect width and height ## |
| 224 | |
| 225 | #Return bounds (0, 0, size.width(), size.height()) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 226 | |
| 227 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 228 | SkSize size = {25.5f, 35.5f}; |
| 229 | SkRect rect = SkRect::MakeSize(size); |
| 230 | SkDebugf("rect width: %g height: %g\n", rect.width(), rect.height()); |
| 231 | SkISize floor = size.toFloor(); |
| 232 | rect = SkRect::MakeSize(SkSize::Make(floor)); |
| 233 | SkDebugf("floor width: %g height: %g\n", rect.width(), rect.height()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 234 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 235 | rect width: 25.5 height: 35.5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 236 | floor width: 25 height: 35 |
| 237 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 238 | ## |
| 239 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 240 | #SeeAlso MakeWH MakeXYWH MakeIWH setWH SkIRect::MakeWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 241 | |
| 242 | ## |
| 243 | |
| 244 | # ------------------------------------------------------------------------------ |
| 245 | |
| 246 | #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeLTRB(SkScalar l, SkScalar t, SkScalar r, |
| 247 | SkScalar b) |
| 248 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 249 | Returns constructed Rect set to (l, t, r, b). Does not sort input; Rect may |
| 250 | result in fLeft greater than fRight, or fTop greater than fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 251 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 252 | #Param l SkScalar stored in fLeft ## |
| 253 | #Param t SkScalar stored in fTop ## |
| 254 | #Param r SkScalar stored in fRight ## |
| 255 | #Param b SkScalar stored in fBottom ## |
| 256 | |
| 257 | #Return bounds (l, t, r, b) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 258 | |
| 259 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 260 | SkRect rect = SkRect::MakeLTRB(5, 35, 15, 25); |
| 261 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 262 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 263 | rect.sort(); |
| 264 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 265 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 266 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 267 | rect: 5, 35, 15, 25 isEmpty: true |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 268 | rect: 5, 25, 15, 35 isEmpty: false |
| 269 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 270 | ## |
| 271 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 272 | #SeeAlso MakeXYWH SkIRect::MakeLTRB |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 273 | |
| 274 | ## |
| 275 | |
| 276 | # ------------------------------------------------------------------------------ |
| 277 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 278 | #Method static constexpr SkRect SK_WARN_UNUSED_RESULT MakeXYWH(SkScalar x, SkScalar y, SkScalar w, SkScalar h) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 279 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 280 | Returns constructed Rect set to |
| 281 | #Formula |
| 282 | (x, y, x + w, y + h) |
| 283 | ## |
| 284 | . Does not validate input; |
| 285 | w or h may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 286 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 287 | #Param x stored in fLeft ## |
| 288 | #Param y stored in fTop ## |
| 289 | #Param w added to x and stored in fRight ## |
| 290 | #Param h added to y and stored in fBottom ## |
| 291 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 292 | #Return bounds at (x, y) with width w and height h ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 293 | |
| 294 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 295 | SkRect rect = SkRect::MakeXYWH(5, 35, -15, 25); |
| 296 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 297 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 298 | rect.sort(); |
| 299 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 300 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 301 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 302 | rect: 5, 35, -10, 60 isEmpty: true |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 303 | rect: -10, 35, 5, 60 isEmpty: false |
| 304 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 305 | ## |
| 306 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 307 | #SeeAlso MakeLTRB SkIRect::MakeXYWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 308 | |
| 309 | ## |
| 310 | |
| 311 | # ------------------------------------------------------------------------------ |
| 312 | |
| 313 | #Method static SkRect SK_WARN_UNUSED_RESULT MakeFromIRect(const SkIRect& irect) |
| 314 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 315 | Deprecated. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 316 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 317 | #Deprecated |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 318 | ## |
| 319 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 320 | #Param irect integer rect ## |
| 321 | |
| 322 | #Return irect as SkRect ## |
| 323 | |
| 324 | #NoExample |
| 325 | ## |
| 326 | |
| 327 | #SeeAlso Make |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 328 | |
| 329 | ## |
| 330 | |
| 331 | # ------------------------------------------------------------------------------ |
| 332 | |
| 333 | #Method static SkRect Make(const SkISize& size) |
| 334 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 335 | Returns constructed IRect set to (0, 0, size.width(), size.height()). |
| 336 | Does not validate input; size.width() or size.height() may be negative. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 337 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 338 | #Param size integer values for Rect width and height ## |
| 339 | |
| 340 | #Return bounds (0, 0, size.width(), size.height()) ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 341 | |
| 342 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 343 | SkRect rect1 = SkRect::MakeSize({2, 35}); |
| 344 | SkRect rect2 = SkRect::MakeIWH(2, 35); |
| 345 | SkDebugf("rect1 %c= rect2\n", rect1 == rect2 ? '=' : '!'); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 346 | #StdOut |
| 347 | rect1 == rect2 |
| 348 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 349 | ## |
| 350 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 351 | #SeeAlso MakeWH MakeXYWH SkRect::MakeIWH SkIRect::MakeSize |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 352 | |
| 353 | ## |
| 354 | |
| 355 | # ------------------------------------------------------------------------------ |
| 356 | |
| 357 | #Method static SkRect SK_WARN_UNUSED_RESULT Make(const SkIRect& irect) |
| 358 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 359 | Returns constructed IRect set to irect, promoting integers to Scalar. |
| 360 | Does not validate input; fLeft may be greater than fRight, fTop may be greater |
| 361 | than fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 362 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 363 | #Param irect integer unsorted bounds ## |
| 364 | |
| 365 | #Return irect members converted to SkScalar ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 366 | |
| 367 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 368 | SkIRect i_rect1 = {2, 35, 22, 53}; |
| 369 | SkRect f_rect = SkRect::Make(i_rect1); |
| 370 | f_rect.offset(0.49f, 0.49f); |
| 371 | SkIRect i_rect2; |
| 372 | f_rect.round(&i_rect2); |
| 373 | SkDebugf("i_rect1 %c= i_rect2\n", i_rect1 == i_rect2? '=' : '!'); |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 374 | ## |
| 375 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 376 | #SeeAlso MakeLTRB |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 377 | |
| 378 | ## |
| 379 | |
| 380 | # ------------------------------------------------------------------------------ |
| 381 | |
| 382 | #Method bool isEmpty() const |
| 383 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 384 | Returns true if fLeft is equal to or greater than fRight, or if fTop is equal |
| 385 | to or greater than fBottom. Call sort() to reverse rectangles with negative |
| 386 | width() or height(). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 387 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 388 | #Return true if width() or height() are zero or negative ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 389 | |
| 390 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 391 | SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}}; |
| 392 | for (auto rect : tests) { |
| 393 | SkDebugf("rect: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 394 | rect.bottom(), rect.isEmpty() ? "" : " not"); |
| 395 | rect.sort(); |
| 396 | SkDebugf("sorted: {%g, %g, %g, %g} is" "%s empty\n", rect.left(), rect.top(), rect.right(), |
| 397 | rect.bottom(), rect.isEmpty() ? "" : " not"); |
| 398 | } |
| 399 | #StdOut |
| 400 | rect: {20, 40, 10, 50} is empty |
| 401 | sorted: {10, 40, 20, 50} is not empty |
| 402 | rect: {20, 40, 20, 50} is empty |
| 403 | sorted: {20, 40, 20, 50} is empty |
| 404 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 405 | ## |
| 406 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 407 | #SeeAlso MakeEmpty sort SkIRect::isEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 408 | |
| 409 | ## |
| 410 | |
| 411 | # ------------------------------------------------------------------------------ |
| 412 | |
| 413 | #Method bool isSorted() const |
| 414 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 415 | Returns true if fLeft is equal to or less than fRight, or if fTop is equal |
| 416 | to or less than fBottom. Call sort() to reverse rectangles with negative |
| 417 | width() or height(). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 418 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 419 | #Return true if width() or height() are zero or positive ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 420 | |
| 421 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 422 | SkRect tests[] = {{20, 40, 10, 50}, {20, 40, 20, 50}}; |
| 423 | for (auto rect : tests) { |
| 424 | SkDebugf("rect: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(), |
| 425 | rect.bottom(), rect.isSorted() ? "" : " not"); |
| 426 | rect.sort(); |
| 427 | SkDebugf("sorted: {%g, %g, %g, %g} is" "%s sorted\n", rect.left(), rect.top(), rect.right(), |
| 428 | rect.bottom(), rect.isSorted() ? "" : " not"); |
| 429 | } |
| 430 | #StdOut |
| 431 | rect: {20, 40, 10, 50} is not sorted |
| 432 | sorted: {10, 40, 20, 50} is sorted |
| 433 | rect: {20, 40, 20, 50} is sorted |
| 434 | sorted: {20, 40, 20, 50} is sorted |
| 435 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 436 | ## |
| 437 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 438 | #SeeAlso sort makeSorted isEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 439 | |
| 440 | ## |
| 441 | |
| 442 | # ------------------------------------------------------------------------------ |
| 443 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 444 | #Method bool isFinite() const |
| 445 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 446 | Returns true if all values in the rectangle are finite: SK_ScalarMin or larger, |
| 447 | and SK_ScalarMax or smaller. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 448 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 449 | #Return true if no member is infinite or NaN ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 450 | |
| 451 | #Example |
Mike Reed | 274218e | 2018-01-08 15:05:02 -0500 | [diff] [blame] | 452 | SkRect largest = { SK_ScalarMin, SK_ScalarMin, SK_ScalarMax, SK_ScalarMax }; |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 453 | SkDebugf("largest is finite: %s\n", largest.isFinite() ? "true" : "false"); |
| 454 | SkDebugf("large width %g\n", largest.width()); |
| 455 | SkRect widest = SkRect::MakeWH(largest.width(), largest.height()); |
| 456 | SkDebugf("widest is finite: %s\n", widest.isFinite() ? "true" : "false"); |
| 457 | #StdOut |
| 458 | largest is finite: true |
| 459 | large width inf |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 460 | widest is finite: false |
| 461 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 462 | ## |
| 463 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 464 | #SeeAlso SkScalarIsFinite SkScalarIsNaN |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 465 | |
| 466 | ## |
| 467 | |
| 468 | # ------------------------------------------------------------------------------ |
| 469 | |
| 470 | #Method SkScalar x() const |
| 471 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 472 | Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid. |
| 473 | Call sort() to reverse fLeft and fRight if needed. |
| 474 | |
| 475 | #Return fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 476 | |
| 477 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 478 | SkRect unsorted = { 15, 5, 10, 25 }; |
| 479 | SkDebugf("unsorted.fLeft: %g unsorted.x(): %g\n", unsorted.fLeft, unsorted.x()); |
| 480 | SkRect sorted = unsorted.makeSorted(); |
| 481 | SkDebugf("sorted.fLeft: %g sorted.x(): %g\n", sorted.fLeft, sorted.x()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 482 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 483 | unsorted.fLeft: 15 unsorted.x(): 15 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 484 | sorted.fLeft: 10 sorted.x(): 10 |
| 485 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 486 | ## |
| 487 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 488 | #SeeAlso fLeft left() y() SkIRect::x() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 489 | |
| 490 | ## |
| 491 | |
| 492 | # ------------------------------------------------------------------------------ |
| 493 | |
| 494 | #Method SkScalar y() const |
| 495 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 496 | Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, |
| 497 | and sort() to reverse fTop and fBottom if needed. |
| 498 | |
| 499 | #Return fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 500 | |
| 501 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 502 | SkRect unsorted = { 15, 25, 10, 5 }; |
| 503 | SkDebugf("unsorted.fTop: %g unsorted.y(): %g\n", unsorted.fTop, unsorted.y()); |
| 504 | SkRect sorted = unsorted.makeSorted(); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 505 | SkDebugf("sorted.fTop: %g sorted.y(): %g\n", sorted.fTop, sorted.y()); |
| 506 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 507 | unsorted.fTop: 25 unsorted.y(): 25 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 508 | sorted.fTop: 5 sorted.y(): 5 |
| 509 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 510 | ## |
| 511 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 512 | #SeeAlso fTop top() x() SkIRect::y() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 513 | |
| 514 | ## |
| 515 | |
| 516 | # ------------------------------------------------------------------------------ |
| 517 | |
| 518 | #Method SkScalar left() const |
| 519 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 520 | Returns left edge of Rect, if sorted. Call isSorted to see if Rect is valid. |
| 521 | Call sort() to reverse fLeft and fRight if needed. |
| 522 | |
| 523 | #Return fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 524 | |
| 525 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 526 | SkRect unsorted = { 15, 5, 10, 25 }; |
| 527 | SkDebugf("unsorted.fLeft: %g unsorted.left(): %g\n", unsorted.fLeft, unsorted.left()); |
| 528 | SkRect sorted = unsorted.makeSorted(); |
| 529 | SkDebugf("sorted.fLeft: %g sorted.left(): %g\n", sorted.fLeft, sorted.left()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 530 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 531 | unsorted.fLeft: 15 unsorted.left(): 15 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 532 | sorted.fLeft: 10 sorted.left(): 10 |
| 533 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 534 | ## |
| 535 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 536 | #SeeAlso fLeft x() SkIRect::left() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 537 | |
| 538 | ## |
| 539 | |
| 540 | # ------------------------------------------------------------------------------ |
| 541 | |
| 542 | #Method SkScalar top() const |
| 543 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 544 | Returns top edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, |
| 545 | and sort() to reverse fTop and fBottom if needed. |
| 546 | |
| 547 | #Return fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 548 | |
| 549 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 550 | SkRect unsorted = { 15, 25, 10, 5 }; |
| 551 | SkDebugf("unsorted.fTop: %g unsorted.top(): %g\n", unsorted.fTop, unsorted.top()); |
| 552 | SkRect sorted = unsorted.makeSorted(); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 553 | SkDebugf("sorted.fTop: %g sorted.top(): %g\n", sorted.fTop, sorted.top()); |
| 554 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 555 | unsorted.fTop: 25 unsorted.top(): 25 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 556 | sorted.fTop: 5 sorted.top(): 5 |
| 557 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 558 | ## |
| 559 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 560 | #SeeAlso fTop y() SkIRect::top() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 561 | |
| 562 | ## |
| 563 | |
| 564 | # ------------------------------------------------------------------------------ |
| 565 | |
| 566 | #Method SkScalar right() const |
| 567 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 568 | Returns right edge of Rect, if sorted. Call isSorted to see if Rect is valid. |
| 569 | Call sort() to reverse fLeft and fRight if needed. |
| 570 | |
| 571 | #Return fRight ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 572 | |
| 573 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 574 | SkRect unsorted = { 15, 25, 10, 5 }; |
| 575 | SkDebugf("unsorted.fRight: %g unsorted.right(): %g\n", unsorted.fRight, unsorted.right()); |
| 576 | SkRect sorted = unsorted.makeSorted(); |
| 577 | SkDebugf("sorted.fRight: %g sorted.right(): %g\n", sorted.fRight, sorted.right()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 578 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 579 | unsorted.fRight: 10 unsorted.right(): 10 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 580 | sorted.fRight: 15 sorted.right(): 15 |
| 581 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 582 | ## |
| 583 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 584 | #SeeAlso fRight SkIRect::right() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 585 | |
| 586 | ## |
| 587 | |
| 588 | # ------------------------------------------------------------------------------ |
| 589 | |
| 590 | #Method SkScalar bottom() const |
| 591 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 592 | Returns bottom edge of Rect, if sorted. Call isEmpty to see if Rect may be invalid, |
| 593 | and sort() to reverse fTop and fBottom if needed. |
| 594 | |
| 595 | #Return fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 596 | |
| 597 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 598 | SkRect unsorted = { 15, 25, 10, 5 }; |
| 599 | SkDebugf("unsorted.fBottom: %g unsorted.bottom(): %g\n", unsorted.fBottom, unsorted.bottom()); |
| 600 | SkRect sorted = unsorted.makeSorted(); |
| 601 | SkDebugf("sorted.fBottom: %g sorted.bottom(): %g\n", sorted.fBottom, sorted.bottom()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 602 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 603 | unsorted.fBottom: 5 unsorted.bottom(): 5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 604 | sorted.fBottom: 25 sorted.bottom(): 25 |
| 605 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 606 | ## |
| 607 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 608 | #SeeAlso fBottom SkIRect::bottom() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 609 | |
| 610 | ## |
| 611 | |
| 612 | # ------------------------------------------------------------------------------ |
| 613 | |
| 614 | #Method SkScalar width() const |
| 615 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 616 | Returns span on the x-axis. This does not check if Rect is sorted, or if |
| 617 | result fits in 32-bit float; result may be negative or infinity. |
| 618 | |
| 619 | #Return fRight minus fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 620 | |
| 621 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 622 | #Description |
| 623 | Compare with SkIRect::width() example. |
| 624 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 625 | SkRect unsorted = { 15, 25, 10, 5 }; |
| 626 | SkDebugf("unsorted width: %g\n", unsorted.width()); |
| 627 | SkRect large = { -2147483647.f, 1, 2147483644.f, 2 }; |
| 628 | SkDebugf("large width: %.0f\n", large.width()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 629 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 630 | unsorted width: -5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 631 | large width: 4294967296 |
| 632 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 633 | ## |
| 634 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 635 | #SeeAlso height() SkIRect::width() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 636 | |
| 637 | ## |
| 638 | |
| 639 | # ------------------------------------------------------------------------------ |
| 640 | |
| 641 | #Method SkScalar height() const |
| 642 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 643 | Returns span on the y-axis. This does not check if IRect is sorted, or if |
| 644 | result fits in 32-bit float; result may be negative or infinity. |
| 645 | |
| 646 | #Return fBottom minus fTop ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 647 | |
| 648 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 649 | #Description |
| 650 | Compare with SkIRect::height() example. |
| 651 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 652 | SkRect unsorted = { 15, 25, 10, 20 }; |
| 653 | SkDebugf("unsorted height: %g\n", unsorted.height()); |
| 654 | SkRect large = { 1, -2147483647.f, 2, 2147483644.f }; |
| 655 | SkDebugf("large height: %.0f\n", large.height()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 656 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 657 | unsorted height: -5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 658 | large height: 4294967296 |
| 659 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 660 | ## |
| 661 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 662 | #SeeAlso width() SkIRect::height() |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 663 | |
| 664 | ## |
| 665 | |
| 666 | # ------------------------------------------------------------------------------ |
| 667 | |
| 668 | #Method SkScalar centerX() const |
| 669 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 670 | Returns average of left edge and right edge. Result does not change if Rect |
| 671 | is sorted. Result may overflow to infinity if Rect is far from the origin. |
| 672 | |
| 673 | #Return midpoint in x ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 674 | |
| 675 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 676 | SkRect tests[] = {{20, 30, 41, 51}, {-20, -30, -41, -51}}; |
| 677 | for (auto rect : tests) { |
| 678 | SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX()); |
| 679 | rect.sort(); |
| 680 | SkDebugf("left: %3g right: %3g centerX: %3g\n", rect.left(), rect.right(), rect.centerX()); |
| 681 | } |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 682 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 683 | left: 20 right: 41 centerX: 30.5 |
| 684 | left: 20 right: 41 centerX: 30.5 |
| 685 | left: -20 right: -41 centerX: -30.5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 686 | left: -41 right: -20 centerX: -30.5 |
| 687 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 688 | ## |
| 689 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 690 | #SeeAlso centerY SkIRect::centerX |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 691 | |
| 692 | ## |
| 693 | |
| 694 | # ------------------------------------------------------------------------------ |
| 695 | |
| 696 | #Method SkScalar centerY() const |
| 697 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 698 | Returns average of top edge and bottom edge. Result does not change if Rect |
| 699 | is sorted. Result may overflow to infinity if Rect is far from the origin. |
| 700 | |
| 701 | #Return midpoint in y ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 702 | |
| 703 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 704 | SkRect rect = { 2e+38, 2e+38, 3e+38, 3e+38 }; |
| 705 | SkDebugf("left: %g right: %g centerX: %g ", rect.left(), rect.right(), rect.centerX()); |
| 706 | SkDebugf("safe mid x: %g\n", rect.left() / 2 + rect.right() / 2); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 707 | #StdOut |
| 708 | left: 2e+38 right: 3e+38 centerX: inf safe mid x: 2.5e+38 |
| 709 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 710 | ## |
| 711 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 712 | #SeeAlso centerX SkIRect::centerY |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 713 | |
| 714 | ## |
| 715 | |
| 716 | # ------------------------------------------------------------------------------ |
| 717 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 718 | #Method bool operator==(const SkRect& a, const SkRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 719 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 720 | Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are |
| 721 | equal to the corresponding members in b. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 722 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 723 | a and b are not equal if either contain NaN. a and b are equal if members |
| 724 | contain zeroes width different signs. |
| 725 | |
| 726 | #Param a Rect to compare ## |
| 727 | #Param b Rect to compare ## |
| 728 | |
| 729 | #Return true if members are equal ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 730 | |
| 731 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 732 | auto debugster = [](const SkRect& test) -> void { |
| 733 | SkRect negZero = {-0.0f, -0.0f, 2, 2}; |
| 734 | SkDebugf("{%g, %g, %g, %g} %c= {%g, %g, %g, %g} %s numerically equal\n", |
| 735 | test.fLeft, test.fTop, test.fRight, test.fBottom, |
| 736 | negZero.fLeft, negZero.fTop, negZero.fRight, negZero.fBottom, |
| 737 | test == negZero ? '=' : '!', |
| 738 | test.fLeft == negZero.fLeft && test.fTop == negZero.fTop && |
| 739 | test.fRight == negZero.fRight && test.fBottom == negZero.fBottom ? |
| 740 | "and are" : "yet are not"); |
| 741 | }; |
| 742 | SkRect tests[] = {{0, 0, 2, 2}, {-0, -0, 2, 2}, {0.0f, 0.0f, 2, 2}}; |
| 743 | SkDebugf("tests are %s" "equal\n", tests[0] == tests[1] && tests[1] == tests[2] ? "" : "not "); |
| 744 | for (auto rect : tests) { |
| 745 | debugster(rect); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 746 | } |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 747 | #StdOut |
| 748 | tests are equal |
| 749 | {0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal |
| 750 | {0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 751 | {0, 0, 2, 2} == {-0, -0, 2, 2} and are numerically equal |
| 752 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 753 | ## |
| 754 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 755 | #SeeAlso operator!=(const SkRect& a, const SkRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 756 | |
| 757 | ## |
| 758 | |
| 759 | # ------------------------------------------------------------------------------ |
| 760 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 761 | #Method bool operator!=(const SkRect& a, const SkRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 762 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 763 | Returns true if any in a: fLeft, fTop, fRight, and fBottom; does not |
| 764 | equal the corresponding members in b. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 765 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 766 | a and b are not equal if either contain NaN. a and b are equal if members |
| 767 | contain zeroes width different signs. |
| 768 | |
| 769 | #Param a Rect to compare ## |
| 770 | #Param b Rect to compare ## |
| 771 | |
| 772 | #Return true if members are not equal ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 773 | |
| 774 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 775 | SkRect test = {0, 0, 2, SK_ScalarNaN}; |
| 776 | SkDebugf("test with NaN is %s" "equal to itself\n", test == test ? "" : "not "); |
| 777 | #StdOut |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 778 | test with NaN is not equal to itself |
| 779 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 780 | ## |
| 781 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 782 | #SeeAlso operator==(const SkRect& a, const SkRect& b) |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 783 | |
| 784 | ## |
| 785 | |
| 786 | # ------------------------------------------------------------------------------ |
| 787 | |
| 788 | #Method void toQuad(SkPoint quad[4]) const |
| 789 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 790 | Returns four points in quad that enclose Rect ordered as: top-left, top-right, |
| 791 | bottom-right, bottom-left. |
| 792 | |
| 793 | #Private |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 794 | Consider adding param to control whether quad is CW or CCW. |
| 795 | ## |
| 796 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 797 | #Param quad storage for corners of Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 798 | |
| 799 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 800 | SkRect rect = {1, 2, 3, 4}; |
| 801 | SkPoint corners[4]; |
| 802 | rect.toQuad(corners); |
| 803 | SkDebugf("rect: {%g, %g, %g, %g}\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 804 | SkDebugf("corners:"); |
| 805 | for (auto corner : corners) { |
| 806 | SkDebugf(" {%g, %g}", corner.fX, corner.fY); |
| 807 | } |
| 808 | SkDebugf("\n"); |
| 809 | #StdOut |
| 810 | rect: {1, 2, 3, 4} |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 811 | corners: {1, 2} {3, 2} {3, 4} {1, 4} |
| 812 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 813 | ## |
| 814 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 815 | #SeeAlso SkPath::addRect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 816 | |
| 817 | ## |
| 818 | |
| 819 | # ------------------------------------------------------------------------------ |
| 820 | |
| 821 | #Method void setEmpty() |
| 822 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 823 | Sets Rect to (0, 0, 0, 0). |
| 824 | |
| 825 | Many other rectangles are empty; if left is equal to or greater than right, |
| 826 | or if top is equal to or greater than bottom. Setting all members to zero |
| 827 | is a convenience, but does not designate a special empty rectangle. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 828 | |
| 829 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 830 | SkRect rect = {3, 4, 1, 2}; |
| 831 | for (int i = 0; i < 2; ++i) { |
| 832 | SkDebugf("rect: {%g, %g, %g, %g} is %s" "empty\n", rect.fLeft, rect.fTop, |
| 833 | rect.fRight, rect.fBottom, rect.isEmpty() ? "" : "not "); |
| 834 | rect.setEmpty(); |
| 835 | } |
| 836 | #StdOut |
| 837 | rect: {3, 4, 1, 2} is empty |
| 838 | rect: {0, 0, 0, 0} is empty |
| 839 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 840 | ## |
| 841 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 842 | #SeeAlso MakeEmpty SkIRect::setEmpty |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 843 | |
| 844 | ## |
| 845 | |
| 846 | # ------------------------------------------------------------------------------ |
| 847 | |
| 848 | #Method void set(const SkIRect& src) |
| 849 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 850 | Sets Rect to src, promoting src members from integer to Scalar. |
| 851 | Very large values in src may lose precision. |
| 852 | |
| 853 | #Param src integer Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 854 | |
| 855 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 856 | SkIRect i_rect = {3, 4, 1, 2}; |
| 857 | SkDebugf("i_rect: {%d, %d, %d, %d}\n", i_rect.fLeft, i_rect.fTop, i_rect.fRight, i_rect.fBottom); |
| 858 | SkRect f_rect; |
| 859 | f_rect.set(i_rect); |
| 860 | SkDebugf("f_rect: {%g, %g, %g, %g}\n", f_rect.fLeft, f_rect.fTop, f_rect.fRight, f_rect.fBottom); |
| 861 | #StdOut |
| 862 | i_rect: {3, 4, 1, 2} |
| 863 | f_rect: {3, 4, 1, 2} |
| 864 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 865 | ## |
| 866 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 867 | #SeeAlso setLTRB SkIntToScalar |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 868 | |
| 869 | ## |
| 870 | |
| 871 | # ------------------------------------------------------------------------------ |
| 872 | |
| 873 | #Method void set(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) |
| 874 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 875 | Sets Rect to (left, top, right, bottom). |
| 876 | left and right are not sorted; left is not necessarily less than right. |
| 877 | top and bottom are not sorted; top is not necessarily less than bottom. |
| 878 | |
| 879 | #Param left stored in fLeft ## |
| 880 | #Param top stored in fTop ## |
| 881 | #Param right stored in fRight ## |
| 882 | #Param bottom stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 883 | |
| 884 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 885 | SkRect rect1 = {3, 4, 1, 2}; |
| 886 | SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 887 | SkRect rect2; |
| 888 | rect2.set(3, 4, 1, 2); |
| 889 | SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
| 890 | #StdOut |
| 891 | rect1: {3, 4, 1, 2} |
| 892 | rect2: {3, 4, 1, 2} |
| 893 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 894 | ## |
| 895 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 896 | #SeeAlso setLTRB setXYWH SkIRect::set |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 897 | |
| 898 | ## |
| 899 | |
| 900 | # ------------------------------------------------------------------------------ |
| 901 | |
| 902 | #Method void setLTRB(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) |
| 903 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 904 | Sets Rect to (left, top, right, bottom). |
| 905 | left and right are not sorted; left is not necessarily less than right. |
| 906 | top and bottom are not sorted; top is not necessarily less than bottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 907 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 908 | #Param left stored in fLeft ## |
| 909 | #Param top stored in fTop ## |
| 910 | #Param right stored in fRight ## |
| 911 | #Param bottom stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 912 | |
| 913 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 914 | SkRect rect1 = {3, 4, 1, 2}; |
| 915 | SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 916 | SkRect rect2; |
| 917 | rect2.setLTRB(3, 4, 1, 2); |
| 918 | SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
| 919 | #StdOut |
| 920 | rect1: {3, 4, 1, 2} |
| 921 | rect2: {3, 4, 1, 2} |
| 922 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 923 | ## |
| 924 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 925 | #SeeAlso set setXYWH SkIRect::set |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 926 | |
| 927 | ## |
| 928 | |
| 929 | # ------------------------------------------------------------------------------ |
| 930 | |
| 931 | #Method void iset(int left, int top, int right, int bottom) |
| 932 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 933 | Sets Rect to (left, top, right, bottom). |
| 934 | All parameters are promoted from integer to Scalar. |
| 935 | left and right are not sorted; left is not necessarily less than right. |
| 936 | top and bottom are not sorted; top is not necessarily less than bottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 937 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 938 | #Param left promoted to SkScalar and stored in fLeft ## |
| 939 | #Param top promoted to SkScalar and stored in fTop ## |
| 940 | #Param right promoted to SkScalar and stored in fRight ## |
| 941 | #Param bottom promoted to SkScalar and stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 942 | |
| 943 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 944 | SkRect rect1 = {3, 4, 1, 2}; |
| 945 | SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 946 | SkRect rect2; |
| 947 | rect2.iset(3, 4, 1, 2); |
| 948 | SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
| 949 | #StdOut |
| 950 | rect1: {3, 4, 1, 2} |
| 951 | rect2: {3, 4, 1, 2} |
| 952 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 953 | ## |
| 954 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 955 | #SeeAlso set setLTRB SkIRect::set SkIntToScalar |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 956 | |
| 957 | ## |
| 958 | |
| 959 | # ------------------------------------------------------------------------------ |
| 960 | |
| 961 | #Method void isetWH(int width, int height) |
| 962 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 963 | Sets Rect to (0, 0, width, height). |
| 964 | width and height may be zero or negative. width and height are promoted from |
| 965 | integer to SkScalar, large values may lose precision. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 966 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 967 | #Param width promoted to SkScalar and stored in fRight ## |
| 968 | #Param height promoted to SkScalar and stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 969 | |
| 970 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 971 | SkRect rect1 = {0, 0, 1, 2}; |
| 972 | SkDebugf("rect1: {%g, %g, %g, %g}\n", rect1.fLeft, rect1.fTop, rect1.fRight, rect1.fBottom); |
| 973 | SkRect rect2; |
| 974 | rect2.isetWH(1, 2); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 975 | SkDebugf("rect2: {%g, %g, %g, %g}\n", rect2.fLeft, rect2.fTop, rect2.fRight, rect2.fBottom); |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 976 | #StdOut |
| 977 | rect1: {0, 0, 1, 2} |
| 978 | rect2: {0, 0, 1, 2} |
| 979 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 980 | ## |
| 981 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 982 | #SeeAlso MakeWH MakeXYWH iset() SkIRect:MakeWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 983 | |
| 984 | ## |
| 985 | |
| 986 | # ------------------------------------------------------------------------------ |
| 987 | |
| 988 | #Method void set(const SkPoint pts[], int count) |
| 989 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 990 | Sets to bounds of Point array with count entries. If count is zero or smaller, |
| 991 | or if Point array contains an infinity or NaN, sets Rect to (0, 0, 0, 0). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 992 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 993 | Result is either empty or sorted: fLeft is less than or equal to fRight, and |
| 994 | fTop is less than or equal to fBottom. |
| 995 | |
| 996 | #Param pts Point array ## |
| 997 | #Param count entries in array ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 998 | |
| 999 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1000 | SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; |
| 1001 | for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { |
| 1002 | SkRect rect; |
| 1003 | rect.set(points, count); |
| 1004 | if (count > 0) { |
| 1005 | SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY); |
| 1006 | } else { |
| 1007 | SkDebugf("%14s", " "); |
| 1008 | } |
| 1009 | SkDebugf("count: %d rect: %g, %g, %g, %g\n", count, |
| 1010 | rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1011 | } |
| 1012 | #StdOut |
| 1013 | count: 0 rect: 0, 0, 0, 0 |
| 1014 | added: 3, 4 count: 1 rect: 3, 4, 3, 4 |
| 1015 | added: 1, 2 count: 2 rect: 1, 2, 3, 4 |
| 1016 | added: 5, 6 count: 3 rect: 1, 2, 5, 6 |
| 1017 | added: nan, 8 count: 4 rect: 0, 0, 0, 0 |
| 1018 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1019 | ## |
| 1020 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1021 | #SeeAlso setBounds setBoundsCheck SkPath::addPoly |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1022 | |
| 1023 | ## |
| 1024 | |
| 1025 | # ------------------------------------------------------------------------------ |
| 1026 | |
| 1027 | #Method void setBounds(const SkPoint pts[], int count) |
| 1028 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1029 | Sets to bounds of Point array with count entries. If count is zero or smaller, |
| 1030 | or if Point array contains an infinity or NaN, sets to (0, 0, 0, 0). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1031 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1032 | Result is either empty or sorted: fLeft is less than or equal to fRight, and |
| 1033 | fTop is less than or equal to fBottom. |
| 1034 | |
| 1035 | #Param pts Point array ## |
| 1036 | #Param count entries in array ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1037 | |
| 1038 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1039 | SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; |
| 1040 | for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { |
| 1041 | SkRect rect; |
| 1042 | rect.setBounds(points, count); |
| 1043 | if (count > 0) { |
| 1044 | SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY); |
| 1045 | } else { |
| 1046 | SkDebugf("%14s", " "); |
| 1047 | } |
| 1048 | SkDebugf("count: %d rect: %g, %g, %g, %g\n", count, |
| 1049 | rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1050 | } |
| 1051 | #StdOut |
| 1052 | count: 0 rect: 0, 0, 0, 0 |
| 1053 | added: 3, 4 count: 1 rect: 3, 4, 3, 4 |
| 1054 | added: 1, 2 count: 2 rect: 1, 2, 3, 4 |
| 1055 | added: 5, 6 count: 3 rect: 1, 2, 5, 6 |
| 1056 | added: nan, 8 count: 4 rect: 0, 0, 0, 0 |
| 1057 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1058 | ## |
| 1059 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1060 | #SeeAlso set setBoundsCheck SkPath::addPoly |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1061 | |
| 1062 | ## |
| 1063 | |
| 1064 | # ------------------------------------------------------------------------------ |
| 1065 | |
| 1066 | #Method bool setBoundsCheck(const SkPoint pts[], int count) |
| 1067 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1068 | Sets to bounds of Point array with count entries. Returns false if count is |
| 1069 | zero or smaller, or if Point array contains an infinity or NaN; in these cases |
| 1070 | sets Rect to (0, 0, 0, 0). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1071 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1072 | Result is either empty or sorted: fLeft is less than or equal to fRight, and |
| 1073 | fTop is less than or equal to fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1074 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1075 | #Param pts Point array ## |
| 1076 | #Param count entries in array ## |
| 1077 | |
| 1078 | #Return true if all Point values are finite ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1079 | |
| 1080 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1081 | SkPoint points[] = {{3, 4}, {1, 2}, {5, 6}, {SK_ScalarNaN, 8}}; |
| 1082 | for (int count = 0; count <= (int) SK_ARRAY_COUNT(points); ++count) { |
| 1083 | SkRect rect; |
| 1084 | bool success = rect.setBoundsCheck(points, count); |
| 1085 | if (count > 0) { |
| 1086 | SkDebugf("added: %3g, %g ", points[count - 1].fX, points[count - 1].fY); |
| 1087 | } else { |
| 1088 | SkDebugf("%14s", " "); |
| 1089 | } |
| 1090 | SkDebugf("count: %d rect: %g, %g, %g, %g success: %s\n", count, |
| 1091 | rect.fLeft, rect.fTop, rect.fRight, rect.fBottom, success ? "true" : "false"); |
| 1092 | } |
| 1093 | #StdOut |
| 1094 | count: 0 rect: 0, 0, 0, 0 success: true |
| 1095 | added: 3, 4 count: 1 rect: 3, 4, 3, 4 success: true |
| 1096 | added: 1, 2 count: 2 rect: 1, 2, 3, 4 success: true |
| 1097 | added: 5, 6 count: 3 rect: 1, 2, 5, 6 success: true |
| 1098 | added: nan, 8 count: 4 rect: 0, 0, 0, 0 success: false |
| 1099 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1100 | ## |
| 1101 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1102 | #SeeAlso set setBounds SkPath::addPoly |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1103 | |
| 1104 | ## |
| 1105 | |
| 1106 | # ------------------------------------------------------------------------------ |
| 1107 | |
| 1108 | #Method void set(const SkPoint& p0, const SkPoint& p1) |
| 1109 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1110 | Sets bounds to the smallest Rect enclosing Points p0 and p1. The result is |
| 1111 | sorted and may be empty. Does not check to see if values are finite. |
| 1112 | |
| 1113 | #Param p0 corner to include ## |
| 1114 | #Param p1 corner to include ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1115 | |
| 1116 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1117 | #Description |
| 1118 | p0 and p1 may be swapped and have the same effect unless one contains NaN. |
| 1119 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1120 | SkPoint point1 = {SK_ScalarNaN, 8}; |
| 1121 | SkPoint point2 = {3, 4}; |
| 1122 | SkRect rect; |
| 1123 | rect.set(point1, point2); |
| 1124 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1125 | rect.set(point2, point1); |
| 1126 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1127 | ## |
| 1128 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1129 | #SeeAlso setBounds setBoundsCheck |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1130 | |
| 1131 | ## |
| 1132 | |
| 1133 | # ------------------------------------------------------------------------------ |
| 1134 | |
| 1135 | #Method void setXYWH(SkScalar x, SkScalar y, SkScalar width, SkScalar height) |
| 1136 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1137 | Sets Rect to |
| 1138 | #Formula |
| 1139 | (x, y, x + width, y + height) |
| 1140 | ## |
| 1141 | . Does not validate input; |
| 1142 | width or height may be negative. |
| 1143 | |
| 1144 | #Param x stored in fLeft ## |
| 1145 | #Param y stored in fTop ## |
| 1146 | #Param width added to x and stored in fRight ## |
| 1147 | #Param height added to y and stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1148 | |
| 1149 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1150 | SkRect rect; |
| 1151 | rect.setXYWH(5, 35, -15, 25); |
| 1152 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1153 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1154 | rect.sort(); |
| 1155 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1156 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1157 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1158 | rect: 5, 35, -10, 60 isEmpty: true |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1159 | rect: -10, 35, 5, 60 isEmpty: false |
| 1160 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1161 | ## |
| 1162 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1163 | #SeeAlso MakeXYWH setLTRB set SkIRect::setXYWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1164 | |
| 1165 | ## |
| 1166 | |
| 1167 | # ------------------------------------------------------------------------------ |
| 1168 | |
| 1169 | #Method void setWH(SkScalar width, SkScalar height) |
| 1170 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1171 | Sets Rect to (0, 0, width, height). Does not validate input; |
| 1172 | width or height may be negative. |
| 1173 | |
| 1174 | #Param width stored in fRight ## |
| 1175 | #Param height stored in fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1176 | |
| 1177 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1178 | SkRect rect; |
| 1179 | rect.setWH(-15, 25); |
| 1180 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1181 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1182 | rect.sort(); |
| 1183 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1184 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1185 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1186 | rect: 0, 0, -15, 25 isEmpty: true |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1187 | rect: -15, 0, 0, 25 isEmpty: false |
| 1188 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1189 | ## |
| 1190 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1191 | #SeeAlso MakeWH setXYWH isetWH |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1192 | |
| 1193 | ## |
| 1194 | |
| 1195 | # ------------------------------------------------------------------------------ |
| 1196 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1197 | #Method SkRect makeOffset(SkScalar dx, SkScalar dy) const |
| 1198 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1199 | Returns Rect offset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1200 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1201 | If dx is negative, Rect returned is moved to the left. |
| 1202 | If dx is positive, Rect returned is moved to the right. |
| 1203 | If dy is negative, Rect returned is moved upward. |
| 1204 | If dy is positive, Rect returned is moved downward. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1205 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1206 | #Param dx added to fLeft and fRight ## |
| 1207 | #Param dy added to fTop and fBottom ## |
| 1208 | |
| 1209 | #Return Rect offset in x or y, with original width and height ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1210 | |
| 1211 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1212 | SkRect rect = { 10, 50, 20, 60 }; |
| 1213 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1214 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1215 | rect = rect.makeOffset(15, 32); |
| 1216 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1217 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1218 | #StdOut |
| 1219 | rect: 10, 50, 20, 60 isEmpty: false |
| 1220 | rect: 25, 82, 35, 92 isEmpty: false |
| 1221 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1222 | ## |
| 1223 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1224 | #SeeAlso offset() makeInset makeOutset SkIRect::makeOffset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1225 | |
| 1226 | ## |
| 1227 | |
| 1228 | # ------------------------------------------------------------------------------ |
| 1229 | |
| 1230 | #Method SkRect makeInset(SkScalar dx, SkScalar dy) const |
| 1231 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1232 | Returns Rect, inset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1233 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1234 | If dx is negative, Rect returned is wider. |
| 1235 | If dx is positive, Rect returned is narrower. |
| 1236 | If dy is negative, Rect returned is taller. |
| 1237 | If dy is positive, Rect returned is shorter. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1238 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1239 | #Param dx added to fLeft and subtracted from fRight ## |
| 1240 | #Param dy added to fTop and subtracted from fBottom ## |
| 1241 | |
| 1242 | #Return Rect inset symmetrically left and right, top and bottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1243 | |
| 1244 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1245 | SkRect rect = { 10, 50, 20, 60 }; |
| 1246 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1247 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1248 | rect = rect.makeInset(15, 32); |
| 1249 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1250 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1251 | #StdOut |
| 1252 | rect: 10, 50, 20, 60 isEmpty: false |
| 1253 | rect: 25, 82, 5, 28 isEmpty: true |
| 1254 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1255 | ## |
| 1256 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1257 | #SeeAlso inset() makeOffset makeOutset SkIRect::makeInset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1258 | |
| 1259 | ## |
| 1260 | |
| 1261 | # ------------------------------------------------------------------------------ |
| 1262 | |
| 1263 | #Method SkRect makeOutset(SkScalar dx, SkScalar dy) const |
| 1264 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1265 | Returns Rect, outset by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1266 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1267 | If dx is negative, Rect returned is narrower. |
| 1268 | If dx is positive, Rect returned is wider. |
| 1269 | If dy is negative, Rect returned is shorter. |
| 1270 | If dy is positive, Rect returned is taller. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1271 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1272 | #Param dx subtracted to fLeft and added from fRight ## |
| 1273 | #Param dy subtracted to fTop and added from fBottom ## |
| 1274 | |
| 1275 | #Return Rect outset symmetrically left and right, top and bottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1276 | |
| 1277 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1278 | SkRect rect = { 10, 50, 20, 60 }; |
| 1279 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1280 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1281 | rect = rect.makeOutset(15, 32); |
| 1282 | SkDebugf("rect: %g, %g, %g, %g isEmpty: %s\n", rect.left(), rect.top(), rect.right(), |
| 1283 | rect.bottom(), rect.isEmpty() ? "true" : "false"); |
| 1284 | #StdOut |
| 1285 | rect: 10, 50, 20, 60 isEmpty: false |
| 1286 | rect: -5, 18, 35, 92 isEmpty: false |
| 1287 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1288 | ## |
| 1289 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1290 | #SeeAlso outset() makeOffset makeInset SkIRect::makeOutset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1291 | |
| 1292 | ## |
| 1293 | |
| 1294 | # ------------------------------------------------------------------------------ |
| 1295 | |
| 1296 | #Method void offset(SkScalar dx, SkScalar dy) |
| 1297 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1298 | Offsets Rect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1299 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1300 | If dx is negative, moves Rect to the left. |
| 1301 | If dx is positive, moves Rect to the right. |
| 1302 | If dy is negative, moves Rect upward. |
| 1303 | If dy is positive, moves Rect downward. |
| 1304 | |
| 1305 | #Param dx offset added to fLeft and fRight ## |
| 1306 | #Param dy offset added to fTop and fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1307 | |
| 1308 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1309 | SkRect rect = { 10, 14, 50, 73 }; |
| 1310 | rect.offset(5, 13); |
| 1311 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1312 | #StdOut |
| 1313 | rect: 15, 27, 55, 86 |
| 1314 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1315 | ## |
| 1316 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1317 | #SeeAlso offsetTo makeOffset SkIRect::offset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1318 | |
| 1319 | ## |
| 1320 | |
| 1321 | # ------------------------------------------------------------------------------ |
| 1322 | |
| 1323 | #Method void offset(const SkPoint& delta) |
| 1324 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1325 | Offsets Rect by adding delta.fX to fLeft, fRight; and by adding delta.fY to |
| 1326 | fTop, fBottom. |
| 1327 | |
| 1328 | If delta.fX is negative, moves Rect to the left. |
| 1329 | If delta.fX is positive, moves Rect to the right. |
| 1330 | If delta.fY is negative, moves Rect upward. |
| 1331 | If delta.fY is positive, moves Rect downward. |
| 1332 | |
| 1333 | #Param delta added to Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1334 | |
| 1335 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1336 | SkRect rect = { 10, 14, 50, 73 }; |
| 1337 | rect.offset({5, 13}); |
| 1338 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1339 | #StdOut |
| 1340 | rect: 15, 27, 55, 86 |
| 1341 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1342 | ## |
| 1343 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1344 | #SeeAlso offsetTo makeOffset SkIRect::offset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1345 | |
| 1346 | ## |
| 1347 | |
| 1348 | # ------------------------------------------------------------------------------ |
| 1349 | |
| 1350 | #Method void offsetTo(SkScalar newX, SkScalar newY) |
| 1351 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1352 | Offsets Rect so that fLeft equals newX, and fTop equals newY. width and height |
| 1353 | are unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1354 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1355 | #Param newX stored in fLeft, preserving width() ## |
| 1356 | #Param newY stored in fTop, preserving height() ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1357 | |
| 1358 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1359 | SkRect rect = { 10, 14, 50, 73 }; |
| 1360 | rect.offsetTo(15, 27); |
| 1361 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1362 | #StdOut |
| 1363 | rect: 15, 27, 55, 86 |
| 1364 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1365 | ## |
| 1366 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1367 | #SeeAlso offset makeOffset setXYWH SkIRect::offsetTo |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1368 | |
| 1369 | ## |
| 1370 | |
| 1371 | # ------------------------------------------------------------------------------ |
| 1372 | |
| 1373 | #Method void inset(SkScalar dx, SkScalar dy) |
| 1374 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1375 | Insets Rect by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1376 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1377 | If dx is positive, makes Rect narrower. |
| 1378 | If dx is negative, makes Rect wider. |
| 1379 | If dy is positive, makes Rect shorter. |
| 1380 | If dy is negative, makes Rect taller. |
| 1381 | |
| 1382 | #Param dx added to fLeft and subtracted from fRight ## |
| 1383 | #Param dy added to fTop and subtracted from fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1384 | |
| 1385 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1386 | SkRect rect = { 10, 14, 50, 73 }; |
| 1387 | rect.inset(5, 13); |
| 1388 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1389 | #StdOut |
| 1390 | rect: 15, 27, 45, 60 |
| 1391 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1392 | ## |
| 1393 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1394 | #SeeAlso outset makeInset SkIRect::inset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1395 | |
| 1396 | ## |
| 1397 | |
| 1398 | # ------------------------------------------------------------------------------ |
| 1399 | |
| 1400 | #Method void outset(SkScalar dx, SkScalar dy) |
| 1401 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1402 | Outsets Rect by (dx, dy). |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1403 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1404 | If dx is positive, makes Rect wider. |
| 1405 | If dx is negative, makes Rect narrower. |
| 1406 | If dy is positive, makes Rect taller. |
| 1407 | If dy is negative, makes Rect shorter. |
| 1408 | |
| 1409 | #Param dx subtracted to fLeft and added from fRight ## |
| 1410 | #Param dy subtracted to fTop and added from fBottom ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1411 | |
| 1412 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1413 | SkRect rect = { 10, 14, 50, 73 }; |
| 1414 | rect.outset(5, 13); |
| 1415 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1416 | #StdOut |
| 1417 | rect: 5, 1, 55, 86 |
| 1418 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1419 | ## |
| 1420 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1421 | #SeeAlso inset makeOutset SkIRect::outset |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1422 | |
| 1423 | ## |
| 1424 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1425 | #Topic Intersection |
| 1426 | |
| 1427 | Rects intersect when they enclose a common area. To intersect, each of the pair |
| 1428 | must describe area; fLeft is less than fRight, and fTop is less than fBottom; |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1429 | empty() returns false. The intersection of Rect pair can be described by: |
| 1430 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1431 | #Formula |
| 1432 | (max(a.fLeft, b.fLeft), max(a.fTop, b.fTop), |
| 1433 | min(a.fRight, b.fRight), min(a.fBottom, b.fBottom)) |
| 1434 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1435 | . |
| 1436 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1437 | The intersection is only meaningful if the resulting Rect is not empty and |
| 1438 | describes an area: fLeft is less than fRight, and fTop is less than fBottom. |
| 1439 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1440 | # ------------------------------------------------------------------------------ |
| 1441 | |
| 1442 | #Method bool intersect(const SkRect& r) |
| 1443 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1444 | Returns true if Rect intersects r, and sets Rect to intersection. |
| 1445 | Returns false if Rect does not intersect r, and leaves Rect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1446 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1447 | Returns false if either r or Rect is empty, leaving Rect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1448 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1449 | #Param r limit of result ## |
| 1450 | |
| 1451 | #Return true if r and Rect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1452 | |
| 1453 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1454 | #Description |
| 1455 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1456 | may not be evaluated in left to right order: the printed intersection may |
| 1457 | be before or after the call to intersect. |
| 1458 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1459 | SkRect leftRect = { 10, 40, 50, 80 }; |
| 1460 | SkRect rightRect = { 30, 60, 70, 90 }; |
| 1461 | SkDebugf("%s intersection: ", leftRect.intersect(rightRect) ? "" : "no "); |
| 1462 | SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(), |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1463 | leftRect.right(), leftRect.bottom()); |
| 1464 | #StdOut |
| 1465 | intersection: 30, 60, 50, 80 |
| 1466 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1467 | ## |
| 1468 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1469 | #SeeAlso intersects Intersects join SkIRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1470 | |
| 1471 | ## |
| 1472 | |
| 1473 | # ------------------------------------------------------------------------------ |
| 1474 | |
| 1475 | #Method bool intersect(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) |
| 1476 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1477 | Constructs Rect to intersect from (left, top, right, bottom). Does not sort |
| 1478 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1479 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1480 | Returns true if Rect intersects construction, and sets Rect to intersection. |
| 1481 | Returns false if Rect does not intersect construction, and leaves Rect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1482 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1483 | Returns false if either construction or Rect is empty, leaving Rect unchanged. |
| 1484 | |
| 1485 | #Param left x minimum of constructed Rect ## |
| 1486 | #Param top y minimum of constructed Rect ## |
| 1487 | #Param right x maximum of constructed Rect ## |
| 1488 | #Param bottom y maximum of constructed Rect ## |
| 1489 | |
| 1490 | #Return true if construction and Rect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1491 | |
| 1492 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1493 | #Description |
| 1494 | Two SkDebugf calls are required. If the calls are combined, their arguments |
| 1495 | may not be evaluated in left to right order: the printed intersection may |
| 1496 | be before or after the call to intersect. |
| 1497 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1498 | SkRect leftRect = { 10, 40, 50, 80 }; |
| 1499 | SkDebugf("%s intersection: ", leftRect.intersect(30, 60, 70, 90) ? "" : "no "); |
| 1500 | SkDebugf("%g, %g, %g, %g\n", leftRect.left(), leftRect.top(), |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1501 | leftRect.right(), leftRect.bottom()); |
| 1502 | #StdOut |
| 1503 | intersection: 30, 60, 50, 80 |
| 1504 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1505 | ## |
| 1506 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1507 | #SeeAlso intersects Intersects join SkIRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1508 | |
| 1509 | ## |
| 1510 | |
| 1511 | # ------------------------------------------------------------------------------ |
| 1512 | |
| 1513 | #Method bool SK_WARN_UNUSED_RESULT intersect(const SkRect& a, const SkRect& b) |
| 1514 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1515 | Returns true if a intersects b, and sets Rect to intersection. |
| 1516 | Returns false if a does not intersect b, and leaves Rect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1517 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1518 | Returns false if either a or b is empty, leaving Rect unchanged. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1519 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1520 | #Param a Rect to intersect ## |
| 1521 | #Param b Rect to intersect ## |
| 1522 | |
| 1523 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1524 | |
| 1525 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1526 | SkRect result; |
| 1527 | bool intersected = result.intersect({ 10, 40, 50, 80 }, { 30, 60, 70, 90 }); |
| 1528 | SkDebugf("%s intersection: %g, %g, %g, %g\n", intersected ? "" : "no ", |
| 1529 | result.left(), result.top(), result.right(), result.bottom()); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1530 | #StdOut |
| 1531 | intersection: 30, 60, 50, 80 |
| 1532 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1533 | ## |
| 1534 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1535 | #SeeAlso intersects Intersects join SkIRect::intersect |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1536 | |
| 1537 | ## |
| 1538 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1539 | # ------------------------------------------------------------------------------ |
| 1540 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1541 | #Method bool intersects(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) const |
| 1542 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1543 | Constructs Rect to intersect from (left, top, right, bottom). Does not sort |
| 1544 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1545 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1546 | Returns true if Rect intersects construction. |
| 1547 | Returns false if either construction or Rect is empty, or do not intersect. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1548 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1549 | #Param left x minimum of constructed Rect ## |
| 1550 | #Param top y minimum of constructed Rect ## |
| 1551 | #Param right x maximum of constructed Rect ## |
| 1552 | #Param bottom y maximum of constructed Rect ## |
| 1553 | |
| 1554 | #Return true if construction and Rect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1555 | |
| 1556 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1557 | SkRect rect = { 10, 40, 50, 80 }; |
| 1558 | SkDebugf("%s intersection", rect.intersects(30, 60, 70, 90) ? "" : "no "); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1559 | #StdOut |
| 1560 | intersection |
| 1561 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1562 | ## |
| 1563 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1564 | #SeeAlso intersect Intersects SkIRect::Intersects |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1565 | |
| 1566 | ## |
| 1567 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1568 | # ------------------------------------------------------------------------------ |
| 1569 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1570 | #Method bool intersects(const SkRect& r) const |
| 1571 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1572 | Returns true if Rect intersects r. |
| 1573 | Returns false if either r or Rect is empty, or do not intersect. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1574 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1575 | #Param r Rect to intersect ## |
| 1576 | |
| 1577 | #Return true if r and Rect have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1578 | |
| 1579 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1580 | SkRect rect = { 10, 40, 50, 80 }; |
| 1581 | SkDebugf("%s intersection", rect.intersects({30, 60, 70, 90}) ? "" : "no "); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1582 | #StdOut |
| 1583 | intersection |
| 1584 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1585 | ## |
| 1586 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1587 | #SeeAlso intersect Intersects SkIRect::Intersects |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1588 | |
| 1589 | ## |
| 1590 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1591 | # ------------------------------------------------------------------------------ |
| 1592 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1593 | #Method static bool Intersects(const SkRect& a, const SkRect& b) |
| 1594 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1595 | Returns true if a intersects b. |
| 1596 | Returns false if either a or b is empty, or do not intersect. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1597 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1598 | #Param a Rect to intersect ## |
| 1599 | #Param b Rect to intersect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1600 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1601 | #Return true if a and b have area in common ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1602 | |
| 1603 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1604 | SkDebugf("%s intersection", SkRect::Intersects({10, 40, 50, 80}, {30, 60, 70, 90}) ? "" : "no "); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1605 | #StdOut |
| 1606 | intersection |
| 1607 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1608 | ## |
| 1609 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1610 | #SeeAlso intersect intersects SkIRect::Intersects |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1611 | |
| 1612 | ## |
| 1613 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1614 | #Topic Intersection ## |
| 1615 | |
| 1616 | |
| 1617 | # ------------------------------------------------------------------------------ |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1618 | |
| 1619 | #Method void join(SkScalar left, SkScalar top, SkScalar right, SkScalar bottom) |
| 1620 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1621 | Constructs Rect to intersect from (left, top, right, bottom). Does not sort |
| 1622 | construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1623 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1624 | Sets Rect to the union of itself and the construction. |
| 1625 | |
| 1626 | Has no effect if construction is empty. Otherwise, if Rect is empty, sets |
| 1627 | Rect to construction. |
| 1628 | |
| 1629 | #Param left x minimum of constructed Rect ## |
| 1630 | #Param top y minimum of constructed Rect ## |
| 1631 | #Param right x maximum of constructed Rect ## |
| 1632 | #Param bottom y maximum of constructed Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1633 | |
| 1634 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1635 | SkRect rect = { 10, 20, 15, 25}; |
| 1636 | rect.join(50, 60, 55, 65); |
| 1637 | SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1638 | #StdOut |
| 1639 | join: 10, 20, 55, 65 |
| 1640 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1641 | ## |
| 1642 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1643 | #SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1644 | |
| 1645 | ## |
| 1646 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1647 | # ------------------------------------------------------------------------------ |
| 1648 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1649 | #Method void join(const SkRect& r) |
| 1650 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1651 | Sets Rect to the union of itself and r. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1652 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1653 | Has no effect if r is empty. Otherwise, if Rect is empty, sets |
| 1654 | Rect to r. |
| 1655 | |
| 1656 | #Param r expansion Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1657 | |
| 1658 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1659 | SkRect rect = { 10, 20, 15, 25}; |
| 1660 | rect.join({50, 60, 55, 65}); |
| 1661 | SkDebugf("join: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1662 | #StdOut |
| 1663 | join: 10, 20, 55, 65 |
| 1664 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1665 | ## |
| 1666 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1667 | #SeeAlso joinNonEmptyArg joinPossiblyEmptyRect SkIRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1668 | |
| 1669 | ## |
| 1670 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1671 | # ------------------------------------------------------------------------------ |
| 1672 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1673 | #Method void joinNonEmptyArg(const SkRect& r) |
| 1674 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1675 | Sets Rect to the union of itself and r. |
| 1676 | |
| 1677 | Asserts if r is empty and SK_DEBUG is defined. |
| 1678 | If Rect is empty, sets Rect to r. |
| 1679 | |
| 1680 | May produce incorrect results if r is empty. |
| 1681 | |
| 1682 | #Param r expansion Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1683 | |
| 1684 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1685 | #Description |
| 1686 | Since Rect is not sorted, first result is copy of toJoin. |
| 1687 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1688 | SkRect rect = { 10, 100, 15, 0}; |
| 1689 | SkRect sorted = rect.makeSorted(); |
| 1690 | SkRect toJoin = { 50, 60, 55, 65 }; |
| 1691 | rect.joinNonEmptyArg(toJoin); |
| 1692 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1693 | sorted.joinNonEmptyArg(toJoin); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1694 | SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom); |
| 1695 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1696 | rect: 50, 60, 55, 65 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1697 | sorted: 10, 0, 55, 100 |
| 1698 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1699 | ## |
| 1700 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1701 | #SeeAlso join joinPossiblyEmptyRect SkIRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1702 | |
| 1703 | ## |
| 1704 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1705 | # ------------------------------------------------------------------------------ |
| 1706 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1707 | #Method void joinPossiblyEmptyRect(const SkRect& r) |
| 1708 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1709 | Sets Rect to the union of itself and the construction. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1710 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1711 | May produce incorrect results if Rect or r is empty. |
| 1712 | |
| 1713 | #Param r expansion Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1714 | |
| 1715 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1716 | #Description |
| 1717 | Since Rect is not sorted, first result is not useful. |
| 1718 | ## |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1719 | SkRect rect = { 10, 100, 15, 0}; |
| 1720 | SkRect sorted = rect.makeSorted(); |
| 1721 | SkRect toJoin = { 50, 60, 55, 65 }; |
| 1722 | rect.joinPossiblyEmptyRect(toJoin); |
| 1723 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1724 | sorted.joinPossiblyEmptyRect(toJoin); |
| 1725 | SkDebugf("sorted: %g, %g, %g, %g\n", sorted.fLeft, sorted.fTop, sorted.fRight, sorted.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1726 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1727 | rect: 10, 60, 55, 65 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1728 | sorted: 10, 0, 55, 100 |
| 1729 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1730 | ## |
| 1731 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1732 | #SeeAlso joinNonEmptyArg join SkIRect::join |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1733 | |
| 1734 | ## |
| 1735 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1736 | # ------------------------------------------------------------------------------ |
| 1737 | |
Cary Clark | 884dd7d | 2017-10-11 10:37:52 -0400 | [diff] [blame] | 1738 | #Method bool contains(const SkRect& r) const |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1739 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1740 | Returns true if Rect contains r. |
| 1741 | Returns false if Rect is empty or r is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1742 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1743 | Rect contains r when Rect area completely includes r area. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1744 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1745 | #Param r Rect contained ## |
| 1746 | |
| 1747 | #Return true if all sides of Rect are outside r ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1748 | |
| 1749 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1750 | SkRect rect = { 30, 50, 40, 60 }; |
| 1751 | SkRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 1752 | for (auto contained : tests) { |
| 1753 | SkDebugf("rect: (%g, %g, %g, %g) %s (%g, %g, %g, %g)\n", |
| 1754 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 1755 | rect.contains(contained) ? "contains" : "does not contain", |
| 1756 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 1757 | } |
| 1758 | #StdOut |
| 1759 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 1760 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 1761 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 1762 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1763 | ## |
| 1764 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1765 | #SeeAlso SkIRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1766 | |
| 1767 | ## |
| 1768 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1769 | # ------------------------------------------------------------------------------ |
| 1770 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1771 | #Method bool contains(const SkIRect& r) const |
| 1772 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1773 | Returns true if Rect contains r. |
| 1774 | Returns false if Rect is empty or r is empty. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1775 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1776 | Rect contains r when Rect area completely includes r area. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1777 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1778 | #Param r IRect contained ## |
| 1779 | |
| 1780 | #Return true if all sides of Rect are outside r ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1781 | |
| 1782 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1783 | SkRect rect = { 30, 50, 40, 60 }; |
| 1784 | SkIRect tests[] = { { 30, 50, 31, 51}, { 39, 49, 40, 50}, { 29, 59, 30, 60} }; |
| 1785 | for (auto contained : tests) { |
| 1786 | SkDebugf("rect: (%g, %g, %g, %g) %s (%d, %d, %d, %d)\n", |
| 1787 | rect.left(), rect.top(), rect.right(), rect.bottom(), |
| 1788 | rect.contains(contained) ? "contains" : "does not contain", |
| 1789 | contained.left(), contained.top(), contained.right(), contained.bottom()); |
| 1790 | } |
| 1791 | #StdOut |
| 1792 | rect: (30, 50, 40, 60) contains (30, 50, 31, 51) |
| 1793 | rect: (30, 50, 40, 60) does not contain (39, 49, 40, 50) |
| 1794 | rect: (30, 50, 40, 60) does not contain (29, 59, 30, 60) |
| 1795 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1796 | ## |
| 1797 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1798 | #SeeAlso SkIRect::contains |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1799 | |
| 1800 | ## |
| 1801 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1802 | #Topic Round |
| 1803 | |
| 1804 | # ------------------------------------------------------------------------------ |
| 1805 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1806 | #Method void round(SkIRect* dst) const |
| 1807 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1808 | Sets IRect by adding 0.5 and discarding the fractional portion of Rect |
| 1809 | members, using |
| 1810 | #Formula |
| 1811 | (SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop), |
| 1812 | SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)) |
| 1813 | ## |
| 1814 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1815 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1816 | #Param dst storage for IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1817 | |
| 1818 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1819 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1820 | SkIRect round; |
| 1821 | rect.round(&round); |
| 1822 | SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1823 | #StdOut |
| 1824 | round: 31, 51, 41, 61 |
| 1825 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1826 | ## |
| 1827 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1828 | #SeeAlso roundIn roundOut SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1829 | |
| 1830 | ## |
| 1831 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1832 | # ------------------------------------------------------------------------------ |
| 1833 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1834 | #Method void roundOut(SkIRect* dst) const |
| 1835 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1836 | Sets IRect by discarding the fractional portion of fLeft and fTop; and |
| 1837 | rounding up fRight and FBottom, using |
| 1838 | #Formula |
| 1839 | (SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), |
| 1840 | SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) |
| 1841 | ## |
| 1842 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1843 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1844 | #Param dst storage for IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1845 | |
| 1846 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1847 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1848 | SkIRect round; |
| 1849 | rect.roundOut(&round); |
| 1850 | SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1851 | #StdOut |
| 1852 | round: 30, 50, 41, 61 |
| 1853 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1854 | ## |
| 1855 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1856 | #SeeAlso roundIn round SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1857 | |
| 1858 | ## |
| 1859 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1860 | # ------------------------------------------------------------------------------ |
| 1861 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1862 | #Method void roundOut(SkRect* dst) const |
| 1863 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1864 | Sets Rect by discarding the fractional portion of fLeft and fTop; and |
| 1865 | rounding up fRight and FBottom, using |
| 1866 | #Formula |
| 1867 | (SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), |
| 1868 | SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) |
| 1869 | ## |
| 1870 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1871 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1872 | #Param dst storage for Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1873 | |
| 1874 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1875 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1876 | SkRect round; |
| 1877 | rect.roundOut(&round); |
| 1878 | SkDebugf("round: %g, %g, %g, %g\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1879 | #StdOut |
| 1880 | round: 30, 50, 41, 61 |
| 1881 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1882 | ## |
| 1883 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1884 | #SeeAlso roundIn round SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1885 | |
| 1886 | ## |
| 1887 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1888 | # ------------------------------------------------------------------------------ |
| 1889 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1890 | #Method void roundIn(SkIRect* dst) const |
| 1891 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1892 | Sets Rect by rounding up fLeft and fTop; and |
| 1893 | discarding the fractional portion of fRight and FBottom, using |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1894 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1895 | #Formula |
| 1896 | (SkScalarCeilToInt(fLeft), SkScalarCeilToInt(fTop), |
| 1897 | SkScalarFloorToInt(fRight), SkScalarFloorToInt(fBottom)) |
| 1898 | ## |
| 1899 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1900 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1901 | #Param dst storage for IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1902 | |
| 1903 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1904 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1905 | SkIRect round; |
| 1906 | rect.roundIn(&round); |
| 1907 | SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1908 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1909 | round: 31, 51, 40, 60 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1910 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1911 | ## |
| 1912 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1913 | #SeeAlso roundOut round SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1914 | |
| 1915 | ## |
| 1916 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1917 | # ------------------------------------------------------------------------------ |
| 1918 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1919 | #Method SkIRect round() const |
| 1920 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1921 | Returns IRect by adding 0.5 and discarding the fractional portion of Rect |
| 1922 | members, using |
| 1923 | #Formula |
| 1924 | (SkScalarRoundToInt(fLeft), SkScalarRoundToInt(fTop), |
| 1925 | SkScalarRoundToInt(fRight), SkScalarRoundToInt(fBottom)) |
| 1926 | ## |
| 1927 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1928 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1929 | #Return rounded IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1930 | |
| 1931 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1932 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1933 | SkIRect round = rect.round(); |
| 1934 | SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1935 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1936 | round: 31, 51, 41, 61 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1937 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1938 | ## |
| 1939 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1940 | #SeeAlso roundOut roundIn SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1941 | |
| 1942 | ## |
| 1943 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1944 | # ------------------------------------------------------------------------------ |
| 1945 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1946 | #Method SkIRect roundOut() const |
| 1947 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1948 | Sets IRect by discarding the fractional portion of fLeft and fTop; and |
| 1949 | rounding up fRight and FBottom, using |
| 1950 | #Formula |
| 1951 | (SkScalarFloorToInt(fLeft), SkScalarFloorToInt(fTop), |
| 1952 | SkScalarCeilToInt(fRight), SkScalarCeilToInt(fBottom)) |
| 1953 | ## |
| 1954 | . |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1955 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1956 | #Return rounded IRect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1957 | |
| 1958 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1959 | SkRect rect = { 30.5f, 50.5f, 40.5f, 60.5f }; |
| 1960 | SkIRect round = rect.roundOut(); |
| 1961 | SkDebugf("round: %d, %d, %d, %d\n", round.fLeft, round.fTop, round.fRight, round.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1962 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1963 | round: 30, 50, 41, 61 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1964 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1965 | ## |
| 1966 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1967 | #SeeAlso round roundIn SkScalarRoundToInt |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1968 | |
| 1969 | ## |
| 1970 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1971 | #Topic Round ## |
| 1972 | |
| 1973 | # ------------------------------------------------------------------------------ |
| 1974 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1975 | #Method void sort() |
| 1976 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1977 | Swaps fLeft and fRight if fLeft is greater than fRight; and swaps |
| 1978 | fTop and fBottom if fTop is greater than fBottom. Result may be empty; |
| 1979 | and width() and height() will be zero or positive. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1980 | |
| 1981 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1982 | SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f }; |
| 1983 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 1984 | rect.sort(); |
| 1985 | SkDebugf("sorted: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1986 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 1987 | rect: 30.5, 50.5, 20.5, 10.5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1988 | sorted: 20.5, 10.5, 30.5, 50.5 |
| 1989 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1990 | ## |
| 1991 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1992 | #SeeAlso makeSorted SkIRect::sort |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1993 | |
| 1994 | ## |
| 1995 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 1996 | # ------------------------------------------------------------------------------ |
| 1997 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 1998 | #Method SkRect makeSorted() const |
| 1999 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2000 | Returns Rect with fLeft and fRight swapped if fLeft is greater than fRight; and |
| 2001 | with fTop and fBottom swapped if fTop is greater than fBottom. Result may be empty; |
| 2002 | and width() and height() will be zero or positive. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2003 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2004 | #Return sorted Rect ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2005 | |
| 2006 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2007 | SkRect rect = { 30.5f, 50.5f, 20.5f, 10.5f }; |
| 2008 | SkDebugf("rect: %g, %g, %g, %g\n", rect.fLeft, rect.fTop, rect.fRight, rect.fBottom); |
| 2009 | SkRect sort = rect.makeSorted(); |
| 2010 | SkDebugf("sorted: %g, %g, %g, %g\n", sort.fLeft, sort.fTop, sort.fRight, sort.fBottom); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2011 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2012 | rect: 30.5, 50.5, 20.5, 10.5 |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2013 | sorted: 20.5, 10.5, 30.5, 50.5 |
| 2014 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2015 | ## |
| 2016 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2017 | #SeeAlso sort SkIRect::makeSorted |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2018 | |
| 2019 | ## |
| 2020 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2021 | # ------------------------------------------------------------------------------ |
| 2022 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2023 | #Method const SkScalar* asScalars() const |
| 2024 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2025 | Returns pointer to first Scalar in Rect, to treat it as an array with four |
| 2026 | entries. |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2027 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2028 | #Return pointer to fLeft ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2029 | |
| 2030 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2031 | SkRect rect = {7, 11, 13, 17}; |
| 2032 | SkDebugf("rect.asScalars() %c= &rect.fLeft\n", rect.asScalars() == &rect.fLeft? '=' : '!'); |
| 2033 | #StdOut |
| 2034 | rect.asScalars() == &rect.fLeft |
| 2035 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2036 | ## |
| 2037 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2038 | #SeeAlso toQuad |
| 2039 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2040 | ## |
| 2041 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2042 | # ------------------------------------------------------------------------------ |
| 2043 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2044 | #Method void dump(bool asHex) const |
| 2045 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2046 | Writes text representation of Rect to standard output. Set asHex to true to |
| 2047 | generate exact binary representations of floating point numbers. |
| 2048 | |
| 2049 | #Param asHex true if SkScalar values are written as hexadecimal ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2050 | |
| 2051 | #Example |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2052 | SkRect rect = {20, 30, 40, 50}; |
| 2053 | for (bool dumpAsHex : { false, true } ) { |
| 2054 | rect.dump(dumpAsHex); |
| 2055 | SkDebugf("\n"); |
| 2056 | } |
| 2057 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2058 | SkRect::MakeLTRB(20, 30, 40, 50); |
| 2059 | |
| 2060 | SkRect::MakeLTRB(SkBits2Float(0x41a00000), /* 20.000000 */ |
| 2061 | SkBits2Float(0x41f00000), /* 30.000000 */ |
| 2062 | SkBits2Float(0x42200000), /* 40.000000 */ |
| 2063 | SkBits2Float(0x42480000) /* 50.000000 */); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2064 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2065 | ## |
| 2066 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2067 | #SeeAlso dumpHex |
| 2068 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2069 | ## |
| 2070 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2071 | # ------------------------------------------------------------------------------ |
| 2072 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2073 | #Method void dump() const |
| 2074 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2075 | Writes text representation of Rect to standard output. The representation may be |
| 2076 | directly compiled as C++ code. Floating point values are written |
| 2077 | with limited precision; it may not be possible to reconstruct original Rect |
| 2078 | from output. |
| 2079 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2080 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2081 | SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6}; |
| 2082 | rect.dump(); |
| 2083 | SkRect copy = SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7); |
| 2084 | SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not "); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2085 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2086 | SkRect::MakeLTRB(0.857143f, 0.666667f, 2.6f, 7); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2087 | rect is not equal to copy |
| 2088 | ## |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2089 | ## |
| 2090 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2091 | #SeeAlso dumpHex |
| 2092 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2093 | ## |
| 2094 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2095 | # ------------------------------------------------------------------------------ |
| 2096 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2097 | #Method void dumpHex() const |
| 2098 | |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2099 | Writes text representation of Rect to standard output. The representation may be |
| 2100 | directly compiled as C++ code. Floating point values are written |
| 2101 | in hexadecimal to preserve their exact bit pattern. The output reconstructs the |
| 2102 | original Rect. |
| 2103 | |
| 2104 | Use instead of dump() when submitting |
| 2105 | #A bug reports against Skia # http://bug.skia.org ## |
| 2106 | . |
| 2107 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2108 | #Example |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2109 | SkRect rect = {6.f / 7, 2.f / 3, 26.f / 10, 42.f / 6}; |
| 2110 | rect.dumpHex(); |
| 2111 | SkRect copy = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ |
| 2112 | SkBits2Float(0x3f2aaaab), /* 0.666667 */ |
| 2113 | SkBits2Float(0x40266666), /* 2.600000 */ |
| 2114 | SkBits2Float(0x40e00000) /* 7.000000 */); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2115 | SkDebugf("rect is " "%s" "equal to copy\n", rect == copy ? "" : "not "); |
| 2116 | #StdOut |
Cary Clark | 154beea | 2017-10-26 07:58:48 -0400 | [diff] [blame] | 2117 | SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */ |
| 2118 | SkBits2Float(0x3f2aaaab), /* 0.666667 */ |
| 2119 | SkBits2Float(0x40266666), /* 2.600000 */ |
| 2120 | SkBits2Float(0x40e00000) /* 7.000000 */); |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2121 | rect is equal to copy |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2122 | ## |
Cary Clark | 7fc1d12 | 2017-10-09 14:07:42 -0400 | [diff] [blame] | 2123 | ## |
| 2124 | |
| 2125 | #SeeAlso dump |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2126 | |
| 2127 | ## |
| 2128 | |
Cary Clark | 0c95aab | 2018-01-08 16:20:59 -0500 | [diff] [blame] | 2129 | #Method static SkRect SK_WARN_UNUSED_RESULT MakeLargest() |
| 2130 | |
| 2131 | #Deprecated |
| 2132 | ## |
| 2133 | |
| 2134 | ## |
| 2135 | |
Cary Clark | bc5697d | 2017-10-04 14:31:33 -0400 | [diff] [blame] | 2136 | #Struct SkRect ## |
| 2137 | |
| 2138 | #Topic Rect ## |