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