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