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