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