skia2/site/user/api/SkIPoint_Reference.md
Cary Clark 2f466242c7 working on image and nightly housekeeping bot
Add more examples and docs for SkImage; still a ways to go.
Fix bit-rotted examples.
Add typedef support.
Add json driver to pick files to work on; remove special-casing.
Fix unordered map traversal that made md output unreliable.

TBR=rmistry@google.com
Docs-Preview: https://skia.org/?cl=80060
Bug: skia:6898
Change-Id: Ib8eb9fdfa5a9db61c8332e657fa2e2f4b96a665f
Reviewed-on: https://skia-review.googlesource.com/80060
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
2017-12-11 21:47:38 +00:00

16 KiB

SkIPoint Reference

IPoint

Struct SkIPoint

SkIPoint holds two 32 bit integer coordinates

Overview

Subtopics

topics description

Operators

description function
SkIPoint operator-() const Reverses sign of IPoint.
SkIPoint operator+(const SkIPoint& a, const SkIVector& b) Returns IPoint offset by IVector.
SkIVector operator-(const SkIPoint& a, const SkIPoint& b) Returns IVector between IPoints.
bool operator!=(const SkIPoint& a, const SkIPoint& b) Returns true if IPoints are unequal.
bool operator==(const SkIPoint& a, const SkIPoint& b) Returns true if IPoints are equal.
void operator+=(const SkIVector& v) Adds IVector to IPoint.
void operator-=(const SkIVector& v) Subtracts IVector from IPoint.

Member Functions

description function
Make Constructs from integer inputs.
equals Returns true if members are equal.
isZero Returns true if both members equal zero.
set Sets to integer input.
x Returns fX.
y Returns fY.

int32_t fX

x-axis value used by IPoint.

int32_t fY

y-axis value used by IPoint.

Make

static constexpr SkIPoint Make(int32_t x, int32_t y)

Sets fX to x, fY to y.

Parameters

x integer x-axis value of constructed IPoint
y integer y-axis value of constructed IPoint

Return Value

IPoint (x, y)

Example

Example Output

pt1 == pt2

See Also

set SkPoint::iset() SkPoint::Make SkIPoint16::Make


x

int32_t x() const

Returns x-axis value of IPoint.

Return Value

fX

Example

Example Output

pt1.fX == pt1.x()

See Also

y SkPoint::x() SkIPoint16::x()


y

int32_t y() const

Returns y-axis value of IPoint.

Return Value

fY

Example

Example Output

pt1.fY == pt1.y()

See Also

x SkPoint::y() SkIPoint16::y()


isZero

bool isZero() const

Returns true if fX and fY are both zero.

Return Value

true if fX is zero and fY is zero

Example

Example Output

pt.isZero() == true

See Also

SkPoint::isZero


set

void set(int32_t x, int32_t y)

Sets fX to x and fY to y.

Parameters

x new value for fX
y new value for fY

Example

Example Output

pt1 == pt2

See Also

Make SkIPoint16::set


operator-

SkIPoint operator-() _const

Returns IPoint changing the signs of fX and fY.

Return Value

IPoint as (-fX, -fY)

Example

Example Output

pt: 0, 0  negate: 0, 0
pt: -1, -2  negate: 1, 2
pt: 2147483647, -2147483647  negate: -2147483647, 2147483647
pt: -2147483648, -2147483648  negate: -2147483648, -2147483648

See Also

operator-(const SkIPoint& a, const SkIPoint& b) operator-=(const SkIVector& v) SkPoint::operator-() const


operator+=

void operator+=(const SkIVector& v)

Offsets IPoint by IVector v. Sets IPoint to(fX + v.fX, fY + v.fY).

Parameters

v IVector to add

Example

See Also

operator+(const SkIPoint& a, const SkIVector& b) SkPoint::operator+=(const SkVector& v)


operator-=

void operator-=(const SkIVector& v)

Subtracts IVector v from IPoint. Sets IPoint to: (fX - v.fX, fY - v.fY).

Parameters

v IVector to subtract

Example

See Also

operator-(const SkIPoint& a, const SkIPoint& b) SkPoint::operator-=(const SkVector& v)


equals

bool equals(int32_t x, int32_t y) const

Returns true if IPoint is equivalent to IPoint constructed from (x, y).

Parameters

x value compared with fX
y value compared with fY

Return Value

true if IPoint equals (x, y)

Example

Example Output

pt: 0, 0  == pt
pt: -1, -2  == pt
pt: 2147483647, -1  == pt
pt: -2147483648, -1  == pt

See Also

operator==(const SkIPoint& a, const SkIPoint& b)


operator==

bool operator==(const SkIPoint& a, const SkIPoint& b)

Returns true if a is equivalent to b.

Parameters

a IPoint to compare
b IPoint to compare

Return Value

true if a.fX == b.fX and a.fY == b.fY

Example

Example Output

pt: 0, 0  == pt
pt: -1, -2  == pt
pt: 2147483647, -1  == pt
pt: -2147483648, -1  == pt

See Also

equals operator!=(const SkIPoint& a, const SkIPoint& b)


operator!=

bool operator!=(const SkIPoint& a, const SkIPoint& b)

Returns true if a is not equivalent to b.

Parameters

a IPoint to compare
b IPoint to compare

Return Value

true if a.fX != b.fX or a.fY != b.fY

Example

Example Output

pt: 0, 0  == pt
pt: -1, -2  == pt
pt: 2147483647, -1  == pt
pt: -2147483648, -1  == pt

See Also

operator==(const SkIPoint& a, const SkIPoint& b) equals


operator-

SkIVector operator-(const SkIPoint& a, const SkIPoint& b)

Returns IVector from b to a; computed as(a.fX - b.fX, a.fY - b.fY).

Can also be used to subtract IVector from IVector, returning IVector.

Parameters

a IPoint or IVector to subtract from
b IVector to subtract

Return Value

IVector from b to a

Example

See Also

operator-=(const SkIVector& v)


operator+

SkIPoint operator+(const SkIPoint& a, const SkIVector& b)

Returns IPoint resulting from IPoint a offset by IVector b, computed as: (a.fX + b.fX, a.fY + b.fY).

Can also be used to offset IPoint b by IVector a, returning IPoint. Can also be used to add IVector to IVector, returning IVector.

Parameters

a IPoint or IVector to add to
b IPoint or IVector to add

Return Value

IPoint equal to a offset by b

Example

See Also

operator+=(const SkIVector& v)


IVector