Flutter Engine
The Flutter Engine
|
#include <SkRRect.h>
Public Types | |
enum | Type { kEmpty_Type , kRect_Type , kOval_Type , kSimple_Type , kNinePatch_Type , kComplex_Type , kLastType = kComplex_Type } |
enum | Corner { kUpperLeft_Corner , kUpperRight_Corner , kLowerRight_Corner , kLowerLeft_Corner } |
Public Member Functions | |
SkRRect ()=default | |
SkRRect (const SkRRect &rrect)=default | |
SkRRect & | operator= (const SkRRect &rrect)=default |
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) |
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]) |
const SkRect & | rect () const |
SkVector | radii (Corner corner) const |
const SkRect & | getBounds () const |
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 |
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 |
SkString | dumpToString (bool asHex) const |
void | dump () const |
void | dumpHex () const |
Static Public Member Functions | |
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) |
Static Public Attributes | |
static constexpr size_t | kSizeInMemory = 12 * sizeof(SkScalar) |
Friends | |
class | SkPath |
class | SkRRectPriv |
bool | operator== (const SkRRect &a, const SkRRect &b) |
bool | operator!= (const SkRRect &a, const SkRRect &b) |
SkRRect describes a rounded rectangle with a bounds and a pair of radii for each corner. 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.
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 corners.
SkRRect may modify the provided parameters when initializing bounds and radii. If either axis radii is zero or less: radii are stored as zero; corner is square. If corner curves overlap, radii are proportionally reduced to fit within bounds.
enum SkRRect::Corner |
Definition at line 251 of file SkRRect.h.
enum SkRRect::Type |
Enumerator | |
---|---|
kEmpty_Type | zero width or height |
kRect_Type | non-zero width and height, and zeroed radii |
kOval_Type | non-zero width and height filled with radii |
kSimple_Type | non-zero width and height with equal radii |
kNinePatch_Type | non-zero width and height with axis-aligned radii |
kComplex_Type | non-zero width and height with arbitrary radii |
kLastType | largest Type value |
Definition at line 66 of file SkRRect.h.
|
default |
Initializes bounds at (0, 0), the origin, with zero width and height. Initializes corner radii to (0, 0), and sets type of kEmpty_Type.
|
default |
Initializes to copy of rrect bounds and corner radii.
rrect | bounds and corner to copy |
bool SkRRect::contains | ( | const SkRect & | rect | ) | const |
Returns true if rect is inside the bounds and corner radii, and if SkRRect and rect are not empty.
rect | area tested for containment |
example: https://fiddle.skia.org/c/@RRect_contains
Definition at line 360 of file SkRRect.cpp.
|
inline |
void SkRRect::dump | ( | bool | asHex | ) | const |
Writes text representation of SkRRect to standard output. Set asHex true to generate exact binary representations of floating point numbers.
asHex | true if SkScalar values are written as hexadecimal |
example: https://fiddle.skia.org/c/@RRect_dump
Definition at line 651 of file SkRRect.cpp.
|
inline |
SkString SkRRect::dumpToString | ( | bool | asHex | ) | const |
Definition at line 632 of file SkRRect.cpp.
|
inline |
|
inline |
Returns top-left corner radii. If type() returns kEmpty_Type, kRect_Type, kOval_Type, or kSimple_Type, returns a value representative of all corner radii. If type() returns kNinePatch_Type or kComplex_Type, at least one of the remaining three corners has a different value.
Definition at line 111 of file SkRRect.h.
|
inline |
|
inline |
Insets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be positive, negative, or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if adjusted radius becomes negative, pins radius to zero. If dx exceeds half bounds width, bounds left and right are set to bounds x-axis center. If dy exceeds half bounds height, bounds top and bottom are set to bounds y-axis center.
If dx or dy cause the bounds to become infinite, bounds is zeroed.
dx | added to rect().fLeft, and subtracted from rect().fRight |
dy | added to rect().fTop, and subtracted from rect().fBottom |
Definition at line 341 of file SkRRect.h.
Copies SkRRect to dst, then insets dst bounds by dx and dy, and adjusts dst radii by dx and dy. dx and dy may be positive, negative, or zero. dst may be SkRRect.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if adjusted radius becomes negative, pins radius to zero. If dx exceeds half dst bounds width, dst bounds left and right are set to bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and bottom are set to bounds y-axis center.
If dx or dy cause the bounds to become infinite, dst bounds is zeroed.
dx | added to rect().fLeft, and subtracted from rect().fRight |
dy | added to rect().fTop, and subtracted from rect().fBottom |
dst | insets bounds and radii |
example: https://fiddle.skia.org/c/@RRect_inset
Definition at line 562 of file SkRRect.cpp.
bool SkRRect::isValid | ( | ) | const |
Returns true if bounds and radii values are finite and describe a SkRRect SkRRect::Type that matches getType(). All SkRRect methods construct valid types, even if the input values are not valid. Invalid SkRRect data can only be generated by corrupting memory.
example: https://fiddle.skia.org/c/@RRect_isValid
Definition at line 663 of file SkRRect.cpp.
|
inlinestatic |
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval.height(). If oval bounds is empty, sets to kEmpty_Type. Otherwise, sets to kOval_Type.
oval | bounds of oval |
|
inlinestatic |
Sets to rounded rectangle with the same radii for all four corners. If rect is empty, sets to kEmpty_Type. Otherwise, if xRad and yRad are zero, sets to kRect_Type. Otherwise, if xRad is at least half rect.width() and yRad is at least half rect.height(), sets to kOval_Type. Otherwise, sets to kSimple_Type.
rect | bounds of rounded rectangle |
xRad | x-axis radius of corners |
yRad | y-axis radius of corners |
Definition at line 180 of file SkRRect.h.
Copies rrect bounds and corner radii.
rrect | bounds and corner to copy |
Outsets bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be positive, negative, or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if adjusted radius becomes negative, pins radius to zero. If dx exceeds half bounds width, bounds left and right are set to bounds x-axis center. If dy exceeds half bounds height, bounds top and bottom are set to bounds y-axis center.
If dx or dy cause the bounds to become infinite, bounds is zeroed.
Outsets dst bounds by dx and dy, and adjusts radii by dx and dy. dx and dy may be positive, negative, or zero.
If either corner radius is zero, the corner has no curvature and is unchanged. Otherwise, if adjusted radius becomes negative, pins radius to zero. If dx exceeds half dst bounds width, dst bounds left and right are set to bounds x-axis center. If dy exceeds half dst bounds height, dst bounds top and bottom are set to bounds y-axis center.
If dx or dy cause the bounds to become infinite, dst bounds is zeroed.
size_t SkRRect::readFromMemory | ( | const void * | buffer, |
size_t | length | ||
) |
Reads SkRRect from buffer, reading kSizeInMemory bytes. Returns kSizeInMemory, bytes read if length is at least kSizeInMemory. Otherwise, returns zero.
buffer | memory to read from |
length | size of buffer |
example: https://fiddle.skia.org/c/@RRect_readFromMemory
Definition at line 610 of file SkRRect.cpp.
|
inline |
Returns bounds. Bounds may have zero width or zero height. Bounds right is greater than or equal to left; bounds bottom is greater than or equal to top. Result is identical to getBounds().
Definition at line 264 of file SkRRect.h.
|
inline |
void SkRRect::setNinePatch | ( | const SkRect & | rect, |
SkScalar | leftRad, | ||
SkScalar | topRad, | ||
SkScalar | rightRad, | ||
SkScalar | bottomRad | ||
) |
Sets bounds to rect. Sets radii to (leftRad, topRad), (rightRad, topRad), (rightRad, bottomRad), (leftRad, bottomRad).
If rect is empty, sets to kEmpty_Type. Otherwise, if leftRad and rightRad are zero, sets to kRect_Type. Otherwise, if topRad and bottomRad are zero, sets to kRect_Type. Otherwise, if leftRad and rightRad are equal and at least half rect.width(), and topRad and bottomRad are equal at least half rect.height(), sets to kOval_Type. Otherwise, if leftRad and rightRad are equal, and topRad and bottomRad are equal, sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
Nine patch refers to the nine parts defined by the radii: one center rectangle, four edge patches, and four corner patches.
rect | bounds of rounded rectangle |
leftRad | left-top and left-bottom x-axis radius |
topRad | left-top and right-top y-axis radius |
rightRad | right-top and right-bottom x-axis radius |
bottomRad | left-bottom and right-bottom y-axis radius |
Definition at line 115 of file SkRRect.cpp.
void SkRRect::setOval | ( | const SkRect & | oval | ) |
Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval.height(). If oval bounds is empty, sets to kEmpty_Type. Otherwise, sets to kOval_Type.
oval | bounds of oval |
Definition at line 30 of file SkRRect.cpp.
|
inline |
Sets bounds to sorted rect, and sets corner radii to zero. If set bounds has width and height, and sets type to kRect_Type; otherwise, sets type to kEmpty_Type.
rect | bounds to set |
Definition at line 126 of file SkRRect.h.
Sets bounds to rect. Sets radii array for individual control of all for corners.
If rect is empty, sets to kEmpty_Type. Otherwise, if one of each corner radii are zero, sets to kRect_Type. Otherwise, if all x-axis radii are equal and at least half rect.width(), and all y-axis radii are equal at least half rect.height(), sets to kOval_Type. Otherwise, if all x-axis radii are equal, and all y-axis radii are equal, sets to kSimple_Type. Otherwise, sets to kNinePatch_Type.
rect | bounds of rounded rectangle |
radii | corner x-axis and y-axis radii |
example: https://fiddle.skia.org/c/@RRect_setRectRadii
Definition at line 189 of file SkRRect.cpp.
Sets to rounded rectangle with the same radii for all four corners. If rect is empty, sets to kEmpty_Type. Otherwise, if xRad or yRad is zero, sets to kRect_Type. Otherwise, if xRad is at least half rect.width() and yRad is at least half rect.height(), sets to kOval_Type. Otherwise, sets to kSimple_Type.
rect | bounds of rounded rectangle |
xRad | x-axis radius of corners |
yRad | y-axis radius of corners |
example: https://fiddle.skia.org/c/@RRect_setRectXY
Definition at line 52 of file SkRRect.cpp.
Transforms by SkRRect by matrix, storing result in dst. Returns true if SkRRect transformed can be represented by another SkRRect. Returns false if matrix contains transformations that are not axis aligned.
Asserts in debug builds if SkRRect equals dst.
example: https://fiddle.skia.org/c/@RRect_transform
Definition at line 436 of file SkRRect.cpp.
|
inline |
|
inline |
size_t SkRRect::writeToMemory | ( | void * | buffer | ) | const |
Writes SkRRect to buffer. Writes kSizeInMemory bytes, and returns kSizeInMemory, the number of bytes written.
buffer | storage for SkRRect |
example: https://fiddle.skia.org/c/@RRect_writeToMemory
Definition at line 599 of file SkRRect.cpp.
Returns true if bounds and radii in a are not equal to bounds and radii in b.
a and b are not equal if either contain NaN. a and b are equal if members contain zeroes with different signs.
Definition at line 303 of file SkRRect.h.
Returns true if bounds and radii in a are equal to bounds and radii in b.
a and b are not equal if either contain NaN. a and b are equal if members contain zeroes with different signs.
|
friend |
|
staticconstexpr |