Flutter Engine
The Flutter Engine
|
#include <SkRect.h>
Public Member Functions | |
bool | contains (SkScalar x, SkScalar y) const |
bool | isEmpty () const |
bool | isSorted () const |
bool | isFinite () const |
constexpr float | x () const |
constexpr float | y () const |
constexpr float | left () const |
constexpr float | top () const |
constexpr float | right () const |
constexpr float | bottom () const |
constexpr float | width () const |
constexpr float | height () const |
constexpr float | centerX () const |
constexpr float | centerY () const |
constexpr SkPoint | center () const |
void | toQuad (SkPoint quad[4]) const |
void | setEmpty () |
void | set (const SkIRect &src) |
void | setLTRB (float left, float top, float right, float bottom) |
void | setBounds (const SkPoint pts[], int count) |
bool | setBoundsCheck (const SkPoint pts[], int count) |
void | setBoundsNoCheck (const SkPoint pts[], int count) |
void | set (const SkPoint &p0, const SkPoint &p1) |
void | setXYWH (float x, float y, float width, float height) |
void | setWH (float width, float height) |
void | setIWH (int32_t width, int32_t height) |
constexpr SkRect | makeOffset (float dx, float dy) const |
constexpr SkRect | makeOffset (SkVector v) const |
SkRect | makeInset (float dx, float dy) const |
SkRect | makeOutset (float dx, float dy) const |
void | offset (float dx, float dy) |
void | offset (const SkPoint &delta) |
void | offsetTo (float newX, float newY) |
void | inset (float dx, float dy) |
void | outset (float dx, float dy) |
bool | intersect (const SkRect &r) |
bool | intersect (const SkRect &a, const SkRect &b) |
bool | intersects (const SkRect &r) const |
void | join (const SkRect &r) |
void | joinNonEmptyArg (const SkRect &r) |
void | joinPossiblyEmptyRect (const SkRect &r) |
bool | contains (float x, float y) const |
bool | contains (const SkRect &r) const |
bool | contains (const SkIRect &r) const |
void | round (SkIRect *dst) const |
void | roundOut (SkIRect *dst) const |
void | roundOut (SkRect *dst) const |
void | roundIn (SkIRect *dst) const |
SkIRect | round () const |
SkIRect | roundOut () const |
SkIRect | roundIn () const |
void | sort () |
SkRect | makeSorted () const |
const float * | asScalars () const |
void | dump (bool asHex) const |
void | dump () const |
void | dumpHex () const |
Static Public Member Functions | |
static constexpr SkRect | MakeEmpty () |
static constexpr SkRect | MakeWH (float w, float h) |
static SkRect | MakeIWH (int w, int h) |
static constexpr SkRect | MakeSize (const SkSize &size) |
static constexpr SkRect | MakeLTRB (float l, float t, float r, float b) |
static constexpr SkRect | MakeXYWH (float x, float y, float w, float h) |
static SkRect | Make (const SkISize &size) |
static SkRect | Make (const SkIRect &irect) |
static bool | Intersects (const SkRect &a, const SkRect &b) |
Public Attributes | |
SkScalar | fLeft |
smaller x-axis bounds More... | |
SkScalar | fTop |
smaller y-axis bounds More... | |
SkScalar | fRight |
larger x-axis bounds More... | |
SkScalar | fBottom |
larger y-axis bounds More... | |
float | fLeft = 0 |
smaller x-axis bounds More... | |
float | fTop = 0 |
smaller y-axis bounds More... | |
float | fRight = 0 |
larger x-axis bounds More... | |
float | fBottom = 0 |
larger y-axis bounds More... | |
Friends | |
bool | operator== (const SkRect &a, const SkRect &b) |
bool | operator!= (const SkRect &a, const SkRect &b) |
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle. SkRect may be created from outer bounds or from position, width, and height. SkRect describes an area; if its right is less than or equal to its left, or if its bottom is less than or equal to its top, it is considered empty.
Definition at line 13 of file extension.cpp.
|
inline |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Returns average of left edge and right edge. Result does not change if SkRect is sorted. Result may overflow to infinity if SkRect is far from the origin.
Definition at line 776 of file SkRect.h.
|
inlineconstexpr |
|
inline |
Returns true if SkRect contains r. Returns false if SkRect is empty or r is empty.
SkRect contains r when SkRect area completely includes r area.
r | SkIRect contained |
Definition at line 1215 of file SkRect.h.
|
inline |
|
inline |
|
inline |
void SkRect::dump | ( | bool | asHex | ) | const |
Writes text representation of SkRect to standard output. Set asHex to 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/@Rect_dump
Definition at line 152 of file SkRect.cpp.
|
inline |
Writes text representation of SkRect 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 SkRect.
Use instead of dump() when submitting
Definition at line 1365 of file SkRect.h.
|
inlineconstexpr |
|
inline |
Insets SkRect by (dx, dy).
If dx is positive, makes SkRect narrower. If dx is negative, makes SkRect wider. If dy is positive, makes SkRect shorter. If dy is negative, makes SkRect taller.
dx | added to fLeft and subtracted from fRight |
dy | added to fTop and subtracted from fBottom |
Definition at line 1060 of file SkRect.h.
Returns true if a intersects b, and sets SkRect to intersection. Returns false if a does not intersect b, and leaves SkRect unchanged.
Returns false if either a or b is empty, leaving SkRect unchanged.
Definition at line 120 of file SkRect.cpp.
bool SkRect::intersect | ( | const SkRect & | r | ) |
Returns true if SkRect intersects r, and sets SkRect to intersection. Returns false if SkRect does not intersect r, and leaves SkRect unchanged.
Returns false if either r or SkRect is empty, leaving SkRect unchanged.
r | limit of result |
example: https://fiddle.skia.org/c/@Rect_intersect
Definition at line 114 of file SkRect.cpp.
Returns true if a intersects b. Returns false if either a or b is empty, or do not intersect.
|
inline |
|
inline |
|
inline |
|
inline |
void SkRect::join | ( | const SkRect & | r | ) |
Sets SkRect to the union of itself and r.
Has no effect if r is empty. Otherwise, if SkRect is empty, sets SkRect to r.
r | expansion SkRect |
example: https://fiddle.skia.org/c/@Rect_join_2
Definition at line 126 of file SkRect.cpp.
|
inline |
Sets SkRect to the union of itself and r.
Asserts if r is empty and SK_DEBUG is defined. If SkRect is empty, sets SkRect to r.
May produce incorrect results if r is empty.
r | expansion SkRect |
Definition at line 1158 of file SkRect.h.
|
inline |
|
inlineconstexpr |
Returns constructed SkIRect set to irect, promoting integers to float. Does not validate input; fLeft may be greater than fRight, fTop may be greater than fBottom.
irect | integer unsorted bounds |
Returns constructed SkIRect set to (0, 0, size.width(), size.height()). Does not validate input; size.width() or size.height() may be negative.
size | integer values for SkRect width and height |
Definition at line 669 of file SkRect.h.
|
inlinestaticconstexpr |
Returns constructed SkRect set to (0, 0, 0, 0). Many other rectangles are empty; if left is equal to or greater than right, or if top is equal to or greater than bottom. Setting all members to zero is a convenience, but does not designate a special empty rectangle.
|
inline |
Returns SkRect, inset by (dx, dy).
If dx is negative, SkRect returned is wider. If dx is positive, SkRect returned is narrower. If dy is negative, SkRect returned is taller. If dy is positive, SkRect returned is shorter.
dx | added to fLeft and subtracted from fRight |
dy | added to fTop and subtracted from fBottom |
Definition at line 987 of file SkRect.h.
Returns constructed SkRect set to integer values (0, 0, w, h). Does not validate input; w or h may be negative.
Use to avoid a compiler warning that input may lose precision when stored. Use SkIRect for an exact integer rectangle.
Definition at line 623 of file SkRect.h.
|
inlinestaticconstexpr |
|
inlineconstexpr |
Returns SkRect offset by (dx, dy).
If dx is negative, SkRect returned is moved to the left. If dx is positive, SkRect returned is moved to the right. If dy is negative, SkRect returned is moved upward. If dy is positive, SkRect returned is moved downward.
dx | added to fLeft and fRight |
dy | added to fTop and fBottom |
|
inline |
Returns SkRect, outset by (dx, dy).
If dx is negative, SkRect returned is narrower. If dx is positive, SkRect returned is wider. If dy is negative, SkRect returned is shorter. If dy is positive, SkRect returned is taller.
dx | subtracted to fLeft and added from fRight |
dy | subtracted to fTop and added from fBottom |
|
inline |
|
inlinestaticconstexpr |
|
inlinestaticconstexpr |
Returns constructed SkRect set to (x, y, x + w, y + h). Does not validate input; w or h may be negative.
x | stored in fLeft |
y | stored in fTop |
w | added to x and stored in fRight |
h | added to y and stored in fBottom |
|
inline |
Offsets SkRect by adding delta.fX to fLeft, fRight; and by adding delta.fY to fTop, fBottom.
If delta.fX is negative, moves SkRect to the left. If delta.fX is positive, moves SkRect to the right. If delta.fY is negative, moves SkRect upward. If delta.fY is positive, moves SkRect downward.
delta | added to SkRect |
Definition at line 1033 of file SkRect.h.
|
inline |
Offsets SkRect by adding dx to fLeft, fRight; and by adding dy to fTop, fBottom.
If dx is negative, moves SkRect to the left. If dx is positive, moves SkRect to the right. If dy is negative, moves SkRect upward. If dy is positive, moves SkRect downward.
dx | offset added to fLeft and fRight |
dy | offset added to fTop and fBottom |
|
inline |
Offsets SkRect so that fLeft equals newX, and fTop equals newY. width and height are unchanged.
|
inline |
Outsets SkRect by (dx, dy).
If dx is positive, makes SkRect wider. If dx is negative, makes SkRect narrower. If dy is positive, makes SkRect taller. If dy is negative, makes SkRect shorter.
dx | subtracted to fLeft and added from fRight |
dy | subtracted to fTop and added from fBottom |
Definition at line 1077 of file SkRect.h.
|
inlineconstexpr |
|
inline |
Returns SkIRect by adding 0.5 and discarding the fractional portion of SkRect members, using (sk_float_round2int(fLeft), sk_float_round2int(fTop), sk_float_round2int(fRight), sk_float_round2int(fBottom)).
|
inline |
Sets SkIRect by adding 0.5 and discarding the fractional portion of SkRect members, using (sk_float_round2int(fLeft), sk_float_round2int(fTop), sk_float_round2int(fRight), sk_float_round2int(fBottom)).
dst | storage for SkIRect |
Definition at line 1228 of file SkRect.h.
|
inline |
Sets SkIRect by rounding up fLeft and fTop; and discarding the fractional portion of fRight and fBottom, using (sk_float_ceil2int(fLeft), sk_float_ceil2int(fTop), sk_float_floor2int(fRight), sk_float_floor2int(fBottom)).
|
inline |
Sets SkRect by rounding up fLeft and fTop; and discarding the fractional portion of fRight and fBottom, using (sk_float_ceil2int(fLeft), sk_float_ceil2int(fTop), sk_float_floor2int(fRight), sk_float_floor2int(fBottom)).
dst | storage for SkIRect |
Definition at line 1266 of file SkRect.h.
|
inline |
Sets SkIRect by discarding the fractional portion of fLeft and fTop; and rounding up fRight and fBottom, using (sk_float_floor2int(fLeft), sk_float_floor2int(fTop), sk_float_ceil2int(fRight), sk_float_ceil2int(fBottom)).
|
inline |
Sets SkIRect by discarding the fractional portion of fLeft and fTop; and rounding up fRight and fBottom, using (sk_float_floor2int(fLeft), sk_float_floor2int(fTop), sk_float_ceil2int(fRight), sk_float_ceil2int(fBottom)).
dst | storage for SkIRect |
Definition at line 1241 of file SkRect.h.
|
inline |
|
inline |
Sets to bounds of SkPoint array with count entries. If count is zero or smaller, or if SkPoint array contains an infinity or NaN, sets to (0, 0, 0, 0).
Result is either empty or sorted: fLeft is less than or equal to fRight, and fTop is less than or equal to fBottom.
pts | SkPoint array |
count | entries in array |
Definition at line 881 of file SkRect.h.
Sets to bounds of SkPoint array with count entries. Returns false if count is zero or smaller, or if SkPoint array contains an infinity or NaN; in these cases sets SkRect to (0, 0, 0, 0).
Result is either empty or sorted: fLeft is less than or equal to fRight, and fTop is less than or equal to fBottom.
pts | SkPoint array |
count | entries in array |
example: https://fiddle.skia.org/c/@Rect_setBoundsCheck
Definition at line 61 of file SkRect.cpp.
Sets to bounds of SkPoint pts array with count entries. If any SkPoint in pts contains infinity or NaN, all SkRect dimensions are set to NaN.
pts | SkPoint array |
count | entries in array |
example: https://fiddle.skia.org/c/@Rect_setBoundsNoCheck
Definition at line 100 of file SkRect.cpp.
|
inline |
|
inline |
|
inline |
Sets SkRect to (left, top, right, bottom). left and right are not sorted; left is not necessarily less than right. top and bottom are not sorted; top is not necessarily less than bottom.
left | stored in fLeft |
top | stored in fTop |
right | stored in fRight |
bottom | stored in fBottom |
|
inline |
|
inline |
Sets SkRect to (x, y, x + width, y + height). Does not validate input; width or height may be negative.
x | stored in fLeft |
y | stored in fTop |
width | added to x and stored in fRight |
height | added to y and stored in fBottom |
|
inline |
|
inlineconstexpr |
void SkRect::toQuad | ( | SkPoint | quad[4] | ) | const |
Returns four points in quad that enclose SkRect ordered as: top-left, top-right, bottom-right, bottom-left.
TODO: Consider adding parameter to control whether quad is clockwise or counterclockwise.
quad | storage for corners of SkRect |
example: https://fiddle.skia.org/c/@Rect_toQuad
Definition at line 50 of file SkRect.cpp.
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
Returns true if any in a: fLeft, fTop, fRight, and fBottom; does not equal the corresponding members in b.
a and b are not equal if either contain NaN. a and b are equal if members contain zeroes with different signs.
Returns true if all members in a: fLeft, fTop, fRight, and fBottom; are equal to the corresponding members in b.
a and b are not equal if either contain NaN. a and b are equal if members contain zeroes with different signs.
SkScalar SkRect::fBottom |
larger y-axis bounds
Definition at line 17 of file extension.cpp.
SkScalar SkRect::fLeft |
smaller x-axis bounds
Definition at line 14 of file extension.cpp.
SkScalar SkRect::fRight |
larger x-axis bounds
Definition at line 16 of file extension.cpp.
SkScalar SkRect::fTop |
smaller y-axis bounds
Definition at line 15 of file extension.cpp.