SkRRect related constants are defined by enum, enum class, #define, const, and constexpr.
SkRRect global, struct, and class related member functions share a topic.
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.
SkRRect can be constructed or initialized by these functions, including C++ class constructors.
SkRRect operators inline class member functions with arithmetic equivalents.
SkRRect member functions read and modify the structure properties.
Initializes bounds at (0, 0), the origin, with zero width and height. Initializes corner radii to (0, 0), and sets type of kEmpty Type.
empty Round Rect
setEmpty isEmpty
Initializes to copy of rrect bounds and corner radii.
copy of rrect
operator=(const SkRRect& rrect) MakeRect
Copies rrect bounds and corner radii.
copy of rrect
SkRRect(const SkRRect& rrect) MakeRect
Type describes possible specializations of Round Rect. Each Type is exclusive; a Round Rect may only have one type.
Type members become progressively less restrictive; larger values of Type have more degrees of freedom than smaller values.
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.
Rect Path
Returns Type, one of: kEmpty Type, kRect Type, kOval Type, kSimple Type, kNinePatch Type, kComplex Type.
Type
Type type
Returns Type, one of: kEmpty Type, kRect Type, kOval Type, kSimple Type, kNinePatch Type, kComplex Type.
Type
Type getType
Returns true if rect.fLeft is equal to rect.fRight, or if rect.fTop is equal to rect.fBottom.
true if width or height are zero
SkRect::isEmpty height width
Returns true if not empty, and if either x-axis or y-axis radius at each corner is zero.
true if not empty, and one radius at each corner is zero
isEmpty radii
Returns true if not empty, if all x-axis radii are equal, if all y-axis radii are equal, x-axis radii are at least half the width, and y-axis radii are at least half the height.
true if has identical geometry to Oval
isEmpty isSimple SkCanvas::drawOval
Returns true if not empty, if all x-axis radii are equal but not zero, if all y-axis radii are equal but not zero; and x-axis radius is less than half width, or y-axis radius is less than half height.
true if not empty, Rect or Oval; and axes radii are equal
isEmpty isRect isOval isNinePatch
Returns true if isEmpty, isRect, isOval, and isSimple return false; and if left x-axis radii are equal, right x-axis radii are equal, top y-axis radii are equal, and bottom y-axis radii are equal.
true if not empty, Rect, Oval or simple; and radii are axis-aligned
isEmpty isRect isOval isSimple isComplex
Returns true if isEmpty, isRect, isOval, isSimple, and isNinePatch return false. If true: width and height are greater than zero, at least one corner radii are both greater than zero; left x-axis radii are not equal, or right x-axis radii are not equal, or top y-axis radii are not equal, or bottom y-axis radii are not equal.
true if not empty, Rect, Oval, simple, or nine-patch
isEmpty isRect isOval isSimple isNinePatch
Returns span on the x-axis. This does not check if result fits in 32-bit float; result may be infinity.
bounds().fRight minus bounds().fLeft
unsorted width: 5 large width: inf
SkRect::width height getBounds
Returns span on the y-axis. This does not check if result fits in 32-bit float; result may be infinity.
bounds().fBottom minus bounds().fTop
unsorted height: 5 large height: inf
SkRect.height width getBounds
Returns top-left corner x-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.
corner radii for simple types
radii getBounds getType isSimple
Sets bounds to zero width and height at (0, 0), the origin. Sets corner radii to zero and sets type to kEmpty Type.
MakeEmpty setRect
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.
MakeRect setRectXY
Initializes bounds at (0, 0), the origin, with zero width and height. Initializes corner radii to (0, 0), and sets type of kEmpty Type.
empty Round Rect
SkRRect() SkRect::MakeEmpty
Initializes to copy of r bounds and zeroes corner radii.
copy of r
setRect MakeOval MakeRectXY
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
setOval MakeRect MakeRectXY
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.
rounded rectangle
setRectXY
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.
MakeOval
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.
MakeRectXY SkPath::addRoundRect[2]
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.
setRectRadii
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.
setNinePatch SkPath::addRoundRect[2]
The radii are stored: top-left, top-right, bottom-right, bottom-left.
radii
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.
bounding box
left bounds: (nan) 0 left bounds: (inf) 0 left bounds: (100) 60 left bounds: (50) 50 left bounds: (25) 25
getBounds
Returns Scalar pair for radius of curve on x-axis and y-axis for one corner. Both radii may be zero. If not zero, both are positive and finite.
x-axis and y-axis radii for one corner
left corner: (nan) 0 left corner: (inf) 0 left corner: (100) 25 left corner: (50) 25 left corner: (25) 12.5
Corner
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 rect.
bounding box
rect
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 width different signs.
true if members are equal
operator!=(const SkRRect& a, const SkRRect& b)
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 width different signs.
true if members are not equal
operator==(const SkRRect& a, const SkRRect& b)
Copies Round Rect 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 Round Rect.
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.
outset[2] offset makeOffset
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.
outset[2] offset makeOffset
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.
inset[2] offset makeOffset
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.
inset[2] offset makeOffset
Translates Round Rect by (dx, dy).
makeOffset inset[2] outset[2]
Returns Round Rect translated by (dx, dy).
Round Rect bounds offset by (dx, dy), with unchanged corner radii
offset inset[2] outset[2]
Returns true if rect is inside the bounds and corner radii, and if Round Rect and rect are not empty.
true if Round Rect contains rect
SkRect::contains[2][3]
Returns true if bounds and radii values are finite and describe a Round Rect Type that matches getType. All Round Rect methods construct valid types, even if the input values are not valid. Invalid Round Rect data can only be generated by corrupting memory.
true if bounds and radii match type
Type getType
Writes Round Rect to buffer. Writes kSizeInMemory bytes, and returns kSizeInMemory, the number of bytes written.
bytes written, kSizeInMemory
readFromMemory
Reads Round Rect from buffer, reading kSizeInMemory bytes. Returns kSizeInMemory, bytes read if length is at least kSizeInMemory. Otherwise, returns zero.
bytes read, or 0 if length is less than kSizeInMemory
writeToMemory
Transforms by Round Rect by matrix, storing result in dst. Returns true if Round Rect transformed can be represented by another Round Rect. Returns false if matrix contains transformations other than scale and translate.
Asserts in debug builds if Round Rect equals dst.
true if transformation succeeded.
SkPath::transform[2]
Writes text representation of Round Rect to standard output. Set asHex true to generate exact binary representations of floating point numbers.
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 */ };
dumpHex SkRect::dump[2] SkPath::dump[2] SkPathMeasure::dump
Writes text representation of Round Rect to standard output. The representation may be directly compiled as C++ code. Floating point values are written with limited precision; it may not be possible to reconstruct original Round Rect from output.
SkRect::MakeLTRB(0.857143f, 0.666667f, 0.857143f, 0.666667f); const SkPoint corners[] = { { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, }; rrect is not equal to copy
dumpHex SkRect::dump[2] SkPath::dump[2] SkPathMeasure::dump
Writes text representation of Round Rect to standard output. The representation may be directly compiled as C++ code. Floating point values are written in hexadecimal to preserve their exact bit pattern. The output reconstructs the original Round Rect.
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 */ }; rrect is equal to copy
dump[2] SkRect::dumpHex SkPath::dumpHex