20template <
typename DataType>
23 if constexpr (std::is_unsigned_v<DataType>)
26 return value >= DataType {} ? value : -value;
31template <
typename DataType>
89 static_assert(std::is_signed_v<DataType>);
100 return std::abs(
width) <= std::numeric_limits<DataType>::epsilon() &&
101 std::abs(
height) <= std::numeric_limits<DataType>::epsilon();
106template <
typename To,
typename From>
109 return {
static_cast<To
>(point.
width),
static_cast<To
>(point.
height) };
112template <
typename DataType>
115 return lhs.width == rhs.width && lhs.height == rhs.height;
118template <
typename DataType>
121 return !(lhs == rhs);
124template <
typename DataType>
128 return { lhs.width + rhs.width, lhs.height + rhs.height };
131template <
typename DataType>
135 return { lhs.width - rhs.width, lhs.height - rhs.height };
138template <
typename DataType>
142 return { lhs.width * rhs.width, lhs.height * rhs.height };
145template <
typename DataType>
149 return { lhs.width / rhs.width, lhs.height / rhs.height };
152template <
typename DataType,
typename ScaleType>
155 return {
static_cast<DataType
>(lhs.width * rhs),
156 static_cast<DataType
>(lhs.height * rhs) };
159template <
typename DataType,
typename ScaleType>
162 return {
static_cast<DataType
>(lhs * rhs.width),
163 static_cast<DataType
>(lhs * rhs.height) };
166template <
typename DataType,
typename ScaleType>
169 return {
static_cast<DataType
>(lhs.width / rhs),
170 static_cast<DataType
>(lhs.height / rhs) };
constexpr DataType GetPositiveSizeValue(DataType value) noexcept
bool operator==(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator*(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator+(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator/(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
SizeType< To > size_cast(SizeType< From > point)
Casts size to another data type.
bool operator!=(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator-(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
A class that represents size in 2D space.
SizeType & operator/=(ScaleType scale) noexcept
SizeType & operator/=(SizeType rhs) noexcept
SizeType & operator+=(SizeType rhs) noexcept
SizeType & operator*=(SizeType rhs) noexcept
SizeType & operator-=(SizeType rhs) noexcept
SizeType & operator-() noexcept
bool IsZero() const noexcept
Return true if both width and height are zero.
SizeType & operator*=(ScaleType scale) noexcept