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