diff options
author | crupest <crupest@outlook.com> | 2020-06-22 01:09:24 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-06-22 01:09:24 +0800 |
commit | 4f0a2f32c273780c32cc3937615c2a8bbd993aab (patch) | |
tree | 6e1f45447854a40fe2d16ef9bec79f3c0fef030a /include/cru/platform/GraphBase.hpp | |
parent | d86a71f79afe0e4dac768f61d6bff690567aca5b (diff) | |
download | cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.tar.gz cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.tar.bz2 cru-4f0a2f32c273780c32cc3937615c2a8bbd993aab.zip |
...
Diffstat (limited to 'include/cru/platform/GraphBase.hpp')
-rw-r--r-- | include/cru/platform/GraphBase.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/cru/platform/GraphBase.hpp b/include/cru/platform/GraphBase.hpp index af61eba3..0d4effd4 100644 --- a/include/cru/platform/GraphBase.hpp +++ b/include/cru/platform/GraphBase.hpp @@ -2,13 +2,17 @@ #include "cru/common/Base.hpp" #include <cstdint> +#include <limits> #include <optional> #include <utility> namespace cru::platform { +struct Size; + struct Point final { constexpr Point() = default; constexpr Point(const float x, const float y) : x(x), y(y) {} + explicit constexpr Point(const Size& size); float x = 0; float y = 0; @@ -34,11 +38,20 @@ struct Size final { constexpr Size() = default; constexpr Size(const float width, const float height) : width(width), height(height) {} + explicit constexpr Size(const Point& point) + : width(point.x), height(point.y) {} + + constexpr static Size Infinate() { + return Size{std::numeric_limits<float>::max(), + std::numeric_limits<float>::max()}; + } float width = 0; float height = 0; }; +constexpr Point::Point(const Size& size) : x(size.width), y(size.height) {} + constexpr Size operator+(const Size& left, const Size& right) { return Size(left.width + right.width, left.height + right.height); } @@ -88,6 +101,15 @@ struct Thickness final { float bottom; }; +constexpr Size operator+(const Size& size, const Thickness& thickness) { + return {size.width + thickness.left + thickness.right, + size.height + thickness.top + thickness.bottom}; +} + +constexpr Size operator+(const Thickness& thickness, const Size& size) { + return operator+(size, thickness); +} + constexpr bool operator==(const Thickness& left, const Thickness& right) { return left.left == right.left && left.top == right.top && left.right == right.right && left.bottom == right.bottom; |