diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-11-30 10:00:15 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 12:07:45 +0100 |
commit | b2d698472b4c52161b4b57b76266f8951cf5eef0 (patch) | |
tree | 29fb7cf80e0ac0f5504830971c7f70f657e16392 | |
parent | 169beff21ef85e57da23fc870fd4e8b937e10ef3 (diff) | |
download | serenity-b2d698472b4c52161b4b57b76266f8951cf5eef0.zip |
LibGfx: Add a 'Point::absolute_relative_distance_to(Point)'
This is significantly more elegant than subtracting the points and
constructing another point from the abs() of their individual
components.
-rw-r--r-- | Libraries/LibGfx/Point.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Point.h b/Libraries/LibGfx/Point.h index 6357b9d2b7..3860358ae7 100644 --- a/Libraries/LibGfx/Point.h +++ b/Libraries/LibGfx/Point.h @@ -208,6 +208,11 @@ public: return sqrtf(powf(m_x - other.m_x, 2.0f) + powf(m_y - other.m_y, 2.0f)); } + Point absolute_relative_distance_to(const Point& other) const + { + return { abs(dx_relative_to(other)), abs(dy_relative_to(other)) }; + } + template<typename U> Point<U> to_type() const { |