blob: fa55436ecc5fcbd9e2a1b2a3288c81b1558aee71 [file] [log] [blame] [view]
Cary Clarka560c472017-11-27 10:44:06 -05001SkIPoint Reference
2===
3
Cary Clarka560c472017-11-27 10:44:06 -05004# <a name="IPoint"></a> IPoint
5
6# <a name="SkIPoint"></a> Struct SkIPoint
7<a href="#SkIPoint">SkIPoint</a> holds two 32 bit integer coordinates
8
9# <a name="Overview"></a> Overview
10
11## <a name="Subtopics"></a> Subtopics
12
13| topics | description |
14| --- | --- |
15
16## <a name="Operators"></a> Operators
17
18| description | function |
19| --- | --- |
20| <a href="#SkIPoint">SkIPoint</a> <a href="#SkIPoint_minus_operator">operator-() const</a> | Reverses sign of <a href="#IPoint">IPoint</a>. |
21| <a href="#SkIPoint">SkIPoint</a> <a href="#SkIPoint_add_operator">operator+(const SkIPoint& a, const SkIVector& b)</a> | Returns <a href="#IPoint">IPoint</a> offset by <a href="SkIPoint_Reference#IVector">IVector</a>. |
22| <a href="SkIPoint_Reference#SkIVector">SkIVector</a> <a href="#SkIPoint_subtract_operator">operator-(const SkIPoint& a, const SkIPoint& b)</a> | Returns <a href="SkIPoint_Reference#IVector">IVector</a> between <a href="#IPoint">IPoints</a>. |
23| bool <a href="#SkIPoint_notequal_operator">operator!=(const SkIPoint& a, const SkIPoint& b)</a> | Returns true if <a href="#IPoint">IPoints</a> are unequal. |
24| bool <a href="#SkIPoint_equal_operator">operator==(const SkIPoint& a, const SkIPoint& b)</a> | Returns true if <a href="#IPoint">IPoints</a> are equal. |
25| void <a href="#SkIPoint_addto_operator">operator+=(const SkIVector& v)</a> | Adds <a href="SkIPoint_Reference#IVector">IVector</a> to <a href="#IPoint">IPoint</a>. |
26| void <a href="#SkIPoint_subtractfrom_operator">operator-=(const SkIVector& v)</a> | Subtracts <a href="SkIPoint_Reference#IVector">IVector</a> from <a href="#IPoint">IPoint</a>. |
27
28## <a name="Member_Functions"></a> Member Functions
29
30| description | function |
31| --- | --- |
32| <a href="#SkIPoint_Make">Make</a> | Constructs from integer inputs. |
33| <a href="#SkIPoint_equals">equals</a> | Returns true if members are equal. |
34| <a href="#SkIPoint_isZero">isZero</a> | Returns true if both members equal zero. |
35| <a href="#SkIPoint_set">set</a> | Sets to integer input. |
36| <a href="#SkIPoint_x">x</a> | Returns <a href="#SkIPoint_fX">fX</a>. |
37| <a href="#SkIPoint_y">y</a> | Returns <a href="#SkIPoint_fY">fY</a>. |
38
39<a name="SkIPoint_fX"> <code><strong>int32_t fX</strong></code> </a>
40
41<a href="#SkIPoint_x">x</a>-axis value used by <a href="#IPoint">IPoint</a>.
42
43<a name="SkIPoint_fY"> <code><strong>int32_t fY</strong></code> </a>
44
45<a href="#SkIPoint_y">y</a>-axis value used by <a href="#IPoint">IPoint</a>.
46
47<a name="SkIPoint_Make"></a>
48## Make
49
50<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
51static constexpr SkIPoint Make(int32_t x, int32_t y)
52</pre>
53
54Sets <a href="#SkIPoint_fX">fX</a> to <a href="#SkIPoint_x">x</a>, <a href="#SkIPoint_fY">fY</a> to <a href="#SkIPoint_y">y</a>.
55
56### Parameters
57
58<table> <tr> <td><a name="SkIPoint_Make_x"> <code><strong>x </strong></code> </a></td> <td>
59integer <a href="#SkIPoint_x">x</a>-axis value of constructed <a href="#IPoint">IPoint</a></td>
60 </tr> <tr> <td><a name="SkIPoint_Make_y"> <code><strong>y </strong></code> </a></td> <td>
61integer <a href="#SkIPoint_y">y</a>-axis value of constructed <a href="#IPoint">IPoint</a></td>
62 </tr>
63</table>
64
65### Return Value
66
67<a href="#IPoint">IPoint</a> (<a href="#SkIPoint_x">x</a>, <a href="#SkIPoint_y">y</a>)
68
69### Example
70
71<div><fiddle-embed name="e5cf5159525bd3140f288a95fe641fae">
72
73#### Example Output
74
75~~~~
76pt1 == pt2
77~~~~
78
79</fiddle-embed></div>
80
81### See Also
82
83<a href="#SkIPoint_set">set</a> <a href="#SkPoint_iset">SkPoint::iset()</a> <a href="#SkPoint_Make">SkPoint::Make</a> <a href="#SkIPoint16_Make">SkIPoint16::Make</a>
84
85---
86
87<a name="SkIPoint_x"></a>
88## x
89
90<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
91int32_t x() const
92</pre>
93
94Returns <a href="#SkIPoint_x">x</a>-axis value of <a href="#IPoint">IPoint</a>.
95
96### Return Value
97
98<a href="#SkIPoint_fX">fX</a>
99
100### Example
101
102<div><fiddle-embed name="eed4185294f8a8216fc354e6ee6b2e3a">
103
104#### Example Output
105
106~~~~
107pt1.fX == pt1.x()
108~~~~
109
110</fiddle-embed></div>
111
112### See Also
113
114<a href="#SkIPoint_y">y</a> <a href="#SkPoint_x">SkPoint::x()</a> <a href="#SkIPoint16_x">SkIPoint16::x()</a>
115
116---
117
118<a name="SkIPoint_y"></a>
119## y
120
121<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
122int32_t y() const
123</pre>
124
125Returns <a href="#SkIPoint_y">y</a>-axis value of <a href="#IPoint">IPoint</a>.
126
127### Return Value
128
129<a href="#SkIPoint_fY">fY</a>
130
131### Example
132
133<div><fiddle-embed name="35c41b8ba7cebf8c9a7a8494e610e14d">
134
135#### Example Output
136
137~~~~
138pt1.fY == pt1.y()
139~~~~
140
141</fiddle-embed></div>
142
143### See Also
144
145<a href="#SkIPoint_x">x</a> <a href="#SkPoint_y">SkPoint::y()</a> <a href="#SkIPoint16_y">SkIPoint16::y()</a>
146
147---
148
149<a name="SkIPoint_isZero"></a>
150## isZero
151
152<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
153bool isZero() const
154</pre>
155
156Returns true if <a href="#SkIPoint_fX">fX</a> and <a href="#SkIPoint_fY">fY</a> are both zero.
157
158### Return Value
159
160true if <a href="#SkIPoint_fX">fX</a> is zero and <a href="#SkIPoint_fY">fY</a> is zero
161
162### Example
163
164<div><fiddle-embed name="658c1df611b4577cc7e0bb384e95737e">
165
166#### Example Output
167
168~~~~
169pt.isZero() == true
170~~~~
171
172</fiddle-embed></div>
173
174### See Also
175
176<a href="#SkPoint_isZero">SkPoint::isZero</a>
177
178---
179
180<a name="SkIPoint_set"></a>
181## set
182
183<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
184void set(int32_t x, int32_t y)
185</pre>
186
187Sets <a href="#SkIPoint_fX">fX</a> to <a href="#SkIPoint_x">x</a> and <a href="#SkIPoint_fY">fY</a> to <a href="#SkIPoint_y">y</a>.
188
189### Parameters
190
191<table> <tr> <td><a name="SkIPoint_set_x"> <code><strong>x </strong></code> </a></td> <td>
192new value for <a href="#SkIPoint_fX">fX</a></td>
193 </tr> <tr> <td><a name="SkIPoint_set_y"> <code><strong>y </strong></code> </a></td> <td>
194new value for <a href="#SkIPoint_fY">fY</a></td>
195 </tr>
196</table>
197
198### Example
199
200<div><fiddle-embed name="165418b5718d79d8f1682a8a0ee32ba0">
201
202#### Example Output
203
204~~~~
205pt1 == pt2
206~~~~
207
208</fiddle-embed></div>
209
210### See Also
211
212<a href="#SkIPoint_Make">Make</a> <a href="#SkIPoint16_set">SkIPoint16::set</a>
213
214---
215
216<a name="SkIPoint_minus_operator"></a>
217## operator-
218
219<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
220SkIPoint operator-() _const
221</pre>
222
223Returns <a href="#IPoint">IPoint</a> changing the signs of <a href="#SkIPoint_fX">fX</a> and <a href="#SkIPoint_fY">fY</a>.
224
225### Return Value
226
227<a href="#IPoint">IPoint</a> as (-<a href="#SkIPoint_fX">fX</a>, -<a href="#SkIPoint_fY">fY</a>)
228
229### Example
230
231<div><fiddle-embed name="d283e8876366349aedd85b65cadb3706">
232
233#### Example Output
234
235~~~~
236pt: 0, 0 negate: 0, 0
237pt: -1, -2 negate: 1, 2
238pt: 2147483647, -2147483647 negate: -2147483647, 2147483647
239pt: -2147483648, -2147483648 negate: -2147483648, -2147483648
240~~~~
241
242</fiddle-embed></div>
243
244### See Also
245
246<a href="#SkIPoint_subtract_operator">operator-(const SkIPoint& a, const SkIPoint& b)</a> <a href="#SkIPoint_subtractfrom_operator">operator-=(const SkIVector& v)</a> <a href="#SkPoint_minus_operator">SkPoint::operator-() const</a>
247
248---
249
250<a name="SkIPoint_addto_operator"></a>
251## operator+=
252
253<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
254void operator+=(const SkIVector& v)
255</pre>
256
257Offsets <a href="#IPoint">IPoint</a> by <a href="SkIPoint_Reference#IVector">IVector</a> <a href="#SkIPoint_addto_operator_v">v</a>. Sets <a href="#IPoint">IPoint</a> to(<a href="#SkIPoint_fX">fX</a> + <a href="#SkIPoint_addto_operator_v">v</a>.<a href="#SkIPoint_fX">fX</a>, <a href="#SkIPoint_fY">fY</a> + <a href="#SkIPoint_addto_operator_v">v</a>.<a href="#SkIPoint_fY">fY</a>).
258
259### Parameters
260
261<table> <tr> <td><a name="SkIPoint_addto_operator_v"> <code><strong>v </strong></code> </a></td> <td>
262<a href="SkIPoint_Reference#IVector">IVector</a> to add</td>
263 </tr>
264</table>
265
266### Example
267
268<div><fiddle-embed name="4eb2d95c9e9a66f05296e345bb68bd51"></fiddle-embed></div>
269
270### See Also
271
272<a href="#SkIPoint_add_operator">operator+(const SkIPoint& a, const SkIVector& b)</a> <a href="#SkPoint_addto_operator">SkPoint::operator+=(const SkVector& v)</a>
273
274---
275
276<a name="SkIPoint_subtractfrom_operator"></a>
277## operator-=
278
279<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
280void operator-=(const SkIVector& v)
281</pre>
282
283Subtracts <a href="SkIPoint_Reference#IVector">IVector</a> <a href="#SkIPoint_subtractfrom_operator_v">v</a> from <a href="#IPoint">IPoint</a>. Sets <a href="#IPoint">IPoint</a> to:
284(<a href="#SkIPoint_fX">fX</a> - <a href="#SkIPoint_subtractfrom_operator_v">v</a>.<a href="#SkIPoint_fX">fX</a>, <a href="#SkIPoint_fY">fY</a> - <a href="#SkIPoint_subtractfrom_operator_v">v</a>.<a href="#SkIPoint_fY">fY</a>).
285
286### Parameters
287
288<table> <tr> <td><a name="SkIPoint_subtractfrom_operator_v"> <code><strong>v </strong></code> </a></td> <td>
289<a href="SkIPoint_Reference#IVector">IVector</a> to subtract</td>
290 </tr>
291</table>
292
293### Example
294
295<div><fiddle-embed name="a01e533dc7ab34ed728dc4e7a5f1f0ee"></fiddle-embed></div>
296
297### See Also
298
299<a href="#SkIPoint_subtract_operator">operator-(const SkIPoint& a, const SkIPoint& b)</a> <a href="#SkPoint_subtractfrom_operator">SkPoint::operator-=(const SkVector& v)</a>
300
301---
302
303<a name="SkIPoint_equals"></a>
304## equals
305
306<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
307bool equals(int32_t x, int32_t y) const
308</pre>
309
310Returns true if <a href="#IPoint">IPoint</a> is equivalent to <a href="#IPoint">IPoint</a> constructed from (<a href="#SkIPoint_x">x</a>, <a href="#SkIPoint_y">y</a>).
311
312### Parameters
313
314<table> <tr> <td><a name="SkIPoint_equals_x"> <code><strong>x </strong></code> </a></td> <td>
315value compared with <a href="#SkIPoint_fX">fX</a></td>
316 </tr> <tr> <td><a name="SkIPoint_equals_y"> <code><strong>y </strong></code> </a></td> <td>
317value compared with <a href="#SkIPoint_fY">fY</a></td>
318 </tr>
319</table>
320
321### Return Value
322
323true if <a href="#IPoint">IPoint</a> <a href="#SkIPoint_equals">equals</a> (<a href="#SkIPoint_x">x</a>, <a href="#SkIPoint_y">y</a>)
324
325### Example
326
327<div><fiddle-embed name="64f575d36439d5b69aaed14ffeff1cc4">
328
329#### Example Output
330
331~~~~
332pt: 0, 0 == pt
333pt: -1, -2 == pt
334pt: 2147483647, -1 == pt
335pt: -2147483648, -1 == pt
336~~~~
337
338</fiddle-embed></div>
339
340### See Also
341
342<a href="#SkIPoint_equal_operator">operator==(const SkIPoint& a, const SkIPoint& b)</a>
343
344---
345
346<a name="SkIPoint_equal_operator"></a>
347## operator==
348
349<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
350bool operator==(const SkIPoint& a, const SkIPoint& b)
351</pre>
352
353Returns true if <a href="#SkIPoint_equal_operator_a">a</a> is equivalent to <a href="#SkIPoint_equal_operator_b">b</a>.
354
355### Parameters
356
357<table> <tr> <td><a name="SkIPoint_equal_operator_a"> <code><strong>a </strong></code> </a></td> <td>
358<a href="#IPoint">IPoint</a> to compare</td>
359 </tr> <tr> <td><a name="SkIPoint_equal_operator_b"> <code><strong>b </strong></code> </a></td> <td>
360<a href="#IPoint">IPoint</a> to compare</td>
361 </tr>
362</table>
363
364### Return Value
365
366true if <a href="#SkIPoint_equal_operator_a">a</a>.<a href="#SkIPoint_fX">fX</a> == <a href="#SkIPoint_equal_operator_b">b</a>.<a href="#SkIPoint_fX">fX</a> and <a href="#SkIPoint_equal_operator_a">a</a>.<a href="#SkIPoint_fY">fY</a> == <a href="#SkIPoint_equal_operator_b">b</a>.<a href="#SkIPoint_fY">fY</a>
367
368### Example
369
370<div><fiddle-embed name="37ffe2817d720f99e6c252332ce70460">
371
372#### Example Output
373
374~~~~
375pt: 0, 0 == pt
376pt: -1, -2 == pt
377pt: 2147483647, -1 == pt
378pt: -2147483648, -1 == pt
379~~~~
380
381</fiddle-embed></div>
382
383### See Also
384
385<a href="#SkIPoint_equals">equals</a> <a href="#SkIPoint_notequal_operator">operator!=(const SkIPoint& a, const SkIPoint& b)</a>
386
387---
388
389<a name="SkIPoint_notequal_operator"></a>
390## operator!=
391
392<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
393bool operator!=(const SkIPoint& a, const SkIPoint& b)
394</pre>
395
396Returns true if <a href="#SkIPoint_notequal_operator_a">a</a> is not equivalent to <a href="#SkIPoint_notequal_operator_b">b</a>.
397
398### Parameters
399
400<table> <tr> <td><a name="SkIPoint_notequal_operator_a"> <code><strong>a </strong></code> </a></td> <td>
401<a href="#IPoint">IPoint</a> to compare</td>
402 </tr> <tr> <td><a name="SkIPoint_notequal_operator_b"> <code><strong>b </strong></code> </a></td> <td>
403<a href="#IPoint">IPoint</a> to compare</td>
404 </tr>
405</table>
406
407### Return Value
408
409true if <a href="#SkIPoint_notequal_operator_a">a</a>.<a href="#SkIPoint_fX">fX</a> != <a href="#SkIPoint_notequal_operator_b">b</a>.<a href="#SkIPoint_fX">fX</a> or <a href="#SkIPoint_notequal_operator_a">a</a>.<a href="#SkIPoint_fY">fY</a> != <a href="#SkIPoint_notequal_operator_b">b</a>.<a href="#SkIPoint_fY">fY</a>
410
411### Example
412
413<div><fiddle-embed name="dd89dc48dff69b53d99530b120f204bc">
414
415#### Example Output
416
417~~~~
418pt: 0, 0 == pt
419pt: -1, -2 == pt
420pt: 2147483647, -1 == pt
421pt: -2147483648, -1 == pt
422~~~~
423
424</fiddle-embed></div>
425
426### See Also
427
428<a href="#SkIPoint_equal_operator">operator==(const SkIPoint& a, const SkIPoint& b)</a> <a href="#SkIPoint_equals">equals</a>
429
430---
431
432<a name="SkIPoint_subtract_operator"></a>
433## operator-
434
435<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
436SkIVector operator-(const SkIPoint& a, const SkIPoint& b)
437</pre>
438
439Returns <a href="SkIPoint_Reference#IVector">IVector</a> from <a href="#SkIPoint_subtract_operator_b">b</a> to <a href="#SkIPoint_subtract_operator_a">a</a>; computed as(<a href="#SkIPoint_subtract_operator_a">a</a>.<a href="#SkIPoint_fX">fX</a> - <a href="#SkIPoint_subtract_operator_b">b</a>.<a href="#SkIPoint_fX">fX</a>, <a href="#SkIPoint_subtract_operator_a">a</a>.<a href="#SkIPoint_fY">fY</a> - <a href="#SkIPoint_subtract_operator_b">b</a>.<a href="#SkIPoint_fY">fY</a>).
440
441Can also be used to subtract <a href="SkIPoint_Reference#IVector">IVector</a> from <a href="SkIPoint_Reference#IVector">IVector</a>, returning <a href="SkIPoint_Reference#IVector">IVector</a>.
442
443### Parameters
444
445<table> <tr> <td><a name="SkIPoint_subtract_operator_a"> <code><strong>a </strong></code> </a></td> <td>
446<a href="#IPoint">IPoint</a> or <a href="SkIPoint_Reference#IVector">IVector</a> to subtract from</td>
447 </tr> <tr> <td><a name="SkIPoint_subtract_operator_b"> <code><strong>b </strong></code> </a></td> <td>
448<a href="SkIPoint_Reference#IVector">IVector</a> to subtract</td>
449 </tr>
450</table>
451
452### Return Value
453
454<a href="SkIPoint_Reference#IVector">IVector</a> from <a href="#SkIPoint_subtract_operator_b">b</a> to <a href="#SkIPoint_subtract_operator_a">a</a>
455
456### Example
457
458<div><fiddle-embed name="e626e26bf557857b824aa7d03f723e0f"></fiddle-embed></div>
459
460### See Also
461
462<a href="#SkIPoint_subtractfrom_operator">operator-=(const SkIVector& v)</a>
463
464---
465
466<a name="SkIPoint_add_operator"></a>
467## operator+
468
469<pre style="padding: 1em 1em 1em 1em;width: 62.5em; background-color: #f0f0f0">
470SkIPoint operator+(const SkIPoint& a, const SkIVector& b)
471</pre>
472
473Returns <a href="#IPoint">IPoint</a> resulting from <a href="#IPoint">IPoint</a> <a href="#SkIPoint_add_operator_a">a</a> offset by <a href="SkIPoint_Reference#IVector">IVector</a> <a href="#SkIPoint_add_operator_b">b</a>, computed as:
474(<a href="#SkIPoint_add_operator_a">a</a>.<a href="#SkIPoint_fX">fX</a> + <a href="#SkIPoint_add_operator_b">b</a>.<a href="#SkIPoint_fX">fX</a>, <a href="#SkIPoint_add_operator_a">a</a>.<a href="#SkIPoint_fY">fY</a> + <a href="#SkIPoint_add_operator_b">b</a>.<a href="#SkIPoint_fY">fY</a>).
475
476Can also be used to offset <a href="#IPoint">IPoint</a> <a href="#SkIPoint_add_operator_b">b</a> by <a href="SkIPoint_Reference#IVector">IVector</a> <a href="#SkIPoint_add_operator_a">a</a>, returning <a href="#IPoint">IPoint</a>.
477Can also be used to add <a href="SkIPoint_Reference#IVector">IVector</a> to <a href="SkIPoint_Reference#IVector">IVector</a>, returning <a href="SkIPoint_Reference#IVector">IVector</a>.
478
479### Parameters
480
481<table> <tr> <td><a name="SkIPoint_add_operator_a"> <code><strong>a </strong></code> </a></td> <td>
482<a href="#IPoint">IPoint</a> or <a href="SkIPoint_Reference#IVector">IVector</a> to add to</td>
483 </tr> <tr> <td><a name="SkIPoint_add_operator_b"> <code><strong>b </strong></code> </a></td> <td>
484<a href="#IPoint">IPoint</a> or <a href="SkIPoint_Reference#IVector">IVector</a> to add</td>
485 </tr>
486</table>
487
488### Return Value
489
490<a href="#IPoint">IPoint</a> equal to <a href="#SkIPoint_add_operator_a">a</a> offset by <a href="#SkIPoint_add_operator_b">b</a>
491
492### Example
493
494<div><fiddle-embed name="63f4cba971c6d8434595906f865b5a29"></fiddle-embed></div>
495
496### See Also
497
498<a href="#SkIPoint_addto_operator">operator+=(const SkIVector& v)</a>
499
500---
501
Cary Clark2f466242017-12-11 16:03:17 -0500502# <a name="IVector"></a> IVector