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