roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
roo_display::Box Class Reference

Axis-aligned integer rectangle. More...

#include <box.h>

Public Types

enum class  ClipResult { kEmpty = 0 , kReduced , kUnchanged }
 Result of clipping a box to a clip region. More...
 

Public Member Functions

constexpr Box (int16_t xMin, int16_t yMin, int16_t xMax, int16_t yMax)
 Construct a box from inclusive coordinates.
 
 Box (const Box &)=default
 
 Box (Box &&)=default
 
 Box ()=default
 
Boxoperator= (const Box &)=default
 
Boxoperator= (Box &&)=default
 
bool empty () const
 Return whether the box is empty.
 
int16_t xMin () const
 Minimum x (inclusive).
 
int16_t yMin () const
 Minimum y (inclusive).
 
int16_t xMax () const
 Maximum x (inclusive).
 
int16_t yMax () const
 Maximum y (inclusive).
 
int16_t width () const
 Width in pixels (inclusive coordinates).
 
int16_t height () const
 Height in pixels (inclusive coordinates).
 
int32_t area () const
 Area in pixels.
 
bool contains (int16_t x, int16_t y) const
 Return whether the point (x, y) lies within the box.
 
bool contains (const Box &other) const
 Return whether this box fully contains the other box.
 
bool intersects (const Box &other) const
 Return whether this box intersects the other box.
 
ClipResult clip (const Box &clip_box)
 Clip this box to the given clip box.
 
Box translate (int16_t x_offset, int16_t y_offset) const
 Return a translated copy of this box.
 
Box scale (int16_t x_scale, int16_t y_scale) const
 Return a scaled copy of this box.
 
Box swapXY () const
 Return a copy with x and y axes swapped.
 
Box flipX () const
 Return a copy mirrored across the Y-axis.
 
Box flipY () const
 Return a copy mirrored across the X-axis.
 
Box rotateUpsideDown () const
 Return a copy rotated 180 degrees around the origin.
 
Box rotateRight () const
 Return a copy rotated 90 degrees clockwise around the origin.
 
Box rotateLeft () const
 Return a copy rotated 90 degrees counter-clockwise around the origin.
 
Box extend (int16_t x, int16_t y)
 Return the minimal box containing this box and the given point.
 

Static Public Member Functions

static Box Intersect (const Box &a, const Box &b)
 Return the intersection of two boxes (may be empty).
 
static Box Extent (const Box &a, const Box &b)
 Return the smallest box that contains both input boxes.
 
static Box MaximumBox ()
 Return a large sentinel box used for unbounded extents.
 

Static Public Attributes

static constexpr ClipResult CLIP_RESULT_EMPTY = ClipResult::kEmpty
 
static constexpr ClipResult CLIP_RESULT_REDUCED = ClipResult::kReduced
 
static constexpr ClipResult CLIP_RESULT_UNCHANGED = ClipResult::kUnchanged
 

Detailed Description

Axis-aligned integer rectangle.

Coordinates are inclusive: width is xMax - xMin + 1.

Definition at line 12 of file box.h.

Member Enumeration Documentation

◆ ClipResult

Result of clipping a box to a clip region.

Enumerator
kEmpty 
kReduced 
kUnchanged 

Definition at line 15 of file box.h.

Constructor & Destructor Documentation

◆ Box() [1/4]

constexpr roo_display::Box::Box ( int16_t  xMin,
int16_t  yMin,
int16_t  xMax,
int16_t  yMax 
)
inlineconstexpr

Construct a box from inclusive coordinates.

If xMax < xMin or yMax < yMin, the box is made empty.

Definition at line 45 of file box.h.

◆ Box() [2/4]

roo_display::Box::Box ( const Box )
default

◆ Box() [3/4]

roo_display::Box::Box ( Box &&  )
default

◆ Box() [4/4]

Member Function Documentation

◆ area()

◆ clip()

ClipResult roo_display::Box::clip ( const Box clip_box)
inline

Clip this box to the given clip box.

Returns
Clip result indicating whether the box was reduced or emptied.

Definition at line 105 of file box.h.

References empty(), kEmpty, kReduced, kUnchanged, xMax(), xMin(), yMax(), and yMin().

Referenced by roo_display::Surface::clipToExtents().

◆ contains() [1/2]

