skia2/site/user/api/SkIPoint_Reference.md
Hal Canary 2f0ca4dbf0 Docs: Update docs to point at named fiddles
for x in docs/examples/* ; do
      if grep -q '// Disabled' $x; then
        continue
      fi
      HASH=$(sed -n 's#^// HASH=\(.*\)$#\1#p' $x)
      NAME=$(sed -n 's#^REG_FIDDLE(\([^,]*\),.*$#\1#p' $x)
      FILES="$(grep -l $HASH site/user/api/*.md)"
      if [ "$FILES" ] ; then
        echo $HASH $NAME $FILES;
        sed -i "s/$HASH/@$NAME/g" $FILES
      fi
    done

https://skia.org/user/api/SkAutoCanvasRestore_Reference?cl=248158
https://skia.org/user/api/SkBitmap_Reference?cl=248158
https://skia.org/user/api/SkBlendMode_Reference?cl=248158
https://skia.org/user/api/SkCanvas_Reference?cl=248158
https://skia.org/user/api/SkColor4f_Reference?cl=248158
https://skia.org/user/api/SkColor_Reference?cl=248158
https://skia.org/user/api/SkFont_Reference?cl=248158
https://skia.org/user/api/SkIPoint_Reference?cl=248158
https://skia.org/user/api/SkIRect_Reference?cl=248158
https://skia.org/user/api/SkImageInfo_Reference?cl=248158
https://skia.org/user/api/SkImage_Reference?cl=248158
https://skia.org/user/api/SkMatrix_Reference?cl=248158
https://skia.org/user/api/SkPaint_Reference?cl=248158
https://skia.org/user/api/SkPath_Reference?cl=248158
https://skia.org/user/api/SkPicture_Reference?cl=248158
https://skia.org/user/api/SkPixmap_Reference?cl=248158
https://skia.org/user/api/SkPoint_Reference?cl=248158
https://skia.org/user/api/SkRRect_Reference?cl=248158
https://skia.org/user/api/SkRect_Reference?cl=248158
https://skia.org/user/api/SkRegion_Reference?cl=248158
https://skia.org/user/api/SkSurface_Reference?cl=248158
https://skia.org/user/api/SkTextBlobBuilder_Reference?cl=248158
https://skia.org/user/api/SkTextBlob_Reference?cl=248158

No-Try: true
Change-Id: I29ff57f3c1dd9f27f67be5511c942e7108908642
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/248158
Auto-Submit: Hal Canary <halcanary@google.com>
Commit-Queue: Ben Wagner aka dogben <benjaminwagner@google.com>
Reviewed-by: Ben Wagner aka dogben <benjaminwagner@google.com>
2019-10-11 16:57:05 +00:00

19 KiB

SkIPoint Reference


struct SkIPoint {

    int32_t fX;
    int32_t fY;

    static constexpr SkIPoint Make(int32_t x, int32_t y);
    int32_t x() const;
    int32_t y() const;
    bool isZero() const;
    void set(int32_t x, int32_t y);
    SkIPoint operator-() const;
    void operator+=(const SkIVector& v);
    void operator-=(const SkIVector& v);
    bool equals(int32_t x, int32_t y) const;
    friend bool operator==(const SkIPoint& a, const SkIPoint& b);
    friend bool operator!=(const SkIPoint& a, const SkIPoint& b);
    friend SkIVector operator-(const SkIPoint& a, const SkIPoint& b);
    friend SkIPoint operator+(const SkIPoint& a, const SkIVector& b);
};

SkIPoint holds two 32-bit integer coordinates.

Type Member Description
int32_t fX x-axis value used by IPoint.
int32_t fY y-axis value used by IPoint.


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 SkIPoint
y integer y-axis value of constructed SkIPoint

Return Value

SkIPoint (x, y)

Example

Example Output

pt1 == pt2

See Also

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


int32_t x()const

Returns x-axis value of SkIPoint.

Return Value

fX

Example

Example Output

pt1.fX == pt1.x()

See Also

y() SkPoint::x()


int32_t y()const

Returns y-axis value of SkIPoint.

Return Value

fY

Example

Example Output

pt1.fY == pt1.y()

See Also

x() SkPoint::y()


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


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


SkIPoint operator-()const

Returns SkIPoint changing the signs of fX and fY.

Return Value

SkIPoint 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


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)


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)


bool equals(int32_t x, int32_t y)const

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

Parameters

x value compared with fX
y value compared with fY

Return Value

true if SkIPoint 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)


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

Returns true if a is equivalent to b.

Parameters

a SkIPoint to compare
b SkIPoint 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)


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

Returns true if a is not equivalent to b.

Parameters

a SkIPoint to compare
b SkIPoint 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()


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)


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)


    typedef SkIPoint SkIVector;

SkIVector provides an alternative name for SkIPoint. SkIVector and SkIPoint can be used interchangeably for all purposes.