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

Geometric transformation: swap, scale, translate, rotate, clip. More...

#include <transformation.h>

Public Member Functions

 Transformation (bool xy_swap, int16_t x_scale, int16_t y_scale, int16_t y_offset, int16_t x_offset)
 Construct a transformation with swap, scale, and translation.
 
 Transformation (bool xy_swap, int16_t x_scale, int16_t y_scale, int16_t y_offset, int16_t x_offset, bool clipped, Box clip_rect)
 Construct a transformation with optional clip box.
 
 Transformation ()
 Identity transformation.
 
Transformation swapXY () const
 Swap x/y axes.
 
Transformation flipX () const
 Flip across the Y axis.
 
Transformation flipY () const
 Flip across the X axis.
 
Transformation scale (int16_t x_scale, int16_t y_scale) const
 Scale along both axes.
 
Transformation translate (int16_t x_offset, int16_t y_offset) const
 Translate by offsets.
 
Transformation clip (Box clip_box) const
 Intersect with a clip box.
 
Transformation rotateRight () const
 Rotate 90 degrees clockwise.
 
Transformation rotateLeft () const
 Rotate 90 degrees counter-clockwise.
 
Transformation rotateUpsideDown () const
 Rotate 180 degrees.
 
Transformation rotateClockwise (int turns) const
 Rotate clockwise by turns (multiples of 90 degrees).
 
Transformation rotateCounterClockwise (int turns) const
 Rotate counter-clockwise by turns (multiples of 90 degrees).
 
bool xy_swap () const
 Whether x/y axes are swapped.
 
int16_t x_scale () const
 X scale factor.
 
int16_t y_scale () const
 Y scale factor.
 
int16_t x_offset () const
 X translation.
 
int16_t y_offset () const
 Y translation.
 
bool clipped () const
 Whether clipping is enabled.
 
Box clip_box () const
 Effective clip box.
 
bool is_rescaled () const
 Returns true if scale differs from 1 on any axis.
 
bool is_abs_rescaled () const
 Returns true if scale differs from 1 or -1 on any axis.
 
bool is_translated () const
 Returns true if translation is non-zero.
 
void transformRectNoSwap (int16_t &x0, int16_t &y0, int16_t &x1, int16_t &y1) const
 Apply transformation to a rectangle without swapping input coordinates.
 
Box transformBox (Box in) const
 Apply the transformation to a box.
 
Box smallestEnclosingRect (const Box &rect) const
 Smallest rectangle in destination coordinates enclosing rect.
 
Box smallestBoundingRect () const
 Smallest bounding rect covering the clip box in destination coordinates.
 

Detailed Description

Geometric transformation: swap, scale, translate, rotate, clip.

Definition at line 9 of file transformation.h.

Constructor & Destructor Documentation

◆ Transformation() [1/3]

roo_display::Transformation::Transformation ( bool  xy_swap,
int16_t  x_scale,
int16_t  y_scale,
int16_t  y_offset,
int16_t  x_offset 
)

Construct a transformation with swap, scale, and translation.

Definition at line 7 of file transformation.cpp.

◆ Transformation() [2/3]

roo_display::Transformation::Transformation ( bool  xy_swap,
int16_t  x_scale,
int16_t  y_scale,
int16_t  y_offset,
int16_t  x_offset,
bool  clipped,
Box  clip_rect 
)

Construct a transformation with optional clip box.

Definition at line 17 of file transformation.cpp.

◆ Transformation() [3/3]

roo_display::Transformation::Transformation ( )

Identity transformation.

Definition at line 28 of file transformation.cpp.

Referenced by clip(), flipX(), flipY(), rotateLeft(), rotateRight(), rotateUpsideDown(), scale(), swapXY(), and translate().

Member Function Documentation

◆ clip()

Transformation roo_display::Transformation::clip ( Box  clip_box) const

Intersect with a clip box.

Definition at line 58 of file transformation.cpp.

References clip_box(), roo_display::Box::Intersect(), and Transformation().

◆ clip_box()

Box roo_display::Transformation::clip_box ( ) const
inline

Effective clip box.

Definition at line 59 of file transformation.h.

