3 #include "ge211_forward.h" 4 #include "ge211_util.h" 18 struct Basic_dimensions
49 noexcept(is_nothrow_comparable<T>())
51 return a.width == b.width && a.height == b.height;
57 noexcept(is_nothrow_comparable<T>())
66 noexcept(has_nothrow_arithmetic<T>())
68 return {d1.width + d2.width, d1.height + d2.height};
75 noexcept(has_nothrow_arithmetic<T>())
77 return {d1.width - d2.width, d1.height - d2.height};
83 noexcept(has_nothrow_arithmetic<T>())
85 return {d1.width * s2, d1.height * s2};
91 noexcept(has_nothrow_arithmetic<T>())
103 class = std::enable_if_t<!std::is_same<T, double>::value,
void>>
105 noexcept(has_nothrow_arithmetic<T, double>())
107 return {
static_cast<T
>(d1.width * s2),
108 static_cast<T>(d1.height * s2)};
118 class = std::enable_if_t<!std::is_same<T, double>::value,
void>>
120 noexcept(has_nothrow_arithmetic<double, T>())
135 return {d1.width / s2, d1.height / s2};
145 class = std::enable_if_t<!std::is_same<T, double>::value,
void>>
149 return d1 * (1 / s2);
156 noexcept(has_nothrow_arithmetic<T>)
165 noexcept(has_nothrow_arithmetic<T>)
192 noexcept(has_nothrow_division<T>)
200 noexcept(has_nothrow_division<T, double>)
228 noexcept(is_nothrow_convertible<Coordinate>())
235 noexcept(is_nothrow_convertible<Coordinate>())
261 noexcept(has_nothrow_arithmetic<Coordinate>())
269 noexcept(has_nothrow_arithmetic<Coordinate>())
277 noexcept(has_nothrow_arithmetic<Coordinate>())
285 noexcept(has_nothrow_arithmetic<Coordinate>())
293 noexcept(has_nothrow_arithmetic<Coordinate>())
295 return {
x - dims.width,
y - dims.height};
301 noexcept(has_nothrow_arithmetic<Coordinate>())
303 return {
x + dims.width,
y - dims.height};
309 noexcept(has_nothrow_arithmetic<Coordinate>())
311 return {
x - dims.width,
y + dims.height};
317 noexcept(has_nothrow_arithmetic<Coordinate>())
319 return {
x + dims.width,
y + dims.height};
332 noexcept(is_nothrow_comparable<T>())
334 return p1.x == p2.x && p1.y == p2.y;
340 noexcept(is_nothrow_comparable<T>())
349 noexcept(has_nothrow_arithmetic<T>())
351 return p1.down_right_by(d2);
357 noexcept(has_nothrow_arithmetic<T>())
359 return p2.down_right_by(d1);
366 noexcept(has_nothrow_arithmetic<T>())
368 return p1.up_left_by(d2);
374 noexcept(has_nothrow_arithmetic<T>())
376 return {p1.x - p2.x, p1.y - p2.y};
382 noexcept(has_nothrow_arithmetic<T>())
390 noexcept(has_nothrow_arithmetic<T>())
425 noexcept(has_nothrow_arithmetic<Coordinate>())
427 return {tl.
x, tl.y, dims.width, dims.height};
433 noexcept(has_nothrow_arithmetic<Coordinate>())
441 noexcept(has_nothrow_arithmetic<Coordinate>())
449 noexcept(has_nothrow_arithmetic<Coordinate>())
457 noexcept(has_nothrow_arithmetic<Coordinate>())
509 iterator
begin()
const 522 friend detail::Render_sprite;
523 friend detail::Renderer;
526 operator SDL_Rect() const
530 result.x =
static_cast<int>(
x);
531 result.y =
static_cast<int>(
y);
532 result.w =
static_cast<int>(
width);
533 result.h =
static_cast<int>(
height);
546 const Basic_rectangle<T>& r2)
549 return r1.x == r2.x &&
551 r1.width == r2.width &&
552 r1.height == r2.height;
569 :
public std::iterator<
570 std::input_iterator_tag,
571 typename Basic_rectangle<T>::Position const >
590 if (++current_.y >= y_end_) {
592 current_.y = y_begin_;
599 iterator& operator--()
601 if (current_.y == y_begin_) {
612 iterator operator++(
int)
631 return **
this == *that;
637 return !(*
this == that);
Position bottom_right() const noexcept(has_nothrow_arithmetic< Coordinate >())
The position of the bottom right vertex.
static Basic_rectangle from_top_left(Position tl, Dimensions dims) noexcept(has_nothrow_arithmetic< Coordinate >())
Creates a Basic_rectangle given the position of its top left vertex and its dimensions.
static Basic_rectangle from_bottom_left(Position bl, Dimensions dims) noexcept(has_nothrow_arithmetic< Coordinate >())
Creates a Basic_rectangle given the position of its bottom left vertex and its dimensions.
Coordinate width
The width of the rectangle in pixels.
Basic_dimensions< T > operator/(Basic_dimensions< T > d1, T s2) noexcept(has_nothrow_division< double, T >())
Divides a Basic_dimensions by a T.
Basic_position up_right_by(Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is above and right of this position by the given dimensions.
bool operator!=(const Transform &t1, const Transform &t2) noexcept
Disequality for transforms.
An iterator over the Basic_position<T>s of a Basic_rectangle<T>.
Basic_dimensions< T > & operator/=(Basic_dimensions< T > &d1, T s2) noexcept(has_nothrow_division< T >)
Succinct Basic_dimensions-scalar division.
Basic_position< U > into() const noexcept(is_nothrow_convertible< Coordinate, U >())
Converts a Basic_position to another coordinate type.
Coordinate width
The width of the object.
Coordinate height
The height of the object.
Basic_dimensions< T > & operator-=(Basic_dimensions< T > &d1, Basic_dimensions< T > d2) noexcept(has_nothrow_arithmetic< T >)
Succinct Basic_dimensions subtraction.
constexpr bool has_nothrow_division()
Can types T and U be used for division without risk of an exception?
Basic_dimensions< U > into() const noexcept(is_nothrow_convertible< Coordinate, U >())
Converts a Basic_dimensions to another coordinate type.
constexpr bool has_nothrow_arithmetic()
Can types T and U be used for basic arithmetic (addition, subtraction, multiplication) without risk o...
The game engine namespace.
Position bottom_left() const noexcept(has_nothrow_arithmetic< Coordinate >())
The position of the bottom left vertex.
Basic_dimensions< Coordinate > Dimensions
A dimensions type having the same coordinate type as this position type.
T Coordinate
The coordinate type for the position.
Represents a positioned rectangle.
static Basic_rectangle from_top_right(Position tr, Dimensions dims) noexcept(has_nothrow_arithmetic< Coordinate >())
Creates a Basic_rectangle given the position of its top right vertex and its dimensions.
Basic_rectangle< int > Rectangle
Type alias for the most common use of Basic_rectangle, which is with a coordinate type of int...
static Basic_rectangle from_bottom_right(Position br, Dimensions dims) noexcept(has_nothrow_arithmetic< Coordinate >())
Creates a Basic_rectangle given the position of its bottom right vertex and its dimensions.
Dimensions dimensions() const noexcept(is_nothrow_convertible< Coordinate >())
The dimensions of the rectangle.
Basic_position(Coordinate x, Coordinate y) noexcept(is_nothrow_convertible< Coordinate >())
Constructs a position from the given x and y coordinates.
Coordinate height
The height of the rectangle in pixels.
Coordinate x
The x coordinate.
Coordinate y
The y coordiante.
Basic_dimensions< T > operator-(Basic_dimensions< T > d1, Basic_dimensions< T > d2) noexcept(has_nothrow_arithmetic< T >())
Subtracts two Basic_dimensionses. This is vector subtraction.
Basic_position down_by(Coordinate dy) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is below this position by the given amount.
bool operator==(const Transform &t1, const Transform &t2) noexcept
Equality for transforms.
T Coordinate
The coordinate type for the dimensions.
iterator begin() const
Returns an iterator to the top left corner of this rectangle.
Position top_left() const noexcept(has_nothrow_arithmetic< Coordinate >())
The position of the top left vertex.
A Sprite that renders as a solid circle.
Basic_dimensions< T > & operator*=(Basic_dimensions< T > &d1, T s2) noexcept(has_nothrow_arithmetic< T >)
Succinct Basic_dimensions-scalar multiplication.
Represents the dimensions of an object, or more generally, the displacement between two Basic_positio...
A position in the T-valued Cartesian plane.
Position center() const noexcept(has_nothrow_arithmetic< Coordinate >() &&has_nothrow_division< Coordinate, int >())
The position of the center of the rectangle.
Basic_position down_left_by(Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is below and left of this position by the given dimensions.
T Coordinate
The coordinate type for the rectangle.
Basic_dimensions< T > operator*(Basic_dimensions< T > d1, T s2) noexcept(has_nothrow_arithmetic< T >())
Multiplies a Basic_dimensions by a scalar.
Basic_position right_by(Coordinate dx) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is to the right of this position by the given amount.
static Basic_rectangle from_center(Position center, Dimensions dims) noexcept(has_nothrow_arithmetic< Coordinate >())
Creates a Basic_rectangle given the position of its center and its dimensions.
Basic_position up_by(Coordinate dy) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is above this position by the given amount.
Coordinate y
The y coordinate of the upper-left vertex.
Basic_position down_right_by(Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is below and right of this position by the given dimensions.
Basic_rectangle< U > into() const noexcept(is_nothrow_convertible< Coordinate, U >)
Converts a Basic_rectangle to another coordinate type.
Basic_position up_left_by(Dimensions dims) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is above and left of this position by the given dimensions.
constexpr bool is_nothrow_comparable()
Can type T be compared to itself without risk of an exception?
Position top_right() const noexcept(has_nothrow_arithmetic< Coordinate >())
The position of the top right vertex.
constexpr bool is_nothrow_convertible()
Can type T be converted to type U without risk of an exception?
Coordinate x
The x coordinate of the upper-left vertex.
Basic_dimensions< T > & operator+=(Basic_dimensions< T > &d1, Basic_dimensions< T > d2) noexcept(has_nothrow_arithmetic< T >)
Succinct Basic_dimensions addition.
Basic_position left_by(Coordinate dx) const noexcept(has_nothrow_arithmetic< Coordinate >())
Constructs the position that is to the left of this position by the given amount. ...
Basic_dimensions< T > operator+(Basic_dimensions< T > d1, Basic_dimensions< T > d2) noexcept(has_nothrow_arithmetic< T >())
Adds two Basic_dimensionses. This is vector addition.
iterator end() const
Returns an iterator one past the end of this rectangle.