bool roo_display::Box::contains ( const Box other) const
inline

Return whether this box fully contains the other box.

Definition at line 91 of file box.h.

◆ contains() [2/2]

◆ empty()

bool roo_display::Box::empty ( ) const
inline

◆ extend()

Box roo_display::Box::extend ( int16_t  x,
int16_t  y 
)
inline

Return the minimal box containing this box and the given point.

Definition at line 157 of file box.h.

References Box(), xMax(), xMin(), yMax(), and yMin().

◆ Extent()

static Box roo_display::Box::Extent ( const Box a,
const Box b 
)
inlinestatic

Return the smallest box that contains both input boxes.

Definition at line 34 of file box.h.

References Box(), xMax(), xMin(), yMax(), and yMin().

Referenced by roo_display::RasterizableStack::naturalExtents(), and roo_display::StreamableStack::naturalExtents().

◆ flipX()

Box roo_display::Box::flipX ( ) const
inline

Return a copy mirrored across the Y-axis.

Definition at line 142 of file box.h.

References Box().

Referenced by roo_display::Transformation::flipX().

◆ flipY()

Box roo_display::Box::flipY ( ) const
inline

Return a copy mirrored across the X-axis.

Definition at line 145 of file box.h.

References Box().

Referenced by roo_display::Transformation::flipY().

◆ height()

◆ Intersect()

◆ intersects()

bool roo_display::Box::intersects ( const Box other) const
inline

Return whether this box intersects the other box.

Definition at line 97 of file box.h.

◆ MaximumBox()

static Box roo_display::Box::MaximumBox ( )
inlinestatic

◆ operator=() [1/2]

Box & roo_display::Box::operator= ( Box &&  )
default

◆ operator=() [2/2]

Box & roo_display::Box::operator= ( const Box )
default

◆ rotateLeft()

Box roo_display::Box::rotateLeft ( ) const
inline

Return a copy rotated 90 degrees counter-clockwise around the origin.

Definition at line 154 of file box.h.

References Box().

Referenced by roo_display::Transformation::rotateLeft().

◆ rotateRight()

Box roo_display::Box::rotateRight ( ) const
inline

Return a copy rotated 90 degrees clockwise around the origin.

Definition at line 151 of file box.h.

References Box().

Referenced by roo_display::Transformation::rotateRight().

◆ rotateUpsideDown()

Box roo_display::Box::rotateUpsideDown ( ) const
inline

Return a copy rotated 180 degrees around the origin.

Definition at line 148 of file box.h.

References Box().

Referenced by roo_display::Transformation::rotateUpsideDown().

◆ scale()

Box roo_display::Box::scale ( int16_t  x_scale,
int16_t  y_scale 
) const
inline

Return a scaled copy of this box.

Definition at line 133 of file box.h.

References Box().

Referenced by roo_display::Transformation::scale().

◆ swapXY()

Box roo_display::Box::swapXY ( ) const
inline

Return a copy with x and y axes swapped.

Definition at line 139 of file box.h.

References Box().

Referenced by roo_display::Transformation::swapXY().

◆ translate()

◆ width()

◆ xMax()

◆ xMin()

int16_t roo_display::Box::xMin ( ) const
inline

Minimum x (inclusive).

Definition at line 65 of file box.h.

