Inkscape
Vector Graphics Editor
|
Axis aligned, non-empty rectangle. More...
#include <rect.h>
Public Member Functions | |
Create rectangles. | |
Rect () | |
Create a rectangle that contains only the point at (0,0). | |
Rect (Interval const &a, Interval const &b) | |
Create a rectangle from X and Y intervals. | |
Rect (Point const &a, Point const &b) | |
Create a rectangle from two points. | |
Rect (Coord x0, Coord y0, Coord x1, Coord y1) | |
Rect (Base const &b) | |
Rect (IntRect const &ir) | |
Inspect dimensions. | |
bool | hasZeroArea (Coord eps=EPSILON) const |
Check whether the rectangle has zero area up to specified tolerance. | |
bool | isFinite () const |
Check whether the rectangle has finite area. | |
Coord | diameter () const |
Calculate the diameter of the smallest circle that would contain the rectangle. | |
Test other rectangles and points for inclusion. | |
bool | interiorIntersects (Rect const &r) const |
Check whether the interiors of the rectangles have any common points. | |
bool | interiorContains (Point const &p) const |
Check whether the interior includes the given point. | |
bool | interiorContains (Rect const &r) const |
Check whether the interior includes all points in the given rectangle. | |
bool | interiorContains (OptRect const &r) const |
Rounding to integer coordinates | |
IntRect | roundOutwards () const |
Return the smallest integer rectangle which contains this one. | |
OptIntRect | roundInwards () const |
Return the largest integer rectangle which is contained in this one. | |
Return an expanded or shrunk copy of the rectangle. | |
Rect | expandedBy (Coord amount) const |
Return a new rectangle which results from expanding this one by the same amount along both axes. | |
Rect | expandedBy (Coord x, Coord y) const |
Return a new rectangle which results from expanding this one by possibly different amounts along both axes. | |
Rect | shrunkBy (Coord amount) const |
Return a new rectangle which results from shrinking this one by the same amount along both axes. | |
Rect | shrunkBy (Coord x, Coord y) const |
Return a new rectangle which results from shrinking this one by possibly different amounts along both axes. | |
SVG viewbox functionality. | |
Affine | transformTo (Rect const &viewport, Aspect const &aspect=Aspect()) const |
Transform contents to viewport. | |
Operators | |
Rect & | operator*= (Affine const &m) |
Transform the rectangle by an affine. | |
bool | operator== (IntRect const &ir) const |
bool | operator== (Rect const &other) const |
![]() | |
CInterval & | operator[] (unsigned i) |
CInterval const & | operator[] (unsigned i) const |
CInterval & | operator[] (Dim2 d) |
CInterval const & | operator[] (Dim2 d) const |
CPoint | min () const |
Get the corner of the rectangle with smallest coordinate values. | |
CPoint | max () const |
Get the corner of the rectangle with largest coordinate values. | |
CPoint | corner (unsigned i) const |
Return the n-th corner of the rectangle. | |
Coord | top () const |
Return top coordinate of the rectangle (+Y is downwards). | |
Coord | bottom () const |
Return bottom coordinate of the rectangle (+Y is downwards). | |
Coord | left () const |
Return leftmost coordinate of the rectangle (+X is to the right). | |
Coord | right () const |
Return rightmost coordinate of the rectangle (+X is to the right). | |
Coord | width () const |
Get the horizontal extent of the rectangle. | |
Coord | height () const |
Get the vertical extent of the rectangle. | |
Coord | aspectRatio () const |
Get the ratio of width to height of the rectangle. | |
CPoint | dimensions () const |
Get rectangle's width and height as a point. | |
CPoint | midpoint () const |
Get the point in the geometric center of the rectangle. | |
Coord | area () const |
Compute the rectangle's area. | |
bool | hasZeroArea () const |
Check whether the rectangle has zero area. | |
Coord | maxExtent () const |
Get the larger extent (width or height) of the rectangle. | |
Coord | minExtent () const |
Get the smaller extent (width or height) of the rectangle. | |
Coord | distanceSq (CPoint const &p) const |
Get rectangle's distance SQUARED away from the given point. | |
CPoint | clamp (CPoint const &p) const |
Clamp point to the rectangle. | |
CPoint | nearestEdgePoint (CPoint const &p) const |
Get the nearest point on the edge of the rectangle. | |
bool | intersects (GenericRect< Coord > const &r) const |
Check whether the rectangles have any common points. | |
bool | intersects (OptCRect const &r) const |
Check whether the rectangles have any common points. | |
bool | contains (GenericRect< Coord > const &r) const |
Check whether the rectangle includes all points in the given rectangle. | |
bool | contains (OptCRect const &r) const |
Check whether the rectangle includes all points in the given rectangle. | |
bool | contains (CPoint const &p) const |
Check whether the given point is within the rectangle. | |
void | setLeft (Coord val) |
Set the minimum X coordinate of the rectangle. | |
void | setRight (Coord val) |
Set the maximum X coordinate of the rectangle. | |
void | setTop (Coord val) |
Set the minimum Y coordinate of the rectangle. | |
void | setBottom (Coord val) |
Set the maximum Y coordinate of the rectangle. | |
void | setMin (CPoint const &p) |
Set the upper left point of the rectangle. | |
void | setMax (CPoint const &p) |
Set the lower right point of the rectangle. | |
void | expandTo (CPoint const &p) |
Enlarge the rectangle to contain the given point. | |
void | unionWith (CRect const &b) |
Enlarge the rectangle to contain the argument. | |
void | unionWith (OptCRect const &b) |
Enlarge the rectangle to contain the argument. | |
void | expandBy (Coord amount) |
Expand the rectangle in both directions by the specified amount. | |
void | expandBy (Coord x, Coord y) |
Expand the rectangle in both directions. | |
void | expandBy (CPoint const &p) |
Expand the rectangle by the coordinates of the given point. | |
void | shrinkBy (Coord amount) |
Shrink the rectangle in both directions by the specified amount. | |
void | shrinkBy (Coord x, Coord y) |
Shrink the rectangle in both directions by possibly different amounts. | |
GenericRect< Coord > & | operator+= (CPoint const &p) |
Offset the rectangle by a vector. | |
GenericRect< Coord > & | operator-= (CPoint const &p) |
Offset the rectangle by the negation of a vector. | |
GenericRect< Coord > & | operator|= (CRect const &o) |
Union two rectangles. | |
GenericRect< Coord > & | operator|= (OptCRect const &o) |
bool | operator== (CRect const &o) const |
Test for equality of rectangles. | |
GenericRect ()=default | |
Create a rectangle that contains only the point at (0, 0). | |
GenericRect (CInterval const &a, CInterval const &b) | |
Create a rectangle from X and Y intervals. | |
GenericRect (CPoint const &a, CPoint const &b) | |
Create a rectangle from two points. | |
GenericRect (Coord x0, Coord y0, Coord x1, Coord y1) | |
Create rectangle from coordinates of two points. | |
Private Types | |
typedef GenericRect< Coord > | Base |
Related Symbols | |
(Note that these are not member symbols.) | |
Coord | distance (Point const &p, Rect const &rect) |
Returns the smallest distance between p and rect. | |
Additional Inherited Members | |
![]() | |
using | D1Value = CInterval |
using | D1Reference = CInterval & |
using | D1ConstReference = CInterval const & |
![]() | |
static CRect | from_range (InputIterator start, InputIterator end) |
Create a rectangle from a range of points. | |
static CRect | from_array (CPoint const *c, unsigned n) |
Create a rectangle from a C-style array of points it should contain. | |
static CRect | from_xywh (Coord x, Coord y, Coord w, Coord h) |
Create rectangle from origin and dimensions. | |
static CRect | from_xywh (CPoint const &xy, CPoint const &wh) |
Create rectangle from origin and dimensions. | |
static CRect | infinite () |
Create infinite rectangle. | |
![]() | |
CInterval | f [2] |
|
private |
|
inline |
|
inline |
Calculate the diameter of the smallest circle that would contain the rectangle.
Definition at line 117 of file rect.h.
References Geom::GenericRect< Coord >::corner(), and distance().
Check whether the rectangle has zero area up to specified tolerance.
eps | Maximum value of the area to consider empty |
Definition at line 113 of file rect.h.
References Geom::GenericRect< Coord >::area().
Referenced by Inkscape::UI::Dialog::Export::exportRaster(), Inkscape::UI::Tools::fit_item(), SPItem::getCenter(), Inkscape::UI::Dialog::ExportPreview::setBox(), SPItem::setCenter(), sp_export_png_file(), and sp_generate_internal_bitmap().
|
inline |
Definition at line 240 of file rect.h.
References interiorContains().
|
inline |
Check whether the interior includes the given point.
Definition at line 127 of file rect.h.
References Geom::GenericRect< Coord >::f, Geom::X, and Geom::Y.
Referenced by interiorContains(), wrap_interiorContains_coord(), and wrap_interiorContains_ivl().
|
inline |
Check whether the interior includes all points in the given rectangle.
Interior of the rectangle is the entire rectangle without its borders.
Definition at line 132 of file rect.h.
References Geom::GenericRect< Coord >::f, Geom::X, and Geom::Y.
|
inline |
Check whether the interiors of the rectangles have any common points.
Definition at line 123 of file rect.h.
References Geom::GenericRect< Coord >::f, Geom::X, and Geom::Y.
|
inline |
Transform the rectangle by an affine.
The result of the transformation might not be axis-aligned. The return value of this operation will be the smallest axis-aligned rectangle containing all points of the true result.
Definition at line 87 of file rect.cpp.
References Geom::GenericRect< Coord >::corner(), Geom::GenericRect< Coord >::f, Geom::X, and Geom::Y.
|
inline |
Definition at line 188 of file rect.h.
References Geom::GenericRect< Coord >::f, Geom::X, and Geom::Y.
|
inline |
Definition at line 191 of file rect.h.
References Geom::GenericRect< Coord >::operator==().
|
inline |
Return the largest integer rectangle which is contained in this one.
Definition at line 146 of file rect.h.
References Geom::GenericRect< Coord >::f, roundInwards(), Geom::X, and Geom::Y.
Referenced by roundInwards(), and Geom::TEST().
|
inline |
Return the smallest integer rectangle which contains this one.
Definition at line 141 of file rect.h.
References Geom::GenericRect< Coord >::f, roundOutwards(), Geom::X, and Geom::Y.
Referenced by Inkscape::CanvasItemText::_update(), Inkscape::DrawingImage::_updateItem(), Inkscape::DrawingGlyphs::_updateItem(), SPMeshNodeArray::color_pick(), SPImage::cropToArea(), InkFileExportCmd::do_export_png(), Inkscape::UI::Tools::fit_item(), Inkscape::Filters::FilterUnits::get_pixblock_filterarea_paraller(), Inkscape::UI::Preview::render_preview(), roundOutwards(), and Geom::TEST().
Return a new rectangle which results from shrinking this one by the same amount along both axes.
Definition at line 144 of file rect.cpp.
Referenced by Inkscape::UI::Widget::ColorPlate::get_area(), Inkscape::UI::Widget::round_rect(), and Inkscape::Util::rounded_rectangle().
Transform contents to viewport.
Computes an affine that transforms the contents of this rectangle to the specified viewport. The aspect parameter specifies how to to the transformation (whether the aspect ratio of content should be kept and where it should be placed in the viewport).
Definition at line 99 of file rect.cpp.
References Geom::Aspect::align, Geom::align_factors(), Geom::ALIGN_NONE, Geom::GenericRect< Coord >::dimensions(), Geom::GenericRect< C >::dimensions(), Geom::Aspect::expansion, Geom::EXPANSION_MEET, Geom::GenericRect< C >::min(), Geom::GenericRect< Coord >::min(), offset, scale, Geom::X, and Geom::Y.
Returns the smallest distance between p and rect.
Definition at line 176 of file rect.cpp.
References Geom::GenericRect< C >::bottom(), Geom::GenericRect< C >::left(), Geom::GenericRect< C >::right(), Geom::GenericRect< C >::top(), Geom::X, and Geom::Y.
Referenced by diameter().