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