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