diff --git a/Userland/Libraries/LibGfx/Point.h b/Userland/Libraries/LibGfx/Point.h index 4898361f5e..c5a3c54be4 100644 --- a/Userland/Libraries/LibGfx/Point.h +++ b/Userland/Libraries/LibGfx/Point.h @@ -71,42 +71,42 @@ public: void transform_by(AffineTransform const& transform) { *this = transform.map(*this); } - Point translated(Point const& delta) const + [[nodiscard]] Point translated(Point const& delta) const { Point point = *this; point.translate_by(delta); return point; } - Point translated(T dx, T dy) const + [[nodiscard]] Point translated(T dx, T dy) const { Point point = *this; point.translate_by(dx, dy); return point; } - Point translated(T dboth) const + [[nodiscard]] Point translated(T dboth) const { Point point = *this; point.translate_by(dboth, dboth); return point; } - Point scaled(Point const& delta) const + [[nodiscard]] Point scaled(Point const& delta) const { Point point = *this; point.scale_by(delta); return point; } - Point scaled(T sx, T sy) const + [[nodiscard]] Point scaled(T sx, T sy) const { Point point = *this; point.scale_by(sx, sy); return point; } - Point transformed(AffineTransform const& transform) const + [[nodiscard]] Point transformed(AffineTransform const& transform) const { Point point = *this; point.transform_by(transform); @@ -114,31 +114,31 @@ public: } void constrain(Rect const&); - Point constrained(Rect const& rect) const + [[nodiscard]] Point constrained(Rect const& rect) const { Point point = *this; point.constrain(rect); return point; } - Point moved_left(T amount) const { return { x() - amount, y() }; } - Point moved_right(T amount) const { return { x() + amount, y() }; } - Point moved_up(T amount) const { return { x(), y() - amount }; } - Point moved_down(T amount) const { return { x(), y() + amount }; } + [[nodiscard]] Point moved_left(T amount) const { return { x() - amount, y() }; } + [[nodiscard]] Point moved_right(T amount) const { return { x() + amount, y() }; } + [[nodiscard]] Point moved_up(T amount) const { return { x(), y() - amount }; } + [[nodiscard]] Point moved_down(T amount) const { return { x(), y() + amount }; } template - bool operator==(Point const& other) const + [[nodiscard]] bool operator==(Point const& other) const { return x() == other.x() && y() == other.y(); } template - bool operator!=(Point const& other) const + [[nodiscard]] bool operator!=(Point const& other) const { return !(*this == other); } - Point operator+(Point const& other) const { return { m_x + other.m_x, m_y + other.m_y }; } + [[nodiscard]] Point operator+(Point const& other) const { return { m_x + other.m_x, m_y + other.m_y }; } Point& operator+=(Point const& other) { @@ -147,9 +147,9 @@ public: return *this; } - Point operator-() const { return { -m_x, -m_y }; } + [[nodiscard]] Point operator-() const { return { -m_x, -m_y }; } - Point operator-(Point const& other) const { return { m_x - other.m_x, m_y - other.m_y }; } + [[nodiscard]] Point operator-(Point const& other) const { return { m_x - other.m_x, m_y - other.m_y }; } Point& operator-=(Point const& other) { @@ -158,7 +158,7 @@ public: return *this; } - Point operator*(T factor) const { return { m_x * factor, m_y * factor }; } + [[nodiscard]] Point operator*(T factor) const { return { m_x * factor, m_y * factor }; } Point& operator*=(T factor) { @@ -167,7 +167,7 @@ public: return *this; } - Point operator/(T factor) const { return { m_x / factor, m_y / factor }; } + [[nodiscard]] Point operator/(T factor) const { return { m_x / factor, m_y / factor }; } Point& operator/=(T factor) { @@ -176,7 +176,7 @@ public: return *this; } - T primary_offset_for_orientation(Orientation orientation) const + [[nodiscard]] T primary_offset_for_orientation(Orientation orientation) const { return orientation == Orientation::Vertical ? y() : x(); } @@ -190,7 +190,7 @@ public: } } - T secondary_offset_for_orientation(Orientation orientation) const + [[nodiscard]] T secondary_offset_for_orientation(Orientation orientation) const { return orientation == Orientation::Vertical ? x() : y(); } @@ -204,41 +204,41 @@ public: } } - T dx_relative_to(Point const& other) const + [[nodiscard]] T dx_relative_to(Point const& other) const { return x() - other.x(); } - T dy_relative_to(Point const& other) const + [[nodiscard]] T dy_relative_to(Point const& other) const { return y() - other.y(); } // Returns pixels moved from other in either direction - T pixels_moved(Point const& other) const + [[nodiscard]] T pixels_moved(Point const& other) const { return max(abs(dx_relative_to(other)), abs(dy_relative_to(other))); } - float distance_from(Point const& other) const + [[nodiscard]] 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(Point const& other) const + [[nodiscard]] Point absolute_relative_distance_to(Point const& other) const { return { abs(dx_relative_to(other)), abs(dy_relative_to(other)) }; } template - Point to_type() const + [[nodiscard]] Point to_type() const { return Point(*this); } - String to_string() const; + [[nodiscard]] String to_string() const; private: T m_x { 0 };