|
| SkRRect ()=default |
| Initializes bounds at (0, 0), the origin, with zero width and height. More...
|
|
| SkRRect (const SkRRect &rrect)=default |
| Initializes to copy of rrect bounds and corner radii. More...
|
|
SkRRect & | operator= (const SkRRect &rrect)=default |
| Copies rrect bounds and corner radii. More...
|
|
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 |
| Returns span on the x-axis. More...
|
|
SkScalar | height () const |
| Returns span on the y-axis. More...
|
|
SkVector | getSimpleRadii () const |
| Returns top-left corner radii. More...
|
|
void | setEmpty () |
| Sets bounds to zero width and height at (0, 0), the origin. More...
|
|
void | setRect (const SkRect &rect) |
| Sets bounds to sorted rect, and sets corner radii to zero. More...
|
|
void | setOval (const SkRect &oval) |
| Sets bounds to oval, x-axis radii to half oval.width(), and all y-axis radii to half oval.height(). More...
|
|
void | setRectXY (const SkRect &rect, SkScalar xRad, SkScalar yRad) |
| Sets to rounded rectangle with the same radii for all four corners. More...
|
|
void | setNinePatch (const SkRect &rect, SkScalar leftRad, SkScalar topRad, SkScalar rightRad, SkScalar bottomRad) |
| Sets bounds to rect. More...
|
|
void | setRectRadii (const SkRect &rect, const SkVector radii[4]) |
| Sets bounds to rect. More...
|
|
const SkRect & | rect () const |
| Returns bounds. More...
|
|
SkVector | radii (Corner corner) const |
| Returns scalar pair for radius of curve on x-axis and y-axis for one corner. More...
|
|
const SkRect & | getBounds () const |
| Returns bounds. More...
|
|
void | inset (SkScalar dx, SkScalar dy, SkRRect *dst) const |
| Copies SkRRect to dst, then insets dst bounds by dx and dy, and adjusts dst radii by dx and dy. More...
|
|
void | inset (SkScalar dx, SkScalar dy) |
| Insets bounds by dx and dy, and adjusts radii by dx and dy. More...
|
|
void | outset (SkScalar dx, SkScalar dy, SkRRect *dst) const |
| Outsets dst bounds by dx and dy, and adjusts radii by dx and dy. More...
|
|
void | outset (SkScalar dx, SkScalar dy) |
| Outsets bounds by dx and dy, and adjusts radii by dx and dy. More...
|
|
void | offset (SkScalar dx, SkScalar dy) |
| Translates SkRRect by (dx, dy). More...
|
|
SkRRect | makeOffset (SkScalar dx, SkScalar dy) const |
| Returns SkRRect translated by (dx, dy). More...
|
|
bool | contains (const SkRect &rect) const |
| Returns true if rect is inside the bounds and corner radii, and if SkRRect and rect are not empty. More...
|
|
bool | isValid () const |
| Returns true if bounds and radii values are finite and describe a SkRRect SkRRect::Type that matches getType(). More...
|
|
size_t | writeToMemory (void *buffer) const |
| Writes SkRRect to buffer. More...
|
|
size_t | readFromMemory (const void *buffer, size_t length) |
| Reads SkRRect from buffer, reading kSizeInMemory bytes. More...
|
|
bool | transform (const SkMatrix &matrix, SkRRect *dst) const |
| Transforms by SkRRect by matrix, storing result in dst. More...
|
|
void | dump (bool asHex) const |
| Writes text representation of SkRRect to standard output. More...
|
|
SkString | dumpToString (bool asHex) const |
|
void | dump () const |
| Writes text representation of SkRRect to standard output. More...
|
|
void | dumpHex () const |
| Writes text representation of SkRRect to standard output. More...
|
|
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.
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.
- Parameters
-
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.
- Parameters
-
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
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.
- Parameters
-
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.
- Parameters
-
dx | subtracted from rect().fLeft, and added to rect().fRight |
dy | subtracted from rect().fTop, and added to rect().fBottom |
dst | outset bounds and radii |
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.
- Parameters
-
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 |
void SkRRect::setRectRadii |
( |
const SkRect & |
rect, |
|
|
const SkVector |
radii[4] |
|
) |
| |
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.
- Parameters
-
rect | bounds of rounded rectangle |
radii | corner x-axis and y-axis radii |
example: https://fiddle.skia.org/c/@RRect_setRectRadii
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.
- Parameters
-
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