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