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