2018-06-27 15:00:21 +00:00
|
|
|
#Topic RRect
|
|
|
|
#Alias Round_Rect ##
|
|
|
|
#Alias RRect_Reference ##
|
|
|
|
|
|
|
|
#Class SkRRect
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Code
|
|
|
|
class SkRRect {
|
|
|
|
public:
|
|
|
|
SkRRect() = default;
|
|
|
|
SkRRect(const SkRRect& rrect) = default;
|
|
|
|
SkRRect& operator=(const SkRRect& rrect) = default;
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
kEmpty_Type,
|
|
|
|
kRect_Type,
|
|
|
|
kOval_Type,
|
|
|
|
kSimple_Type,
|
|
|
|
kNinePatch_Type,
|
|
|
|
kComplex_Type,
|
|
|
|
kLastType = kComplex_Type,
|
|
|
|
};
|
|
|
|
|
|
|
|
Type getType() const;
|
|
|
|
Type type() const;
|
|
|
|
bool isEmpty() const;
|
|
|
|
bool isRect() const;
|
|
|
|
bool isOval() const;
|
|
|
|
bool isSimple() const;
|
|
|
|
bool isNinePatch() const;
|
|
|
|
bool isComplex() const;
|
|
|
|
SkScalar width() const;
|
|
|
|
SkScalar height() const;
|
|
|
|
SkVector getSimpleRadii() const;
|
|
|
|
void setEmpty();
|
|
|
|
void setRect(const SkRect& rect);
|
|
|
|
static SkRRect MakeEmpty();
|
|
|
|
static SkRRect MakeRect(const SkRect& r);
|
|
|
|
static SkRRect MakeOval(const SkRect& oval);
|
|
|
|
static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
|
|
|
|
void setOval(const SkRect& oval);
|
|
|
|
void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
|
|
|
|
void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
|
|
|
|
SkScalar rightRad, SkScalar bottomRad);
|
|
|
|
void setRectRadii(const SkRect& rect, const SkVector radii[4]);
|
|
|
|
|
|
|
|
enum Corner {
|
|
|
|
kUpperLeft_Corner,
|
|
|
|
kUpperRight_Corner,
|
|
|
|
kLowerRight_Corner,
|
|
|
|
kLowerLeft_Corner,
|
|
|
|
};
|
|
|
|
|
|
|
|
const SkRect& rect() const;
|
|
|
|
SkVector radii(Corner corner) const;
|
|
|
|
const SkRect& getBounds() const;
|
|
|
|
friend bool operator==(const SkRRect& a, const SkRRect& b);
|
|
|
|
friend bool operator!=(const SkRRect& a, const SkRRect& b);
|
|
|
|
void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const;
|
|
|
|
void inset(SkScalar dx, SkScalar dy);
|
|
|
|
void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const;
|
|
|
|
void outset(SkScalar dx, SkScalar dy);
|
|
|
|
void offset(SkScalar dx, SkScalar dy);
|
|
|
|
SkRRect makeOffset(SkScalar dx, SkScalar dy) const;
|
|
|
|
bool contains(const SkRect& rect) const;
|
|
|
|
bool isValid() const;
|
|
|
|
|
|
|
|
static constexpr size_t kSizeInMemory = 12 * sizeof(SkScalar);
|
|
|
|
|
|
|
|
size_t writeToMemory(void* buffer) const;
|
|
|
|
size_t readFromMemory(const void* buffer, size_t length);
|
|
|
|
bool transform(const SkMatrix& matrix, SkRRect* dst) const;
|
|
|
|
void dump(bool asHex) const;
|
|
|
|
void dump() const;
|
|
|
|
void dumpHex() const;
|
|
|
|
};
|
|
|
|
##
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner.
|
2018-07-17 12:20:27 +00:00
|
|
|
The bounds and radii can be set so that SkRRect describes: a rectangle with sharp corners;
|
|
|
|
a Circle; an Oval; or a rectangle with one or more rounded corners.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
SkRRect allows implementing CSS properties that describe rounded corners.
|
|
|
|
SkRRect may have up to eight different radii, one for each axis on each of its four
|
2018-06-27 15:00:21 +00:00
|
|
|
corners.
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
SkRRect may modify the provided parameters when initializing bounds and radii.
|
2018-07-17 12:20:27 +00:00
|
|
|
If either axis radii is zero or less: radii are stored as zero; corner is square.
|
2018-07-11 20:18:41 +00:00
|
|
|
If corner curves overlap, radii are proportionally reduced to fit within bounds.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Method SkRRect()
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # creates with zeroed bounds and corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 60
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect;
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
canvas->drawRRect(rrect, p);
|
|
|
|
rrect.setRect({10, 10, 100, 50});
|
|
|
|
canvas->drawRRect(rrect, p);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setEmpty isEmpty
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Method SkRRect(const SkRRect& rrect)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # copies bounds and corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-28 12:50:35 +00:00
|
|
|
|
2018-06-27 15:00:21 +00:00
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 60
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
|
|
|
SkRRect rrect2(rrect);
|
|
|
|
rrect2.inset(20, 20);
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
canvas->drawRRect(rrect, p);
|
|
|
|
canvas->drawRRect(rrect2, p);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso operator=(const SkRRect& rrect) MakeRect
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Method SkRRect& operator=(const SkRRect& rrect)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Operators
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # copies bounds and corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({40, 40, 100, 70});
|
|
|
|
SkRRect rrect2 = rrect;
|
|
|
|
rrect2.inset(-20, -20);
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
canvas->drawRRect(rrect, p);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect2, p);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso SkRRect(const SkRRect& rrect) MakeRect
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
2018-06-28 12:50:35 +00:00
|
|
|
#Subtopic Type
|
|
|
|
#Line # specialization of Round_Rect geometry ##
|
|
|
|
|
|
|
|
#PhraseDef list_of_rrect_types
|
|
|
|
kEmpty_Type, kRect_Type, kOval_Type, kSimple_Type, kNinePatch_Type,
|
|
|
|
kComplex_Type
|
|
|
|
##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Enum Type
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # specialization of Round_Rect geometry ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Code
|
|
|
|
enum Type {
|
|
|
|
kEmpty_Type,
|
|
|
|
kRect_Type,
|
|
|
|
kOval_Type,
|
|
|
|
kSimple_Type,
|
|
|
|
kNinePatch_Type,
|
|
|
|
kComplex_Type,
|
|
|
|
kLastType = kComplex_Type,
|
|
|
|
};
|
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
Type describes possible specializations of Round_Rect. Each Type is
|
|
|
|
exclusive; a Round_Rect may only have one type.
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
Type members become progressively less restrictive; larger values of
|
2018-06-28 12:50:35 +00:00
|
|
|
Type have more degrees of freedom than smaller values.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kEmpty_Type 0
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # zero width or height ##
|
2018-06-27 15:00:21 +00:00
|
|
|
Round_Rect has zero width or height. All radii are zero.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kRect_Type 1
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # non-zero width and height, and zeroed radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
Round_Rect has width and height. All radii are zero.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kOval_Type 2
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # non-zero width and height filled with radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
Round_Rect has width and height. All four x-radii are equal,
|
|
|
|
and at least half the width. All four y-radii are equal,
|
|
|
|
and at least half the height.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kSimple_Type 3
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # non-zero width and height with equal radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
Round_Rect has width and height. All four x-radii are equal and
|
|
|
|
greater than zero, and all four y-radii are equal and greater than
|
|
|
|
zero. Either x-radii are less than half the width, or y-radii is
|
|
|
|
less than half the height, or both.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kNinePatch_Type 4
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # non-zero width and height with axis-aligned radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
Round_Rect has width and height. Left x-radii are equal, top
|
|
|
|
y-radii are equal, right x-radii are equal, and bottom y-radii
|
2018-07-17 12:20:27 +00:00
|
|
|
are equal. The radii do not describe Rect, Oval, or simple type.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
The centers of the corner ellipses form an axis-aligned rectangle
|
|
|
|
that divides the Round_Rect into nine rectangular patches; an
|
|
|
|
interior rectangle, four edges, and four corners.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kComplex_Type 5
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # non-zero width and height with arbitrary radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
both radii are non-zero.
|
|
|
|
##
|
2018-07-11 20:18:41 +00:00
|
|
|
#Const kLastType 5
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # largest Type value ##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 128
|
2018-10-31 16:14:03 +00:00
|
|
|
struct Radii { SkVector data[4]; };
|
|
|
|
auto drawRRectType = [=](const SkRect& rect, const Radii& radii) {
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii(rect, radii.data);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
const char* typeStr[] = { "empty", "rect", "oval", "simple", "nine patch", "complex" };
|
|
|
|
canvas->drawString(typeStr[(int) rrect.type()], rect.centerX(), rect.bottom() + 20, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
};
|
|
|
|
drawRRectType({ 45, 30, 45, 30}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
|
|
|
|
drawRRectType({ 90, 10, 140, 30}, {{{ 0, 0}, { 0, 0}, { 0, 0}, { 0, 0}}});
|
|
|
|
drawRRectType({160, 10, 210, 30}, {{{25, 10}, {25, 10}, {25, 10}, {25, 10}}});
|
|
|
|
drawRRectType({ 20, 80, 70, 100}, {{{ 5, 5}, { 5, 5}, { 5, 5}, { 5, 5}}});
|
|
|
|
drawRRectType({ 90, 80, 140, 100}, {{{ 5, 5}, {10, 5}, {10, 5}, { 5, 5}}});
|
2018-06-28 12:50:35 +00:00
|
|
|
drawRRectType({160, 80, 210, 100}, {{{ 5, 5}, {10, 5}, { 5, 5}, { 5, 5}}});
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso Rect Path
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Enum ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method Type getType() const
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns Type ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
Returns Type, one of: #list_of_rrect_types#.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Return Type ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 100
|
2018-06-28 12:50:35 +00:00
|
|
|
#Description
|
|
|
|
rrect2 is not a Rect; inset() has made it empty.
|
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
|
|
|
SkRRect rrect2(rrect);
|
|
|
|
rrect2.inset(20, 20);
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
std::string str("Type ");
|
|
|
|
str += SkRRect::kRect_Type == rrect2.getType() ? "=" : "!";
|
|
|
|
str += "= SkRRect::kRect_Type";
|
|
|
|
canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect2, p);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso Type type
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method Type type() const
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns Type ##
|
|
|
|
|
|
|
|
Returns Type, one of: #list_of_rrect_types#.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Return Type ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 100
|
2018-06-28 12:50:35 +00:00
|
|
|
#Description
|
|
|
|
inset() has made rrect2 empty.
|
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({10, 10, 100, 50});
|
|
|
|
SkRRect rrect2(rrect);
|
|
|
|
rrect2.inset(20, 20);
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
std::string str("Type ");
|
|
|
|
str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
|
|
|
|
str += "= SkRRect::kEmpty_Type";
|
|
|
|
canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect2, p);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso Type getType
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#Subtopic Type ##
|
|
|
|
|
2018-06-27 15:00:21 +00:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isEmpty() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns true if width or height are zero ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 10, 5);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
|
|
|
|
rrect.inset(40, 0);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isEmpty() ? "empty" : "not empty", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkRect::isEmpty height width
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isRect() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns true if not empty, and one radius at each corner is zero ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
|
|
|
|
SkVector radii[] = {{10, 10}, {0, 0}, {0, 0}, {0, 0}};
|
|
|
|
rrect.setRectRadii(rrect.getBounds(), radii);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isRect() ? "rect" : "not rect", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isEmpty radii
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isOval() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns true if not empty, axes radii are equal, radii fill bounds ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 100
|
|
|
|
#Description
|
|
|
|
The first radii are scaled down proportionately until both x-axis and y-axis fit
|
|
|
|
within the bounds. After scaling, x-axis radius is smaller than half the width;
|
2018-07-11 20:18:41 +00:00
|
|
|
left Round_Rect is not an oval. The second radii are equal to half the
|
|
|
|
dimensions; right Round_Rect is an oval.
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 40, 30);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
|
|
|
|
rrect.setRectXY(rrect.getBounds(), 35, 25);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isOval() ? "oval" : "not oval", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isEmpty isSimple SkCanvas::drawOval
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isSimple() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns true if not empty, Rect or Oval; and axes radii are equal ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkVector radii[] = {{40, 30}, {40, 30}, {40, 30}, {40, 30}};
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii({30, 10, 100, 60}, radii);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
|
|
|
|
radii[0].fX = 35;
|
|
|
|
rrect.setRectRadii(rrect.getBounds(), radii);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isSimple() ? "simple" : "not simple", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isEmpty isRect isOval isNinePatch
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isNinePatch() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns true if not empty, Rect, Oval or simple; and radii are axis-aligned ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkVector radii[] = {{20, 30}, {40, 30}, {40, 30}, {20, 30}};
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii({30, 10, 100, 60}, radii);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
|
|
|
|
radii[0].fX = 35;
|
|
|
|
rrect.setRectRadii(rrect.getBounds(), radii);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isNinePatch() ? "9 patch" : "not 9 patch", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isEmpty isRect isOval isSimple isComplex
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method bool isComplex() const
|
2018-06-27 15:00:21 +00:00
|
|
|
#In Property
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns true if not empty, Rect, Oval, simple, or nine-patch ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(16);
|
|
|
|
SkVector radii[] = {{25, 30}, {40, 30}, {40, 30}, {20, 30}};
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii({30, 10, 100, 60}, radii);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
|
|
|
|
radii[0].fX = 20;
|
|
|
|
rrect.setRectRadii(rrect.getBounds(), radii);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawString(rrect.isComplex() ? "complex" : "not complex", 64, 90, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso isEmpty isRect isOval isSimple isNinePatch
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkScalar width() const
|
|
|
|
#In Property
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns span in x-axis ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Description
|
|
|
|
SkRRect::MakeRect sorts its input, so width() is always zero or larger.
|
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 5 });
|
|
|
|
SkDebugf("unsorted width: %g\n", unsorted.width());
|
|
|
|
SkRRect large = SkRRect::MakeRect({ -FLT_MAX, 1, FLT_MAX, 2 });
|
2018-06-27 15:00:21 +00:00
|
|
|
SkDebugf("large width: %.0f\n", large.width());
|
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
unsorted width: 5
|
2018-06-27 15:00:21 +00:00
|
|
|
large width: inf
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkRect::width height getBounds
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkScalar height() const
|
|
|
|
#In Property
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns span in y-axis ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
|
|
|
#Description
|
|
|
|
SkRRect::MakeRect sorts its input, so height() is always zero or larger.
|
|
|
|
##
|
|
|
|
SkRRect unsorted = SkRRect::MakeRect({ 15, 25, 10, 20 });
|
|
|
|
SkDebugf("unsorted height: %g\n", unsorted.height());
|
|
|
|
SkRRect large = SkRRect::MakeRect({ 1, -FLT_MAX, 2, FLT_MAX });
|
|
|
|
SkDebugf("large height: %.0f\n", large.height());
|
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
unsorted height: 5
|
2018-06-27 15:00:21 +00:00
|
|
|
large height: inf
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
#SeeAlso SkRect::height width getBounds
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkVector getSimpleRadii() const
|
|
|
|
#In Property
|
|
|
|
#Line # returns corner radii for simple types ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 100
|
2018-10-31 16:14:03 +00:00
|
|
|
auto drawDetails = [=](const SkRRect& rrect) {
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setTextSize(12);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
SkVector corner = rrect.getSimpleRadii();
|
|
|
|
std::string label = "corner: " + std::to_string(corner.fX).substr(0, 3) + ", " +
|
|
|
|
std::to_string(corner.fY).substr(0, 3);
|
|
|
|
canvas->drawString(label.c_str(), 64, 90, paint);
|
|
|
|
canvas->translate(128, 0);
|
|
|
|
};
|
|
|
|
SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
|
|
|
drawDetails(rrect);
|
|
|
|
rrect.setRectXY(rrect.getBounds(), 5, 8);
|
|
|
|
drawDetails(rrect);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso radii getBounds getType isSimple
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setEmpty()
|
|
|
|
#In Set
|
|
|
|
#Line # zeroes width, height, and corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 80
|
2018-06-27 15:00:21 +00:00
|
|
|
#Description
|
2018-07-11 20:18:41 +00:00
|
|
|
Nothing blue is drawn because Round_Rect is set to empty.
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setEmpty();
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso MakeEmpty setRect
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setRect(const SkRect& rect)
|
|
|
|
#In Set
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # sets Round_Rect bounds with zeroed corners ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 90
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setRect({60, 30, 120, 80});
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
2018-06-27 15:00:21 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso MakeRect setRectXY
|
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method static SkRRect MakeEmpty()
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # creates with zeroed bounds and corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 90
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeEmpty();
|
|
|
|
SkRRect rrect2(rrect);
|
|
|
|
rrect2.inset(-20, -20);
|
|
|
|
SkPaint p;
|
|
|
|
p.setStyle(SkPaint::kStroke_Style);
|
|
|
|
p.setStrokeWidth(10);
|
|
|
|
std::string str("Type ");
|
|
|
|
str += SkRRect::kEmpty_Type == rrect2.type() ? "=" : "!";
|
|
|
|
str += "= SkRRect::kEmpty_Type";
|
|
|
|
canvas->drawString(str.c_str(), 20, 80, SkPaint());
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect2, p);
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso SkRRect() SkRect::MakeEmpty
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method static SkRRect MakeRect(const SkRect& r)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # copies bounds and zeroes corner radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRect({30, 10, 100, 60});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setOval(rrect.getBounds());
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setRect MakeOval MakeRectXY
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method static SkRRect MakeOval(const SkRect& oval)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # creates Oval to fit bounds ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeOval({30, 10, 100, 60});
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setRect(rrect.getBounds());
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
|
|
|
paint.setBlendMode(SkBlendMode::kDifference);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setOval MakeRect MakeRectXY
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method static SkRRect MakeRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Constructors
|
2018-06-28 12:50:35 +00:00
|
|
|
#Line # creates rounded rectangle ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setRect(rrect.getBounds());
|
|
|
|
paint.setColor(SK_ColorBLUE);
|
|
|
|
paint.setBlendMode(SkBlendMode::kModulate);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setRectXY
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setOval(const SkRect& oval)
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Set
|
|
|
|
#Line # replaces with Oval to fit bounds ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setOval(rrect.getBounds());
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
paint.setBlendMode(SkBlendMode::kExclusion);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso MakeOval
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad)
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Set
|
|
|
|
#Line # replaces with rounded rectangle ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({30, 10, 100, 60}, 20, 20);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.setRectXY(rrect.getBounds(), 5, 5);
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
paint.setBlendMode(SkBlendMode::kExclusion);
|
2018-06-28 12:50:35 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso MakeRectXY SkPath::addRoundRect
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
|
|
|
|
SkScalar rightRad, SkScalar bottomRad)
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Set
|
|
|
|
#Line # replaces with rounded rectangle ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 12:50:35 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setNinePatch({30, 10, 100, 60}, 10, 20, 20, 10);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
const SkRect r = rrect.getBounds();
|
|
|
|
canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
|
|
|
|
r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
|
|
|
|
canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
|
|
|
|
r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
|
|
|
|
canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
|
|
|
|
r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
|
|
|
|
canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
|
2018-06-28 12:50:35 +00:00
|
|
|
r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setRectRadii
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void setRectRadii(const SkRect& rect, const SkVector radii[4])
|
2018-06-28 12:50:35 +00:00
|
|
|
#In Set
|
|
|
|
#Line # replaces with rounded rectangle ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 128
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setStrokeWidth(15);
|
|
|
|
paint.setStrokeCap(SkPaint::kSquare_Cap);
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
float intervals[] = { 5, 21.75f };
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
paint.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 0));
|
|
|
|
SkPath path;
|
|
|
|
SkRRect rrect;
|
|
|
|
SkVector corners[] = {{15, 17}, {17, 19}, {19, 15}, {15, 15}};
|
|
|
|
rrect.setRectRadii({20, 20, 100, 100}, corners);
|
|
|
|
path.addRRect(rrect, SkPath::kCW_Direction);
|
|
|
|
canvas->drawPath(path, paint);
|
|
|
|
path.rewind();
|
|
|
|
path.addRRect(rrect, SkPath::kCCW_Direction, 1);
|
|
|
|
canvas->translate(120, 0);
|
2018-06-28 23:13:56 +00:00
|
|
|
canvas->drawPath(path, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 12:50:35 +00:00
|
|
|
#SeeAlso setNinePatch SkPath::addRoundRect
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Enum Corner
|
2018-06-28 23:13:56 +00:00
|
|
|
#Line # corner radii order ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Code
|
|
|
|
enum Corner {
|
|
|
|
kUpperLeft_Corner,
|
|
|
|
kUpperRight_Corner,
|
|
|
|
kLowerRight_Corner,
|
|
|
|
kLowerLeft_Corner,
|
|
|
|
};
|
|
|
|
##
|
|
|
|
|
|
|
|
The radii are stored: top-left, top-right, bottom-right, bottom-left.
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#Const kUpperLeft_Corner 0
|
|
|
|
#Line # index of top-left corner radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
2018-06-28 23:13:56 +00:00
|
|
|
#Const kUpperRight_Corner 1
|
|
|
|
#Line # index of top-right corner radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
2018-06-28 23:13:56 +00:00
|
|
|
#Const kLowerRight_Corner 2
|
|
|
|
#Line # index of bottom-right corner radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
2018-06-28 23:13:56 +00:00
|
|
|
#Const kLowerLeft_Corner 3
|
|
|
|
#Line # index of bottom-left corner radii ##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
#Example
|
2018-06-28 23:13:56 +00:00
|
|
|
#Height 70
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
SkRRect rrect;
|
|
|
|
SkVector corners[] = {{25, 17}, {17, 19}, {19, 15}, {15, 15}};
|
|
|
|
rrect.setRectRadii({30, 10, 100, 60}, corners);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
const SkRect r = rrect.getBounds();
|
|
|
|
canvas->drawLine(r.fLeft, r.fTop + rrect.radii(SkRRect::kUpperLeft_Corner).fY,
|
|
|
|
r.fRight, r.fTop + rrect.radii(SkRRect::kUpperRight_Corner).fY, paint);
|
|
|
|
canvas->drawLine(r.fLeft, r.fBottom - rrect.radii(SkRRect::kLowerLeft_Corner).fY,
|
|
|
|
r.fRight, r.fBottom - rrect.radii(SkRRect::kLowerRight_Corner).fY, paint);
|
|
|
|
canvas->drawLine(r.fLeft + rrect.radii(SkRRect::kUpperLeft_Corner).fX, r.fTop,
|
|
|
|
r.fLeft + rrect.radii(SkRRect::kLowerLeft_Corner).fX, r.fBottom, paint);
|
|
|
|
canvas->drawLine(r.fRight - rrect.radii(SkRRect::kUpperRight_Corner).fX, r.fTop,
|
2018-06-28 23:13:56 +00:00
|
|
|
r.fRight - rrect.radii(SkRRect::kLowerRight_Corner).fX, r.fBottom, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso radii
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Enum ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method const SkRect& rect() const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns bounds ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
for (SkScalar left : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
|
|
|
|
SkRRect rrect1 = SkRRect::MakeRectXY({left, 20, 60, 220}, 50, 200);
|
|
|
|
SkDebugf("left bounds: (%g) %g\n", left, rrect1.rect().fLeft);
|
2018-06-28 23:13:56 +00:00
|
|
|
}
|
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
left bounds: (nan) 0
|
|
|
|
left bounds: (inf) 0
|
|
|
|
left bounds: (100) 60
|
|
|
|
left bounds: (50) 50
|
2018-06-28 23:13:56 +00:00
|
|
|
left bounds: (25) 25
|
|
|
|
##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso getBounds
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method SkVector radii(Corner corner) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns x-axis and y-axis radii for one corner ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 23:13:56 +00:00
|
|
|
#Description
|
|
|
|
Finite values are scaled proportionately to fit; other values are set to zero.
|
2018-07-11 20:18:41 +00:00
|
|
|
Scaled values cannot be larger than 25, half the bounding Round_Rect width.
|
2018-06-28 23:13:56 +00:00
|
|
|
Small scaled values are halved to scale in proportion to the y-axis corner
|
|
|
|
radius, which is twice the bounds height.
|
|
|
|
##
|
2018-10-31 16:14:03 +00:00
|
|
|
for (SkScalar radiusX : { SK_ScalarNaN, SK_ScalarInfinity, 100.f, 50.f, 25.f} ) {
|
|
|
|
SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, radiusX, 200);
|
|
|
|
SkDebugf("left corner: (%g) %g\n", radiusX, rrect1.radii(SkRRect::kUpperLeft_Corner).fX);
|
|
|
|
}
|
2018-06-28 23:13:56 +00:00
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
left corner: (nan) 0
|
|
|
|
left corner: (inf) 0
|
|
|
|
left corner: (100) 25
|
|
|
|
left corner: (50) 25
|
2018-06-28 23:13:56 +00:00
|
|
|
left corner: (25) 12.5
|
|
|
|
##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso Corner
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method const SkRect& getBounds() const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Property
|
|
|
|
#Line # returns bounds ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-06-28 23:13:56 +00:00
|
|
|
#Height 120
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({20, 20, 220, 100}, 15, 15);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
paint.setColor(SK_ColorWHITE);
|
|
|
|
rrect = SkRRect::MakeOval(rrect.getBounds());
|
2018-06-28 23:13:56 +00:00
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso rect
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool operator==(const SkRRect& a, const SkRRect& b)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Operators
|
2018-06-28 23:13:56 +00:00
|
|
|
#Line # returns true if members are equal ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 200);
|
|
|
|
SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 25, 100);
|
|
|
|
SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
|
|
|
|
canvas->drawRRect(rrect1, SkPaint());
|
|
|
|
std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
|
|
|
|
canvas->drawString(str.c_str(), 10, 240, SkPaint());
|
|
|
|
canvas->translate(70, 0);
|
|
|
|
canvas->drawRRect(rrect2, SkPaint());
|
|
|
|
canvas->translate(70, 0);
|
|
|
|
canvas->drawRRect(rrect3, SkPaint());
|
|
|
|
str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
|
2018-06-28 23:13:56 +00:00
|
|
|
canvas->drawString(str.c_str(), -20, 240, SkPaint());
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso operator!=(const SkRRect& a, const SkRRect& b)
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool operator!=(const SkRRect& a, const SkRRect& b)
|
2018-10-08 18:57:48 +00:00
|
|
|
#In Operators
|
2018-06-28 23:13:56 +00:00
|
|
|
#Line # returns true if members are unequal ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect1 = SkRRect::MakeRectXY({10, 20, 60, 220}, 50, 100);
|
|
|
|
SkRRect rrect2 = SkRRect::MakeRectXY(rrect1.rect(), 50, 50);
|
|
|
|
SkRRect rrect3 = SkRRect::MakeOval(rrect1.rect());
|
|
|
|
canvas->drawRRect(rrect1, SkPaint());
|
|
|
|
std::string str = "rrect1 " + std::string(rrect1 == rrect2 ? "=" : "!") + "= rrect2";
|
|
|
|
canvas->drawString(str.c_str(), 10, 240, SkPaint());
|
|
|
|
canvas->translate(70, 0);
|
|
|
|
canvas->drawRRect(rrect2, SkPaint());
|
|
|
|
canvas->translate(70, 0);
|
|
|
|
canvas->drawRRect(rrect3, SkPaint());
|
|
|
|
str = "rrect2 " + std::string(rrect2 == rrect3 ? "=" : "!") + "= rrect3";
|
2018-06-28 23:13:56 +00:00
|
|
|
canvas->drawString(str.c_str(), -20, 240, SkPaint());
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso operator==(const SkRRect& a, const SkRRect& b)
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void inset(SkScalar dx, SkScalar dy, SkRRect* dst) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # insets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.inset(-3, 3, &rrect);
|
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso outset offset makeOffset
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void inset(SkScalar dx, SkScalar dy)
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # insets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({10, 20, 180, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.inset(3, 3);
|
2018-06-28 23:13:56 +00:00
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso outset offset makeOffset
|
|
|
|
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void outset(SkScalar dx, SkScalar dy, SkRRect* dst) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # outsets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.outset(-3, 3, &rrect);
|
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso inset offset makeOffset
|
|
|
|
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void outset(SkScalar dx, SkScalar dy)
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # outsets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.outset(3, 3);
|
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso inset offset makeOffset
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void offset(SkScalar dx, SkScalar dy)
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # offsets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect.offset(3, 3);
|
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso makeOffset inset outset
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
2018-10-08 18:57:48 +00:00
|
|
|
#Method SkRRect makeOffset(SkScalar dx, SkScalar dy) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # offsets bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
SkRRect rrect = SkRRect::MakeRectXY({100, 20, 140, 220}, 50, 100);
|
|
|
|
for (int index = 0; index < 25; ++index) {
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
rrect = rrect.makeOffset(-3, 3);
|
2018-06-28 23:13:56 +00:00
|
|
|
}
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso offset inset outset
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool contains(const SkRect& rect) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Intersection
|
|
|
|
#Line # returns true if Rect is inside ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRect test = {10, 10, 110, 80};
|
|
|
|
SkRRect rrect = SkRRect::MakeRect(test);
|
|
|
|
SkRRect oval = SkRRect::MakeOval(test);
|
|
|
|
test.inset(10, 10);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawString(rrect.contains(test) ? "contains" : "does not contain", 55, 100, paint);
|
|
|
|
canvas->drawString(oval.contains(test) ? "contains" : "does not contain", 185, 100, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->drawRect(test, paint);
|
|
|
|
canvas->translate(120, 0);
|
|
|
|
canvas->drawRRect(oval, paint);
|
2018-07-11 20:18:41 +00:00
|
|
|
canvas->drawRect(test, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso SkRect::contains
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool isValid() const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # returns if type() matches bounds and radii ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
|
|
|
|
SkRRect corrupt = rrect;
|
|
|
|
*((float*) &corrupt) = 120;
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawString(rrect.isValid() ? "is valid" : "is corrupted", 55, 100, paint);
|
|
|
|
canvas->drawString(corrupt.isValid() ? "is valid" : "is corrupted", 185, 100, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->translate(120, 0);
|
2018-07-11 20:18:41 +00:00
|
|
|
canvas->drawRRect(corrupt, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
#SeeAlso Type getType
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Const kSizeInMemory 48
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # storage space for Round_Rect ##
|
2018-06-27 15:00:21 +00:00
|
|
|
|
2018-11-07 19:59:03 +00:00
|
|
|
Space required to write the contents of SkRRect into a buffer; always a multiple of four.
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Const ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method size_t writeToMemory(void* buffer) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # writes Round_Rect to buffer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({10, 10, 110, 80});
|
|
|
|
char storage[SkRRect::kSizeInMemory];
|
|
|
|
rrect.writeToMemory(storage);
|
|
|
|
SkRRect copy;
|
|
|
|
copy.readFromMemory(storage, sizeof(storage));
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawString("rrect", 55, 100, paint);
|
|
|
|
canvas->drawString("copy", 185, 100, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->translate(120, 0);
|
2018-07-11 20:18:41 +00:00
|
|
|
canvas->drawRRect(copy, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
#SeeAlso readFromMemory
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method size_t readFromMemory(const void* buffer, size_t length)
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
2018-07-11 20:18:41 +00:00
|
|
|
#Line # reads Round_Rect from buffer ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii({10, 10, 110, 80}, radii);
|
|
|
|
char storage[SkRRect::kSizeInMemory];
|
|
|
|
rrect.writeToMemory(storage);
|
|
|
|
SkRRect copy;
|
|
|
|
copy.readFromMemory(storage, sizeof(storage));
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawString("rrect", 55, 100, paint);
|
|
|
|
canvas->drawString("copy", 185, 100, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
|
|
|
canvas->translate(120, 0);
|
2018-07-11 20:18:41 +00:00
|
|
|
canvas->drawRRect(copy, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
#SeeAlso writeToMemory
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method bool transform(const SkMatrix& matrix, SkRRect* dst) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Inset_Outset_Offset
|
|
|
|
#Line # scales and offsets into copy ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-07-11 20:18:41 +00:00
|
|
|
#Height 110
|
2018-10-31 16:14:03 +00:00
|
|
|
SkVector radii[] = {{5, 5}, {10, 10}, {15, 15}, {5, 5}};
|
|
|
|
SkRRect rrect;
|
|
|
|
rrect.setRectRadii({10, 10, 110, 80}, radii);
|
|
|
|
SkRRect transformed;
|
|
|
|
SkMatrix matrix = SkMatrix::MakeRectToRect(rrect.rect(), {140, 30, 220, 80},
|
|
|
|
SkMatrix::kCenter_ScaleToFit);
|
|
|
|
bool success = rrect.transform(matrix, &transformed);
|
|
|
|
SkPaint paint;
|
|
|
|
paint.setAntiAlias(true);
|
|
|
|
canvas->drawString("rrect", 55, 100, paint);
|
|
|
|
canvas->drawString(success ? "transformed" : "transform failed", 185, 100, paint);
|
|
|
|
paint.setStyle(SkPaint::kStroke_Style);
|
|
|
|
canvas->drawRRect(rrect, paint);
|
2018-07-11 20:18:41 +00:00
|
|
|
canvas->drawRRect(transformed, paint);
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-07-11 20:18:41 +00:00
|
|
|
#SeeAlso SkPath::transform
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void dump(bool asHex) const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
|
|
|
#Line # sends text representation to standard output ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
|
|
|
for (bool dumpAsHex : { false, true } ) {
|
|
|
|
rrect.dump(dumpAsHex);
|
2018-06-28 23:13:56 +00:00
|
|
|
}
|
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
|
|
|
SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
2018-06-28 23:13:56 +00:00
|
|
|
};
|
|
|
|
##
|
|
|
|
##
|
|
|
|
|
|
|
|
#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void dump() const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
|
|
|
#Line # sends text representation using floats to standard output ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
|
|
|
rrect.dump();
|
|
|
|
SkRect bounds = SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
};
|
|
|
|
SkRRect copy;
|
|
|
|
copy.setRectRadii(bounds, corners);
|
|
|
|
SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
|
2018-06-28 23:13:56 +00:00
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
{ 0, 0 },
|
|
|
|
};
|
2018-06-28 23:13:56 +00:00
|
|
|
rrect is not equal to copy
|
|
|
|
##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso dumpHex SkRect::dump SkPath::dump SkPathMeasure::dump
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#Method void dumpHex() const
|
2018-06-28 23:13:56 +00:00
|
|
|
#In Utility
|
|
|
|
#Line # sends text representation using hexadecimal to standard output ##
|
2018-10-31 16:14:03 +00:00
|
|
|
#Populate
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Example
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRRect rrect = SkRRect::MakeRect({6.f / 7, 2.f / 3, 6.f / 7, 2.f / 3});
|
|
|
|
rrect.dumpHex();
|
|
|
|
SkRect bounds = SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
|
|
|
SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
};
|
|
|
|
SkRRect copy;
|
|
|
|
copy.setRectRadii(bounds, corners);
|
2018-06-28 23:13:56 +00:00
|
|
|
SkDebugf("rrect is " "%s" "equal to copy\n", rrect == copy ? "" : "not ");
|
|
|
|
#StdOut
|
2018-10-31 16:14:03 +00:00
|
|
|
SkRect::MakeLTRB(SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab), /* 0.666667 */
|
|
|
|
SkBits2Float(0x3f5b6db7), /* 0.857143 */
|
|
|
|
SkBits2Float(0x3f2aaaab) /* 0.666667 */);
|
|
|
|
const SkPoint corners[] = {
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
{ SkBits2Float(0x00000000), SkBits2Float(0x00000000) }, /* 0.000000 0.000000 */
|
|
|
|
};
|
2018-06-28 23:13:56 +00:00
|
|
|
rrect is equal to copy
|
|
|
|
##
|
2018-06-27 15:00:21 +00:00
|
|
|
##
|
|
|
|
|
2018-06-28 23:13:56 +00:00
|
|
|
#SeeAlso dump SkRect::dumpHex SkPath::dumpHex
|
2018-06-27 15:00:21 +00:00
|
|
|
|
|
|
|
#Method ##
|
|
|
|
|
|
|
|
#Class SkRRect ##
|
|
|
|
|
|
|
|
#Topic RRect ##
|