summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-09-18 12:03:36 +0200
committerAndreas Kling <kling@serenityos.org>2021-09-18 12:21:42 +0200
commitf6a2d6af0b88e91c1512c88a1c2f15b0378d76f1 (patch)
tree530fcead6bd112f4ff5708015ef0645a5b00e61b
parent441e601689e9406c0dfea7dd67bc76c6919cbffd (diff)
downloadserenity-f6a2d6af0b88e91c1512c88a1c2f15b0378d76f1.zip
LibGfx: Add Point<T>::to_rounded<U>()
-rw-r--r--Userland/Libraries/LibGfx/Point.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h
index 7b9faebe16..88afb4147d 100644
--- a/Userland/Libraries/LibGfx/Point.h
+++ b/Userland/Libraries/LibGfx/Point.h
@@ -13,6 +13,7 @@
#include <LibGfx/Forward.h>
#include <LibGfx/Orientation.h>
#include <LibIPC/Forward.h>
+#include <math.h>
namespace Gfx {
@@ -239,6 +240,12 @@ public:
return Point<U>(*this);
}
+ template<typename U>
+ [[nodiscard]] Point<U> to_rounded() const
+ {
+ return Point<U>(roundf(x()), roundf(y()));
+ }
+
[[nodiscard]] String to_string() const;
private: