SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
Rectangle.h
1#pragma once
2
3namespace spark::math
4{
5 template <typename T>
6 Rectangle<T>::Rectangle(const Vector2<T>& position, const Vector2<T>& extent)
7 : position(position)
8 , extent(extent) {}
9
10 template <typename T>
11 Rectangle<T>::Rectangle(T x, T y, T width, T height)
12 : position(x, y), extent(width, height) {}
13
14 template <typename T>
15 constexpr bool Rectangle<T>::operator==(const Rectangle& other) const noexcept
16 {
17 return position == other.position && extent == other.extent;
18 }
19
20 template <typename T>
21 constexpr bool Rectangle<T>::operator!=(const Rectangle& other) const noexcept
22 {
23 return !(*this == other);
24 }
26 template <typename T>
27 template <typename To>
29 {
30 return Rectangle<To>(position.template castTo<To>(), extent.template castTo<To>());
31 }
32}
Represents a rectangle in 2D space.
Definition Rectangle.h:15
constexpr Rectangle()=default
\brif Initializes a Rectangle with position and extent set to {0, 0}.
constexpr bool operator!=(const Rectangle &other) const noexcept
Compares two Rectangle for inequality.
Definition Rectangle.h:21
constexpr Rectangle< To > castTo() const
Casts the rectangle to a rectangle with a different component type.
Definition Rectangle.h:28
constexpr bool operator==(const Rectangle &other) const noexcept
Compares two Rectangle for equality.
Definition Rectangle.h:15
A vector with two components.
Definition Vector2.h:13