89 for (
unsigned i=0; i<4; ++i) pts[i] =
corner(i) * m;
90 Coord minx = std::min(std::min(pts[0][
X], pts[1][
X]), std::min(pts[2][
X], pts[3][
X]));
91 Coord miny = std::min(std::min(pts[0][
Y], pts[1][
Y]), std::min(pts[2][
Y], pts[3][
Y]));
92 Coord maxx = std::max(std::max(pts[0][
X], pts[1][
X]), std::max(pts[2][
X], pts[3][
X]));
93 Coord maxy = std::max(std::max(pts[0][
Y], pts[1][
Y]), std::max(pts[2][
Y], pts[3][
Y]));
94 f[
X].setMin(minx);
f[
X].setMax(maxx);
95 f[
Y].setMin(miny);
f[
Y].setMax(maxy);
133 copy.expandBy(amount);
147 copy.shrinkBy(amount);
160 double dx = 0, dy = 0;
161 if ( p[
X] < rect.
left() ) {
162 dx = p[
X] - rect.
left();
163 }
else if ( p[
X] > rect.
right() ) {
166 if (p[
Y] < rect.
top() ) {
167 dy = rect.
top() - p[
Y];
168 }
else if ( p[
Y] > rect.
bottom() ) {
179 double dx = 0, dy = 0;
180 if ( p[
X] < rect.
left() ) {
181 dx = p[
X] - rect.
left();
182 }
else if ( p[
X] > rect.
right() ) {
185 if (p[
Y] < rect.
top() ) {
186 dy = rect.
top() - p[
Y];
187 }
else if ( p[
Y] > rect.
bottom() ) {
190 return hypot(dx, dy);
195 if (!rect)
return std::numeric_limits<Coord>::max();
200 if (!rect)
return std::numeric_limits<Coord>::max();
3x3 matrix representing an affine transformation.
C right() const
Return rightmost coordinate of the rectangle (+X is to the right).
C top() const
Return top coordinate of the rectangle (+Y is downwards).
C left() const
Return leftmost coordinate of the rectangle (+X is to the right).
CPoint min() const
Get the corner of the rectangle with smallest coordinate values.
C bottom() const
Return bottom coordinate of the rectangle (+Y is downwards).
CPoint dimensions() const
Get rectangle's width and height as a point.
CPoint corner(unsigned i) const
Return the n-th corner of the rectangle.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
Rect shrunkBy(Coord amount) const
Return a new rectangle which results from shrinking this one by the same amount along both axes.
Rect expandedBy(Coord amount) const
Return a new rectangle which results from expanding this one by the same amount along both axes.
Rect & operator*=(Affine const &m)
Transform the rectangle by an affine.
Affine transformTo(Rect const &viewport, Aspect const &aspect=Aspect()) const
Transform contents to viewport.
Coord distance(Point const &p, Rect const &rect)
Returns the smallest distance between p and rect.
double Coord
Floating point type used to store coordinates.
Various utility functions.
Coord distanceSq(Point const &p, Rect const &rect)
Angle distance(Angle const &a, Angle const &b)
Align
Values for the <align> parameter of preserveAspectRatio.
Point align_factors(Align align)
Convert an align specification to coordinate fractions.
Structure that specifies placement of within a viewport.