skia2/docs/SkIPoint_Reference.bmh
Cary Clark 5081eede67 self check and corrections
Add self-checking code that looks to see that overview is populated
and alphabetized. Eventually, this will self-check to see if
methods are collected into subtopics and have reciprocal 'see also'
data.

Standardize phrases so that they don't start with a capital or end
with a period.

Self-check is a work in progress, so it is not yet run by the
bookmaker bots. The self-check should run cleanly, however. To run
it:

./out/skia/bookmaker -b docs -k

The expected output is doc stats. Self-check errors such as missing
methods in the overview would be reported here if there are any.

TBR=caryclark@google.com
Docs-Preview: https://skia.org/?cl=93621
Bug: skia:6898
Change-Id: I8f1f817a7b083b13138ee33d1aa090445e9304c6
Reviewed-on: https://skia-review.googlesource.com/93621
Reviewed-by: Cary Clark <caryclark@skia.org>
Commit-Queue: Cary Clark <caryclark@skia.org>
2018-01-22 14:04:18 +00:00

465 lines
12 KiB
Plaintext

#Topic IPoint
#Alias IPoints
#Alias IPoint_Reference
#Struct SkIPoint
SkIPoint holds two 32 bit integer coordinates.
#Topic Overview
#Subtopic Subtopics
#ToDo manually add subtopics ##
#Table
#Legend
# name # description ##
#Legend ##
# Constructors # functions that construct SkIPoint16 ##
# Member_Functions # static functions and member methods ##
# Operators # operator overloading methods ##
#Table ##
#Subtopic ##
#Subtopic Constructors
#Table
#Legend
# name # description ##
#Legend ##
# Make # constructs from integer inputs ##
#Table ##
#Subtopic ##
#Subtopic Operators
#Table
#Legend
# name # description ##
#Legend ##
# SkIPoint operator+(const SkIPoint& a, const SkIVector& b) # returns IPoint offset by IVector ##
# SkIPoint operator-()_const # reverses sign of IPoint ##
# 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 ##
#Table ##
#Subtopic ##
#Subtopic Member_Functions
#Table
#Legend
# name # description ##
#Legend ##
# 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 ##
#Table ##
#Subtopic ##
#Topic Overview ##
#Member int32_t fX
x-axis value used by IPoint.
##
#Member int32_t fY
y-axis value used by IPoint.
##
# ------------------------------------------------------------------------------
#Method static constexpr SkIPoint Make(int32_t x, int32_t y)
Sets fX to x, fY to y.
#Param x integer x-axis value of constructed IPoint ##
#Param y integer y-axis value of constructed IPoint ##
#Return IPoint (x, y) ##
#Example
SkIPoint pt1 = {45, 66};
SkIPoint pt2 = SkIPoint::Make(45, 66);
SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!');
#StdOut
pt1 == pt2
##
##
#SeeAlso set() SkPoint::iset() SkPoint::Make SkIPoint16::Make
#Method ##
# ------------------------------------------------------------------------------
#Method int32_t x() const
Returns x-axis value of IPoint.
#Return fX ##
#Example
SkIPoint pt1 = {45, 66};
SkDebugf("pt1.fX %c= pt1.x()\n", pt1.fX == pt1.x() ? '=' : '!');
#StdOut
pt1.fX == pt1.x()
##
##
#SeeAlso y() SkPoint::x() SkIPoint16::x()
#Method ##
# ------------------------------------------------------------------------------
#Method int32_t y() const
Returns y-axis value of IPoint.
#Return fY ##
#Example
SkIPoint pt1 = {45, 66};
SkDebugf("pt1.fY %c= pt1.y()\n", pt1.fY == pt1.y() ? '=' : '!');
#StdOut
pt1.fY == pt1.y()
##
##
#SeeAlso x() SkPoint::y() SkIPoint16::y()
#Method ##
# ------------------------------------------------------------------------------
#Method bool isZero() const
Returns true if fX and fY are both zero.
#Return true if fX is zero and fY is zero ##
#Example
SkIPoint pt = { 0, -0};
SkDebugf("pt.isZero() == %s\n", pt.isZero() ? "true" : "false");
#StdOut
pt.isZero() == true
##
##
#SeeAlso SkPoint::isZero
#Method ##
# ------------------------------------------------------------------------------
#Method void set(int32_t x, int32_t y)
Sets fX to x and fY to y.
#Param x new value for fX ##
#Param y new value for fY ##
#Example
SkIPoint pt1, pt2 = { SK_MinS32, SK_MaxS32 };
pt1.set(SK_MinS32, SK_MaxS32);
SkDebugf("pt1 %c= pt2\n", pt1 == pt2 ? '=' : '!');
#StdOut
pt1 == pt2
##
##
#SeeAlso Make SkIPoint16::set
#Method ##
# ------------------------------------------------------------------------------
#Method SkIPoint operator-()_const
Returns IPoint changing the signs of fX and fY.
#Return IPoint as (-fX, -fY) ##
#Example
SkIPoint test[] = { {0, -0}, {-1, -2},
{ SK_MaxS32, SK_MinS32 },
{ SK_NaN32, -SK_NaN32 } };
for (const SkIPoint& pt : test) {
SkIPoint negPt = -pt;
SkDebugf("pt: %d, %d negate: %d, %d\n", pt.fX, pt.fY, negPt.fX, negPt.fY);
}
#StdOut
pt: 0, 0 negate: 0, 0
pt: -1, -2 negate: 1, 2
pt: 2147483647, -2147483647 negate: -2147483647, 2147483647
pt: -2147483648, -2147483648 negate: -2147483648, -2147483648
##
##
#SeeAlso operator-(const SkIPoint& a, const SkIPoint& b) operator-=(const SkIVector& v) SkPoint::operator-()_const
#Method ##
# ------------------------------------------------------------------------------
#Method void operator+=(const SkIVector& v)
Offsets IPoint by IVector v. Sets IPoint to
#Formula
(fX + v.fX, fY + v.fY)
##
.
#Param v IVector to add ##
#Example
#Height 64
auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
for (size_t i = 0; i < count - 1; ++i) {
SkPoint p0, p1;
p0.iset(pts[i]);
p1.iset(pts[i + 1]);
canvas->drawLine(p0, p1, paint);
}
};
SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
points[1] += {1, 1};
points[2] += {-1, -1};
paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator+(const SkIPoint& a, const SkIVector& b) SkPoint::operator+=(const SkVector& v)
#Method ##
# ------------------------------------------------------------------------------
#Method void operator-=(const SkIVector& v)
Subtracts IVector v from IPoint. Sets IPoint to:
#Formula
(fX - v.fX, fY - v.fY)
##
.
#Param v IVector to subtract ##
#Example
#Height 64
auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
for (size_t i = 0; i < count - 1; ++i) {
SkPoint p0, p1;
p0.iset(pts[i]);
p1.iset(pts[i + 1]);
canvas->drawLine(p0, p1, paint);
}
};
SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
points[1] -= {1, 1};
points[2] -= {-1, -1};
paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator-(const SkIPoint& a, const SkIPoint& b) SkPoint::operator-=(const SkVector& v)
#Method ##
# ------------------------------------------------------------------------------
#Method bool equals(int32_t x, int32_t y) const
Returns true if IPoint is equivalent to IPoint constructed from (x, y).
#Param x value compared with fX ##
#Param y value compared with fY ##
#Return true if IPoint equals (x, y) ##
#Example
SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
for (const SkIPoint& pt : test) {
SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt.equals(pt.fX, pt.fY) ? '=' : '!');
}
#StdOut
pt: 0, 0 == pt
pt: -1, -2 == pt
pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
#SeeAlso operator==(const SkIPoint& a, const SkIPoint& b)
#Method ##
# ------------------------------------------------------------------------------
#Method bool operator==(const SkIPoint& a, const SkIPoint& b)
Returns true if a is equivalent to b.
#Param a IPoint to compare ##
#Param b IPoint to compare ##
#Return true if a.fX == b.fX and a.fY == b.fY ##
#Example
SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
for (const SkIPoint& pt : test) {
SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt == pt ? '=' : '!');
}
#StdOut
pt: 0, 0 == pt
pt: -1, -2 == pt
pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
#SeeAlso equals() operator!=(const SkIPoint& a, const SkIPoint& b)
#Method ##
# ------------------------------------------------------------------------------
#Method bool operator!=(const SkIPoint& a, const SkIPoint& b)
Returns true if a is not equivalent to b.
#Param a IPoint to compare ##
#Param b IPoint to compare ##
#Return true if a.fX != b.fX or a.fY != b.fY ##
#Example
SkIPoint test[] = { {0, -0}, {-1, -2}, {SK_MaxS32, -1}, {SK_NaN32, -1} };
for (const SkIPoint& pt : test) {
SkDebugf("pt: %d, %d %c= pt\n", pt.fX, pt.fY, pt != pt ? '!' : '=');
}
#StdOut
pt: 0, 0 == pt
pt: -1, -2 == pt
pt: 2147483647, -1 == pt
pt: -2147483648, -1 == pt
##
##
#SeeAlso operator==(const SkIPoint& a, const SkIPoint& b) equals()
#Method ##
# ------------------------------------------------------------------------------
#Method SkIVector operator-(const SkIPoint& a, const SkIPoint& b)
Returns IVector from b to a; computed as
#Formula
(a.fX - b.fX, a.fY - b.fY)
##
.
Can also be used to subtract IVector from IVector, returning IVector.
#Param a IPoint or IVector to subtract from ##
#Param b IVector to subtract ##
#Return IVector from b to a ##
#Example
#Height 64
auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
for (size_t i = 0; i < count - 1; ++i) {
SkPoint p0, p1;
p0.iset(pts[i]);
p1.iset(pts[i + 1]);
canvas->drawLine(p0, p1, paint);
}
};
SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
points[1] += points[0] - points[3];
points[2] -= points[1] - points[0];
paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator-=(const SkIVector& v)
#Method ##
# ------------------------------------------------------------------------------
#Method SkIPoint operator+(const SkIPoint& a, const SkIVector& b)
Returns IPoint resulting from IPoint a offset by IVector b, computed as:
#Formula
(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.
#Param a IPoint or IVector to add to ##
#Param b IPoint or IVector to add ##
#Return IPoint equal to a offset by b ##
#Example
#Height 128
auto draw_lines = [=](const SkIPoint pts[], size_t count, SkPaint& paint) -> void {
for (size_t i = 0; i < count - 1; ++i) {
SkPoint p0, p1;
p0.iset(pts[i]);
p1.iset(pts[i + 1]);
canvas->drawLine(p0, p1, paint);
}
};
SkIPoint points[] = { { 3, 1 }, { 4, 2 }, { 5, 1 }, { 7, 3 } };
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kStroke_Style);
canvas->scale(30, 15);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
SkIPoint mod = {4, 1};
for (auto& point : points) {
point = point + mod;
mod.fX -= 1;
mod.fY += 1;
}
paint.setColor(SK_ColorRED);
draw_lines(points, SK_ARRAY_COUNT(points), paint);
##
#SeeAlso operator+=(const SkIVector& v)
#Method ##
#Struct SkIPoint ##
#Topic IPoint ##
#Topic IVector
#Alias IVectors
#Typedef SkIPoint SkIVector
#Typedef ##
##