Lines Matching refs:Rect
27 class Rect {
29 AI Rect() = default;
30 AI Rect(float l, float t, float r, float b) : fVals(NegateBotRight({l,t,r,b})) {}
31 AI Rect(float2 topLeft, float2 botRight) : fVals(topLeft, -botRight) {}
32 AI Rect(const SkRect& r) : fVals(NegateBotRight(float4::Load(r.asScalars()))) {}
34 AI static Rect XYWH(float x, float y, float w, float h) {
35 return Rect(x, y, x + w, y + h);
37 AI static Rect XYWH(float2 topLeft, float2 size) {
38 return Rect(topLeft, topLeft + size);
40 AI static Rect WH(float w, float h) {
41 return Rect(0, 0, w, h);
43 AI static Rect WH(float2 size) {
44 return Rect(float2(0), size);
46 AI static Rect Point(float2 p) {
47 return Rect(p, p);
49 AI static Rect FromVals(float4 vals) { // vals.zw must already be negated.
50 return Rect(vals);
53 // Constructs a Rect with ltrb = [-inf, -inf, inf, inf], useful for accumulating intersections
54 AI static Rect Infinite() {
57 // Constructs a negative Rect with ltrb = [inf, inf, -inf, -inf], useful for accumulating unions
58 AI static Rect InfiniteInverted() {
62 AI bool operator==(Rect rect) const { return all(fVals == rect.fVals); }
63 AI bool operator!=(Rect rect) const { return any(fVals != rect.fVals); }
111 AI ComplementRect(Rect rect) : fVals(-rect.fVals.zwxy()) {}
116 AI bool contains(Rect rect) const { return all(fVals <= rect.fVals); }
121 AI Rect makeRoundIn() const { return ceil(fVals); }
122 AI Rect makeRoundOut() const { return floor(fVals); }
123 AI Rect makeInset(float inset) const { return fVals + inset; }
124 AI Rect makeInset(float2 inset) const { return fVals + inset.xyxy(); }
125 AI Rect makeOutset(float outset) const { return fVals - outset; }
126 AI Rect makeOutset(float2 outset) const { return fVals - outset.xyxy(); }
127 AI Rect makeOffset(float2 offset) const { return fVals + float4(offset, -offset); }
128 AI Rect makeJoin(Rect rect) const { return min(fVals, rect.fVals); }
129 AI Rect makeIntersect(Rect rect) const { return max(fVals, rect.fVals); }
130 AI Rect makeSorted() const { return min(fVals, -fVals.zwxy()); }
132 AI Rect& roundIn() { return *this = this->makeRoundIn(); }
133 AI Rect& roundOut() { return *this = this->makeRoundOut(); }
134 AI Rect& inset(float inset) { return *this = this->makeInset(inset); }
135 AI Rect& inset(float2 inset) { return *this = this->makeInset(inset); }
136 AI Rect& outset(float outset) { return *this = this->makeOutset(outset); }
137 AI Rect& outset(float2 outset) { return *this = this->makeOutset(outset); }
138 AI Rect& offset(float2 offset) { return *this = this->makeOffset(offset); }
139 AI Rect& join(Rect rect) { return *this = this->makeJoin(rect); }
140 AI Rect& intersect(Rect rect) { return *this = this->makeIntersect(rect); }
141 AI Rect& sort() { return *this = this->makeSorted(); }
148 AI Rect(float4 vals) : fVals(vals) {} // vals.zw must already be negated.