Referenced by roo_display::GlyphMetrics::bearingX(), roo_display::TouchCalibration::Calibrate(), clip(), roo_display::drawHLine(), roo_display::internal::TileBase::drawInternal(), roo_display::drawVLine(), extend(), Extent(), roo_display::BlendingFilter< Blender >::fill(), roo_display::RectUnionFilter::fill(), roo_display::ClipMaskFilter::fill(), roo_display::TransformedDisplayOutput::fill(), roo_display::ClippingBufferedHLineFiller::fillHLine(), roo_display::FrontToBackWriter::fillPixels(), roo_display::ClippingBufferedRectFiller::fillRect(), roo_display::FrontToBackWriter::fillRects(), roo_display::ClippingBufferedVLineFiller::fillVLine(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::get(), roo_display::FontMetrics::glyphXMin(), roo_display::GlyphMetrics::glyphXMin(), Intersect(), roo_display::ClipMask::isMasked(), roo_display::GlyphMetrics::lsb(), roo_display::internal::MakeSubRectangle(), roo_display::FontMetrics::minLsb(), roo_display::Offscreen< ColorMode, pixel_order, byte_order, pixels_per_byte, storage_type >::Offscreen(), roo_display::internal::Clipper< RawStreamable, RawStream, typename >::operator()(), roo_display::internal::RectFillerVisible< RawPixelStream >::operator()(), roo_display::operator==(), roo_display::RasterizableStack::readColorRect(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::readColorRect(), roo_display::RoundRectShadow::readColorRect(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::readColors(), roo_display::SimpleTiledRasterizable< Getter >::readColors(), roo_display::RoundRectShadow::RoundRectShadow(), roo_display::DisplayOutput::setAddress(), roo_display::FrontToBackWriter::setAddress(), roo_display::SubRectangle(), roo_display::Translation::transformExtents(), roo_display::Scaling::transformExtents(), roo_display::BlendingFilter< Blender >::write(), roo_display::RectUnionFilter::write(), roo_display::ClipMaskFilter::write(), roo_display::TransformedDisplayOutput::write(), roo_display::FrontToBackWriter::writePixels(), roo_display::ClippingBufferedRectWriter::writeRect(), roo_display::FrontToBackWriter::writeRects(), roo_display::internal::writeRectVisible(), roo_display::internal::writeRectVisibleOverBg(), and roo_display::internal::writeRectVisibleOverOpaqueBg().

◆ yMax()

◆ yMin()

int16_t roo_display::Box::yMin ( ) const
inline

Minimum y (inclusive).

Definition at line 68 of file box.h.

Referenced by roo_display::GlyphMetrics::bearingY(), roo_display::TouchCalibration::Calibrate(), clip(), roo_display::drawHLine(), roo_display::internal::TileBase::drawInternal(), roo_display::drawVLine(), extend(), Extent(), roo_display::ClippingBufferedHLineFiller::fillHLine(), roo_display::FrontToBackWriter::fillPixels(), roo_display::ClippingBufferedRectFiller::fillRect(), roo_display::FrontToBackWriter::fillRects(), roo_display::ClippingBufferedVLineFiller::fillVLine(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::get(), roo_display::GlyphMetrics::glyphYMax(), roo_display::FontMetrics::glyphYMin(), Intersect(), roo_display::ClipMask::isMasked(), roo_display::internal::MakeSubRectangle(), roo_display::Offscreen< ColorMode, pixel_order, byte_order, pixels_per_byte, storage_type >::Offscreen(), roo_display::internal::Clipper< RawStreamable, RawStream, typename >::operator()(), roo_display::internal::RectFillerVisible< RawPixelStream >::operator()(), roo_display::operator==(), roo_display::png_draw(), roo_display::RasterizableStack::readColorRect(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::readColorRect(), roo_display::RoundRectShadow::readColorRect(), roo_display::Raster< PtrTypeT, ColorModeT, pixel_order, byte_order >::readColors(), roo_display::SimpleTiledRasterizable< Getter >::readColors(), roo_display::RoundRectShadow::RoundRectShadow(), roo_display::DisplayOutput::setAddress(), roo_display::FrontToBackWriter::setAddress(), roo_display::SubRectangle(), roo_display::Translation::transformExtents(), roo_display::Scaling::transformExtents(), roo_display::FrontToBackWriter::writePixels(), roo_display::ClippingBufferedRectWriter::writeRect(), roo_display::FrontToBackWriter::writeRects(), roo_display::internal::writeRectVisible(), roo_display::internal::writeRectVisibleOverBg(), and roo_display::internal::writeRectVisibleOverOpaqueBg().

Field Documentation

◆ CLIP_RESULT_EMPTY

constexpr ClipResult roo_display::Box::CLIP_RESULT_EMPTY = ClipResult::kEmpty
staticconstexpr

Definition at line 18 of file box.h.

◆ CLIP_RESULT_REDUCED

constexpr ClipResult roo_display::Box::CLIP_RESULT_REDUCED = ClipResult::kReduced
staticconstexpr

Definition at line 20 of file box.h.

◆ CLIP_RESULT_UNCHANGED

constexpr ClipResult roo_display::Box::CLIP_RESULT_UNCHANGED = ClipResult::kUnchanged
staticconstexpr

Definition at line 22 of file box.h.


The documentation for this class was generated from the following file: