![]() |
TGX 1.0.3
A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.
|
Generic 2D Box [specializations iBox2 , fBox2, dBox2]. More...
#include <Box2.h>
Public Member Functions | |
constexpr | Box2 () |
default constructor: the box content is undefined. | |
constexpr | Box2 (const T minx, const T maxx, const T miny, const T maxy) |
Constructor with explicit dimensions. | |
constexpr | Box2 (const Vec2< T > &P) |
Construct a box representing a single point. | |
Box2 (const Box2< T > &B)=default | |
default copy constructor. | |
Box2< T > & | operator= (const Box2< T > &B)=default |
default assignement operator. | |
template<typename U > | |
operator Box2< U > () | |
Explicit conversion to another box type. | |
operator Box2< typename DefaultFPType< T >::fptype > () | |
Implicit conversion to floating-point type. | |
constexpr bool | isEmpty () const |
Return true if the box is empty. | |
void | empty () |
Make the box empty. | |
T | lx () const |
Return the box width. More... | |
T | ly () const |
Return the box height. More... | |
bool | equals (const Box2< T > &B) const |
Return true if the boxes are equal. More... | |
bool | operator== (const Box2< T > &B) const |
Return true if the boxes are equal. More... | |
bool | contains (const Vec2< T > &v) const |
Return true if the box contains the point v. | |
bool | contains (const Box2< T > &B) const |
Return true if B is included in this box. More... | |
bool | operator>= (const Box2< T > &B) const |
Return true if B is included in this box. More... | |
bool | operator<= (const Box2< T > &B) const |
Return true if this box is included in B. More... | |
bool | operator> (const Box2< T > &B) const |
Return true if B is strictly included in this box (i.e. More... | |
bool | operator< (const Box2< T > &B) const |
Return true if this box is strictly included inside B (i.e. More... | |
Box2< T > | operator& (const Box2< T > &B) const |
Return the intersection of this box and B. More... | |
void | operator&= (const Box2< T > &B) |
Intersect this box with box B. More... | |
Box2< T > | operator| (const Box2< T > &B) const |
Return the smallest box containing both this box and B. | |
void | operator|= (const Box2< T > &B) |
Enlarge this box in order to contain B. | |
Box2< T > | operator| (const Vec2< T > &v) const |
Return the smallest box containing this box and point v. | |
void | operator|= (const Vec2< T > &v) |
Enlarge this box in order to contain point v. | |
void | operator+= (const Vec2< T > &V) |
Translate this box by a given vector. | |
Box2< T > | operator+ (const Vec2< T > &V) const |
Return this box translated by vector v. | |
void | operator-= (const Vec2< T > &V) |
Translate the box by a given vector (substracted) | |
Box2< T > | operator- (const Vec2< T > &V) const |
Return this box translated by v (substracted). | |
void | split (BoxSplit part) |
Split the box in half or quarter. More... | |
Box2< T > | getSplit (BoxSplit part) const |
Return the box splitted in half or quater. More... | |
Vec2< T > | getAnchor (Anchor anchor_pos) const |
Return the position of an anchor point inside this box. More... | |
Vec2< T > | center () const |
Return the position of the box center as a 2 dimensional vector. | |
template<typename Tfloat = DefaultFPType<T>> | |
Tfloat | ratio () const |
Return the aspect ratio of the box lx()/ly() . More... | |
void | zoomOut () |
Zoom outside the box (ie increase its size by 1/10th). More... | |
void | zoomIn () |
Zoom inside the box (ie decrease its size by 1/8th). More... | |
void | left () |
Move the box to the left by 1/10th of its width. More... | |
void | right () |
Move the box to the right by 1/10th of its width. More... | |
void | up () |
Move the box up by 1/10th of its height. More... | |
void | down () |
Move the box down by 1/10th of its height. More... | |
Box2< T > | getEnclosedWithSameRatioAs (const Box2< T > &B) const |
Return the largest box with the same ratio() as box B that is centered and enclosed inside this box. More... | |
Box2< T > | getEnclosingWithSameRatioAs (const Box2< T > &B) const |
Return the smallest box with the same ratio() as box B that contains this box in its center. More... | |
Public Attributes | |
T | minX |
min horizontal (X) value (inclusive) | |
T | maxX |
max horizontal (X) value (inclusive) | |
T | minY |
min vertical (Y) value (inclusive) | |
T | maxY |
max vertical (Y) value (inclusive) | |
Generic 2D Box [specializations iBox2 , fBox2, dBox2].
The class encapsulates of 4 public variables: minX
, maxX
, minY
, maxY
which delimit the 2 dimensional closed box: [minX, maxX] x [minY, maxY]
The box is empty if maxX
< minX
or if maxY
< minY
.
`T` | arithmetic type of the box (int , float ...) |
|
inline |
Return the box width.
T
is of floating point or integral type.T
is floating point, the method returns maxX - minX
. T
is integral, the method returns maxX - minX + 1
(number of horizontal points in the closed box).
|
inline |
Return the box height.
T
is of floating point or integral type.T
is floating point, the method returns maxY - minY
. T
is integral, the method returns maxY - minY + 1
(number of vertical points in the closed box). Return true if B is included in this box.
Return true if B is included in this box.
Return true if this box is included in B.
Return true if B is strictly included in this box (i.e.
contained but not equal).
Return true if this box is strictly included inside B (i.e.
contained but not equal).
Return the intersection of this box and B.
This may return an empty box.
Intersect this box with box B.
May create an empty box.
Split the box in half or quarter.
part | The part or the box to keep. See tgx::BoxSplit. |
Return the box splitted in half or quater.
part | The part or the box to keep. See tgx::BoxSplit. |
Return the position of an anchor point inside this box.
anchor_pos | Th anchor location, see |
|
inline |
|
inline |
Zoom outside the box (ie increase its size by 1/10th).
|
inline |
Zoom inside the box (ie decrease its size by 1/8th).
|
inline |
|
inline |
|
inline |
|
inline |
Box2< T > tgx::Box2< T >::getEnclosedWithSameRatioAs | ( | const Box2< T > & | B | ) | const |
Return the largest box with the same ratio()
as box B
that is centered and enclosed inside this box.
Box2< T > tgx::Box2< T >::getEnclosingWithSameRatioAs | ( | const Box2< T > & | B | ) | const |
Return the smallest box with the same ratio()
as box B
that contains this box in its center.