References roo_display::Box::MaximumBox().

Referenced by clip().

◆ clipped()

bool roo_display::Transformation::clipped ( ) const
inline

Whether clipping is enabled.

Definition at line 57 of file transformation.h.

◆ flipX()

Transformation roo_display::Transformation::flipX ( ) const

Flip across the Y axis.

Definition at line 35 of file transformation.cpp.

References roo_display::Box::flipX(), and Transformation().

◆ flipY()

Transformation roo_display::Transformation::flipY ( ) const

Flip across the X axis.

Definition at line 40 of file transformation.cpp.

References roo_display::Box::flipY(), and Transformation().

◆ is_abs_rescaled()

bool roo_display::Transformation::is_abs_rescaled ( ) const
inline

◆ is_rescaled()

◆ is_translated()

bool roo_display::Transformation::is_translated ( ) const
inline

◆ rotateClockwise()

Transformation roo_display::Transformation::rotateClockwise ( int  turns) const

Rotate clockwise by turns (multiples of 90 degrees).

Definition at line 79 of file transformation.cpp.

References rotateLeft(), rotateRight(), and rotateUpsideDown().

◆ rotateCounterClockwise()

Transformation roo_display::Transformation::rotateCounterClockwise ( int  turns) const

Rotate counter-clockwise by turns (multiples of 90 degrees).

Definition at line 93 of file transformation.cpp.

References rotateLeft(), rotateRight(), and rotateUpsideDown().

◆ rotateLeft()

Transformation roo_display::Transformation::rotateLeft ( ) const

Rotate 90 degrees counter-clockwise.

Definition at line 74 of file transformation.cpp.

References roo_display::Box::rotateLeft(), and Transformation().

Referenced by rotateClockwise(), and rotateCounterClockwise().

◆ rotateRight()

Transformation roo_display::Transformation::rotateRight ( ) const

Rotate 90 degrees clockwise.

Definition at line 69 of file transformation.cpp.

References roo_display::Box::rotateRight(), and Transformation().

Referenced by rotateClockwise(), and rotateCounterClockwise().

◆ rotateUpsideDown()

Transformation roo_display::Transformation::rotateUpsideDown ( ) const

Rotate 180 degrees.

Definition at line 64 of file transformation.cpp.

References roo_display::Box::rotateUpsideDown(), and Transformation().

Referenced by rotateClockwise(), and rotateCounterClockwise().

◆ scale()

Transformation roo_display::Transformation::scale ( int16_t  x_scale,
int16_t  y_scale 
) const

Scale along both axes.

Definition at line 45 of file transformation.cpp.

References roo_display::Box::scale(), Transformation(), x_scale(), and y_scale().

◆ smallestBoundingRect()

Box roo_display::Transformation::smallestBoundingRect ( ) const

Smallest bounding rect covering the clip box in destination coordinates.

Definition at line 169 of file transformation.cpp.

References roo_display::Box::MaximumBox(), and smallestEnclosingRect().

◆ smallestEnclosingRect()

Box roo_display::Transformation::smallestEnclosingRect ( const Box rect) const

Smallest rectangle in destination coordinates enclosing rect.

Definition at line 147 of file transformation.cpp.

References roo_display::floor_div().

Referenced by smallestBoundingRect().

◆ swapXY()

Transformation roo_display::Transformation::swapXY ( ) const

Swap x/y axes.

Definition at line 30 of file transformation.cpp.

References roo_display::Box::swapXY(), and Transformation().

◆ transformBox()

Box roo_display::Transformation::transformBox ( Box  in) const

◆ transformRectNoSwap()

void roo_display::Transformation::transformRectNoSwap ( int16_t x0,
int16_t y0,
int16_t x1,
int16_t y1 
) const

◆ translate()

Transformation roo_display::Transformation::translate ( int16_t  x_offset,
int16_t  y_offset 
) const

Translate by offsets.

Definition at line 51 of file transformation.cpp.

References Transformation(), roo_display::Box::translate(), x_offset(), and y_offset().

◆ x_offset()

◆ x_scale()

◆ xy_swap()

◆ y_offset()

◆ y_scale()


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