diff --git a/Userland/Libraries/LibGfx/Point.cpp b/Userland/Libraries/LibGfx/Point.cpp index 316f8d04df..c2cdf7fda8 100644 --- a/Userland/Libraries/LibGfx/Point.cpp +++ b/Userland/Libraries/LibGfx/Point.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -13,7 +13,7 @@ namespace Gfx { template -void Point::constrain(const Rect& rect) +void Point::constrain(Rect const& rect) { if (x() < rect.left()) { set_x(rect.left()); @@ -44,7 +44,7 @@ String FloatPoint::to_string() const namespace IPC { -bool encode(Encoder& encoder, const Gfx::IntPoint& point) +bool encode(Encoder& encoder, Gfx::IntPoint const& point) { encoder << point.x() << point.y(); return true; diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h index e6b239deef..4898361f5e 100644 --- a/Userland/Libraries/LibGfx/Point.h +++ b/Userland/Libraries/LibGfx/Point.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ @@ -36,7 +36,7 @@ public: } template - explicit Point(const Point& other) + explicit Point(Point const& other) : m_x(other.x()) , m_y(other.y()) { @@ -58,7 +58,7 @@ public: } ALWAYS_INLINE void translate_by(T dboth) { translate_by(dboth, dboth); } - ALWAYS_INLINE void translate_by(const Point& delta) { translate_by(delta.x(), delta.y()); } + ALWAYS_INLINE void translate_by(Point const& delta) { translate_by(delta.x(), delta.y()); } void scale_by(T dx, T dy) { @@ -67,11 +67,11 @@ public: } ALWAYS_INLINE void scale_by(T dboth) { scale_by(dboth, dboth); } - ALWAYS_INLINE void scale_by(const Point& delta) { scale_by(delta.x(), delta.y()); } + ALWAYS_INLINE void scale_by(Point const& delta) { scale_by(delta.x(), delta.y()); } - void transform_by(const AffineTransform& transform) { *this = transform.map(*this); } + void transform_by(AffineTransform const& transform) { *this = transform.map(*this); } - Point translated(const Point& delta) const + Point translated(Point const& delta) const { Point point = *this; point.translate_by(delta); @@ -92,7 +92,7 @@ public: return point; } - Point scaled(const Point& delta) const + Point scaled(Point const& delta) const { Point point = *this; point.scale_by(delta); @@ -106,15 +106,15 @@ public: return point; } - Point transformed(const AffineTransform& transform) const + Point transformed(AffineTransform const& transform) const { Point point = *this; point.transform_by(transform); return point; } - void constrain(const Rect&); - Point constrained(const Rect& rect) const + void constrain(Rect const&); + Point constrained(Rect const& rect) const { Point point = *this; point.constrain(rect); @@ -127,20 +127,20 @@ public: Point moved_down(T amount) const { return { x(), y() + amount }; } template - bool operator==(const Point& other) const + bool operator==(Point const& other) const { return x() == other.x() && y() == other.y(); } template - bool operator!=(const Point& other) const + bool operator!=(Point const& other) const { return !(*this == other); } - Point operator+(const Point& other) const { return { m_x + other.m_x, m_y + other.m_y }; } + Point operator+(Point const& other) const { return { m_x + other.m_x, m_y + other.m_y }; } - Point& operator+=(const Point& other) + Point& operator+=(Point const& other) { m_x += other.m_x; m_y += other.m_y; @@ -149,9 +149,9 @@ public: Point operator-() const { return { -m_x, -m_y }; } - Point operator-(const Point& other) const { return { m_x - other.m_x, m_y - other.m_y }; } + Point operator-(Point const& other) const { return { m_x - other.m_x, m_y - other.m_y }; } - Point& operator-=(const Point& other) + Point& operator-=(Point const& other) { m_x -= other.m_x; m_y -= other.m_y; @@ -204,30 +204,30 @@ public: } } - T dx_relative_to(const Point& other) const + T dx_relative_to(Point const& other) const { return x() - other.x(); } - T dy_relative_to(const Point& other) const + T dy_relative_to(Point const& other) const { return y() - other.y(); } // Returns pixels moved from other in either direction - T pixels_moved(const Point& other) const + T pixels_moved(Point const& other) const { return max(abs(dx_relative_to(other)), abs(dy_relative_to(other))); } - float distance_from(const Point& other) const + float distance_from(Point const& other) const { if (*this == other) return 0; 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 + Point absolute_relative_distance_to(Point const& other) const { return { abs(dx_relative_to(other)), abs(dy_relative_to(other)) }; } @@ -254,7 +254,7 @@ namespace AK { template struct Formatter> : Formatter { - void format(FormatBuilder& builder, const Gfx::Point& value) + void format(FormatBuilder& builder, Gfx::Point const& value) { Formatter::format(builder, value.to_string()); } @@ -264,7 +264,7 @@ struct Formatter> : Formatter { namespace IPC { -bool encode(Encoder&, const Gfx::IntPoint&); +bool encode(Encoder&, Gfx::IntPoint const&); bool decode(Decoder&, Gfx::IntPoint&); }