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