Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 1 | #Topic IPoint |
Cary Clark | 137b874 | 2018-05-30 09:21:49 -0400 | [diff] [blame] | 2 | #Alias IPoints ## |
| 3 | #Alias IPoint_Reference ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 4 | |
| 5 | #Struct SkIPoint |
| 6 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 7 | #Code |
| 8 | #Populate |
| 9 | ## |
| 10 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 11 | SkIPoint holds two 32-bit integer coordinates. |
| 12 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 13 | #Member int32_t fX |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 14 | #Line # x-axis value ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 15 | x-axis value used by IPoint. |
| 16 | ## |
| 17 | |
| 18 | #Member int32_t fY |
Cary Clark | 08895c4 | 2018-02-01 09:37:32 -0500 | [diff] [blame] | 19 | #Line # y-axis value ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 20 | y-axis value used by IPoint. |
| 21 | ## |
| 22 | |
| 23 | # ------------------------------------------------------------------------------ |
| 24 | |
| 25 | #Method static constexpr SkIPoint Make(int32_t x, int32_t y) |
| 26 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 27 | #In Constructors |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 28 | #Line # constructs from integer inputs ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 29 | Sets fX to x, fY to y. |
| 30 | |
| 31 | #Param x integer x-axis value of constructed IPoint ## |
| 32 | #Param y integer y-axis value of constructed IPoint ## |
| 33 | |
| 34 | #Return IPoint (x, y) ## |
| 35 | |
| 36 | #Example |
| 37 | SkIPoint pt1 = {45, 66}; |
| 38 | SkIPoint pt2 = SkIPoint::Make(45, 66); |
| 39 | SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!'); |
| 40 | #StdOut |
| 41 | pt1 == pt2 |
| 42 | ## |
| 43 | ## |
| 44 | |
Mike Reed | 1fda024 | 2018-04-04 15:39:46 -0400 | [diff] [blame] | 45 | #SeeAlso set() SkPoint::iset() SkPoint::Make |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 46 | |
| 47 | #Method ## |
| 48 | |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 49 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 50 | # ------------------------------------------------------------------------------ |
| 51 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 52 | #Subtopic Property |
| 53 | #Line # member values ## |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 54 | #Subtopic Property ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 55 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 56 | #Method int32_t x() const |
| 57 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 58 | #Line # returns fX ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 59 | Returns x-axis value of IPoint. |
| 60 | |
| 61 | #Return fX ## |
| 62 | |
| 63 | #Example |
| 64 | SkIPoint pt1 = {45, 66}; |
| 65 | SkDebugf("pt1.fX %c= pt1.x()\n", pt1.fX == pt1.x() ? '=' : '!'); |
| 66 | #StdOut |
| 67 | pt1.fX == pt1.x() |
| 68 | ## |
| 69 | ## |
| 70 | |
Mike Reed | 1fda024 | 2018-04-04 15:39:46 -0400 | [diff] [blame] | 71 | #SeeAlso y() SkPoint::x() |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 72 | |
| 73 | #Method ## |
| 74 | |
| 75 | # ------------------------------------------------------------------------------ |
| 76 | |
| 77 | #Method int32_t y() const |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 78 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 79 | #Line # returns fY ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 80 | Returns y-axis value of IPoint. |
| 81 | |
| 82 | #Return fY ## |
| 83 | |
| 84 | #Example |
| 85 | SkIPoint pt1 = {45, 66}; |
| 86 | SkDebugf("pt1.fY %c= pt1.y()\n", pt1.fY == pt1.y() ? '=' : '!'); |
| 87 | #StdOut |
| 88 | pt1.fY == pt1.y() |
| 89 | ## |
| 90 | ## |
| 91 | |
Mike Reed | 1fda024 | 2018-04-04 15:39:46 -0400 | [diff] [blame] | 92 | #SeeAlso x() SkPoint::y() |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 93 | |
| 94 | #Method ## |
| 95 | |
| 96 | # ------------------------------------------------------------------------------ |
| 97 | |
| 98 | #Method bool isZero() const |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 99 | #In Property |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 100 | #Line # returns true if both members equal zero ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 101 | Returns true if fX and fY are both zero. |
| 102 | |
| 103 | #Return true if fX is zero and fY is zero ## |
| 104 | |
| 105 | #Example |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 106 | SkIPoint pt = { 0, -0}; |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 107 | SkDebugf("pt.isZero() == %s\n", pt.isZero() ? "true" : "false"); |
| 108 | #StdOut |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 109 | pt.isZero() == true |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 110 | ## |
| 111 | ## |
| 112 | |
| 113 | #SeeAlso SkPoint::isZero |
| 114 | |
| 115 | #Method ## |
| 116 | |
| 117 | # ------------------------------------------------------------------------------ |
| 118 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 119 | #Subtopic Set |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 120 | #Line # replaces all values ## |
| 121 | ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 122 | |
Cary Clark | 4855f78 | 2018-02-06 09:41:53 -0500 | [diff] [blame] | 123 | #Method void set(int32_t x, int32_t y) |
| 124 | #In Set |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 125 | #Line # sets to integer input ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 126 | Sets fX to x and fY to y. |
| 127 | |
| 128 | #Param x new value for fX ## |
| 129 | #Param y new value for fY ## |
| 130 | |
| 131 | #Example |
| 132 | SkIPoint pt1, pt2 = { SK_MinS32, SK_MaxS32 }; |
| 133 | pt1.set(SK_MinS32, SK_MaxS32); |
| 134 | SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!'); |
| 135 | #StdOut |
| 136 | pt1 == pt2 |
| 137 | ## |
| 138 | ## |
| 139 | |
Mike Reed | 1fda024 | 2018-04-04 15:39:46 -0400 | [diff] [blame] | 140 | #SeeAlso Make |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 141 | |
| 142 | #Method ## |
| 143 | |
| 144 | # ------------------------------------------------------------------------------ |
| 145 | |
| 146 | #Method SkIPoint operator-()_const |
| 147 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 148 | #Line # reverses sign of IPoint ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 149 | Returns IPoint changing the signs of fX and fY. |
| 150 | |
| 151 | #Return IPoint as (-fX, -fY) ## |
| 152 | |
| 153 | #Example |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 154 | SkIPoint test[] = { {0, -0}, {-1, -2}, |
| 155 | { SK_MaxS32, SK_MinS32 }, |
Cary Clark | 681287e | 2018-03-16 11:34:15 -0400 | [diff] [blame] | 156 | { SK_NaN32, SK_NaN32 } }; |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 157 | for (const SkIPoint& pt : test) { |
| 158 | SkIPoint negPt = -pt; |
| 159 | SkDebugf("pt: %d, %d negate: %d, %d\n", pt.fX, pt.fY, negPt.fX, negPt.fY); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 160 | } |
| 161 | #StdOut |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 162 | pt: 0, 0 negate: 0, 0 |
| 163 | pt: -1, -2 negate: 1, 2 |
| 164 | pt: 2147483647, -2147483647 negate: -2147483647, 2147483647 |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 165 | pt: -2147483648, -2147483648 negate: -2147483648, -2147483648 |
| 166 | ## |
| 167 | ## |
| 168 | |
| 169 | #SeeAlso operator-(const SkIPoint& a, const SkIPoint& b) operator-=(const SkIVector& v) SkPoint::operator-()_const |
| 170 | |
| 171 | #Method ## |
| 172 | |
| 173 | # ------------------------------------------------------------------------------ |
| 174 | |
| 175 | #Method void operator+=(const SkIVector& v) |
| 176 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 177 | #Line # adds IVector to IPoint ## |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 178 | Offsets IPoint by IVector v. Sets IPoint to #Formula # (fX + v.fX, fY + v.fY) ##. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 179 | |
| 180 | #Param v IVector to add ## |
| 181 | |
| 182 | #Example |
| 183 | #Height 64 |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 184 | auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void { |
| 185 | for (size_t i = 0; i < count - 1; ++i) { |
| 186 | SkPoint p0, p1; |
| 187 | p0.iset(pts[i]); |
| 188 | p1.iset(pts[i + 1]); |
| 189 | canvas->drawLine(p0, p1, paint); |
| 190 | } |
| 191 | }; |
| 192 | SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } }; |
| 193 | SkPaint paint; |
| 194 | paint.setAntiAlias(true); |
| 195 | paint.setStyle(SkPaint::kStroke_Style); |
| 196 | canvas->scale(30, 15); |
| 197 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
| 198 | points[1] += {1, 1}; |
| 199 | points[2] += {-1, -1}; |
| 200 | paint.setColor(SK_ColorRED); |
| 201 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 202 | ## |
| 203 | |
| 204 | #SeeAlso operator+(const SkIPoint& a, const SkIVector& b) SkPoint::operator+=(const SkVector& v) |
| 205 | |
| 206 | #Method ## |
| 207 | |
| 208 | # ------------------------------------------------------------------------------ |
| 209 | |
| 210 | #Method void operator-=(const SkIVector& v) |
| 211 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 212 | #Line # subtracts IVector from IPoint ## |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 213 | Subtracts IVector v from IPoint. Sets IPoint to: #Formula # (fX - v.fX, fY - v.fY) ##. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 214 | |
| 215 | #Param v IVector to subtract ## |
| 216 | |
| 217 | #Example |
| 218 | #Height 64 |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 219 | auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void { |
| 220 | for (size_t i = 0; i < count - 1; ++i) { |
| 221 | SkPoint p0, p1; |
| 222 | p0.iset(pts[i]); |
| 223 | p1.iset(pts[i + 1]); |
| 224 | canvas->drawLine(p0, p1, paint); |
| 225 | } |
| 226 | }; |
| 227 | SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } }; |
| 228 | SkPaint paint; |
| 229 | paint.setAntiAlias(true); |
| 230 | paint.setStyle(SkPaint::kStroke_Style); |
| 231 | canvas->scale(30, 15); |
| 232 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
| 233 | points[1] -= {1, 1}; |
| 234 | points[2] -= {-1, -1}; |
| 235 | paint.setColor(SK_ColorRED); |
| 236 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 237 | ## |
| 238 | |
| 239 | #SeeAlso operator-(const SkIPoint& a, const SkIPoint& b) SkPoint::operator-=(const SkVector& v) |
| 240 | |
| 241 | #Method ## |
| 242 | |
| 243 | # ------------------------------------------------------------------------------ |
| 244 | |
| 245 | #Method bool equals(int32_t x, int32_t y) const |
Cary Clark | 61313f3 | 2018-10-08 14:57:48 -0400 | [diff] [blame] | 246 | #In Operators |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 247 | #Line # returns true if members are equal ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 248 | Returns true if IPoint is equivalent to IPoint constructed from (x, y). |
| 249 | |
| 250 | #Param x value compared with fX ## |
| 251 | #Param y value compared with fY ## |
| 252 | |
| 253 | #Return true if IPoint equals (x, y) ## |
| 254 | |
| 255 | #Example |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 256 | SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} }; |
| 257 | for (const SkIPoint& pt : test) { |
| 258 | SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!'); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 259 | } |
| 260 | #StdOut |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 261 | pt: 0, 0 == pt |
| 262 | pt: -1, -2 == pt |
| 263 | pt: 2147483647, -1 == pt |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 264 | pt: -2147483648, -1 == pt |
| 265 | ## |
| 266 | ## |
| 267 | |
| 268 | #SeeAlso operator==(const SkIPoint& a, const SkIPoint& b) |
| 269 | |
| 270 | #Method ## |
| 271 | |
| 272 | # ------------------------------------------------------------------------------ |
| 273 | |
| 274 | #Method bool operator==(const SkIPoint& a, const SkIPoint& b) |
| 275 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 276 | #Line # returns true if IPoints are equal ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 277 | Returns true if a is equivalent to b. |
| 278 | |
| 279 | #Param a IPoint to compare ## |
| 280 | #Param b IPoint to compare ## |
| 281 | |
| 282 | #Return true if a.fX == b.fX and a.fY == b.fY ## |
| 283 | |
| 284 | #Example |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 285 | SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} }; |
| 286 | for (const SkIPoint& pt : test) { |
| 287 | SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!'); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 288 | } |
| 289 | #StdOut |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 290 | pt: 0, 0 == pt |
| 291 | pt: -1, -2 == pt |
| 292 | pt: 2147483647, -1 == pt |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 293 | pt: -2147483648, -1 == pt |
| 294 | ## |
| 295 | ## |
| 296 | |
| 297 | #SeeAlso equals() operator!=(const SkIPoint& a, const SkIPoint& b) |
| 298 | |
| 299 | #Method ## |
| 300 | |
| 301 | # ------------------------------------------------------------------------------ |
| 302 | |
| 303 | #Method bool operator!=(const SkIPoint& a, const SkIPoint& b) |
| 304 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 305 | #Line # returns true if IPoints are unequal ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 306 | Returns true if a is not equivalent to b. |
| 307 | |
| 308 | #Param a IPoint to compare ## |
| 309 | #Param b IPoint to compare ## |
| 310 | |
| 311 | #Return true if a.fX != b.fX or a.fY != b.fY ## |
| 312 | |
| 313 | #Example |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 314 | SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} }; |
| 315 | for (const SkIPoint& pt : test) { |
| 316 | SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '='); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 317 | } |
| 318 | #StdOut |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 319 | pt: 0, 0 == pt |
| 320 | pt: -1, -2 == pt |
| 321 | pt: 2147483647, -1 == pt |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 322 | pt: -2147483648, -1 == pt |
| 323 | ## |
| 324 | ## |
| 325 | |
| 326 | #SeeAlso operator==(const SkIPoint& a, const SkIPoint& b) equals() |
| 327 | |
| 328 | #Method ## |
| 329 | |
| 330 | # ------------------------------------------------------------------------------ |
| 331 | |
| 332 | #Method SkIVector operator-(const SkIPoint& a, const SkIPoint& b) |
| 333 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 334 | #Line # returns IVector between IPoints ## |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 335 | Returns IVector from b to a; computed as #Formula # (a.fX - b.fX, a.fY - b.fY) ##. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 336 | |
| 337 | Can also be used to subtract IVector from IVector, returning IVector. |
| 338 | |
| 339 | #Param a IPoint or IVector to subtract from ## |
| 340 | #Param b IVector to subtract ## |
| 341 | |
| 342 | #Return IVector from b to a ## |
| 343 | |
| 344 | #Example |
| 345 | #Height 64 |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 346 | auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void { |
| 347 | for (size_t i = 0; i < count - 1; ++i) { |
| 348 | SkPoint p0, p1; |
| 349 | p0.iset(pts[i]); |
| 350 | p1.iset(pts[i + 1]); |
| 351 | canvas->drawLine(p0, p1, paint); |
| 352 | } |
| 353 | }; |
| 354 | SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } }; |
| 355 | SkPaint paint; |
| 356 | paint.setAntiAlias(true); |
| 357 | paint.setStyle(SkPaint::kStroke_Style); |
| 358 | canvas->scale(30, 15); |
| 359 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
| 360 | points[1] += points[0] - points[3]; |
| 361 | points[2] -= points[1] - points[0]; |
| 362 | paint.setColor(SK_ColorRED); |
| 363 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 364 | ## |
| 365 | |
| 366 | #SeeAlso operator-=(const SkIVector& v) |
| 367 | |
| 368 | #Method ## |
| 369 | |
| 370 | # ------------------------------------------------------------------------------ |
| 371 | |
| 372 | #Method SkIPoint operator+(const SkIPoint& a, const SkIVector& b) |
| 373 | |
Cary Clark | ab2621d | 2018-01-30 10:08:57 -0500 | [diff] [blame] | 374 | #Line # returns IPoint offset by IVector ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 375 | Returns IPoint resulting from IPoint a offset by IVector b, computed as: |
Cary Clark | 2be81cf | 2018-09-13 12:04:30 -0400 | [diff] [blame] | 376 | #Formula # (a.fX + b.fX, a.fY + b.fY) ##. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 377 | |
| 378 | Can also be used to offset IPoint b by IVector a, returning IPoint. |
| 379 | Can also be used to add IVector to IVector, returning IVector. |
| 380 | |
| 381 | #Param a IPoint or IVector to add to ## |
| 382 | #Param b IPoint or IVector to add ## |
| 383 | |
| 384 | #Return IPoint equal to a offset by b ## |
| 385 | |
| 386 | #Example |
| 387 | #Height 128 |
Cary Clark | 0c5f546 | 2017-12-15 11:21:51 -0500 | [diff] [blame] | 388 | auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void { |
| 389 | for (size_t i = 0; i < count - 1; ++i) { |
| 390 | SkPoint p0, p1; |
| 391 | p0.iset(pts[i]); |
| 392 | p1.iset(pts[i + 1]); |
| 393 | canvas->drawLine(p0, p1, paint); |
| 394 | } |
| 395 | }; |
| 396 | SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } }; |
| 397 | SkPaint paint; |
| 398 | paint.setAntiAlias(true); |
| 399 | paint.setStyle(SkPaint::kStroke_Style); |
| 400 | canvas->scale(30, 15); |
| 401 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
| 402 | SkIPoint mod = {4, 1}; |
| 403 | for (auto& point : points) { |
| 404 | point = point + mod; |
| 405 | mod.fX -= 1; |
| 406 | mod.fY += 1; |
| 407 | } |
| 408 | paint.setColor(SK_ColorRED); |
| 409 | draw_lines(points, SK_ARRAY_COUNT(points), paint); |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 410 | ## |
| 411 | |
| 412 | #SeeAlso operator+=(const SkIVector& v) |
| 413 | |
| 414 | #Method ## |
| 415 | |
| 416 | #Struct SkIPoint ## |
| 417 | |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 418 | |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 419 | #Subtopic IVector |
| 420 | #Line # alias for IPoint ## |
Cary Clark | 137b874 | 2018-05-30 09:21:49 -0400 | [diff] [blame] | 421 | #Alias IVector ## |
| 422 | #Alias IVectors ## |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 423 | #Typedef SkIPoint SkIVector |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 424 | #Line # alias for IPoint ## |
| 425 | #Code |
| 426 | typedef SkIPoint SkIVector; |
| 427 | ## |
| 428 | SkIVector provides an alternative name for SkIPoint. SkIVector and SkIPoint |
Cary Clark | 137b874 | 2018-05-30 09:21:49 -0400 | [diff] [blame] | 429 | can be used interchangeably for all purposes. |
Cary Clark | a560c47 | 2017-11-27 10:44:06 -0500 | [diff] [blame] | 430 | #Typedef ## |
| 431 | ## |
Cary Clark | 682c58d | 2018-05-16 07:07:07 -0400 | [diff] [blame] | 432 | |
| 433 | #Topic IPoint ## |
| 434 | |