Terminal++ 3.1.0.4
A C++ library for interacting with ANSI terminal windows
Loading...
Searching...
No Matches
point.hpp
1#pragma once
2
3#include "terminalpp/core.hpp"
4
5#include <iosfwd>
6
7namespace terminalpp {
8
9//* =========================================================================
15//* =========================================================================
17{
18 //* =====================================================================
22 //* =====================================================================
23 constexpr point() : y_(0), x_(0)
24 {
25 }
26
27 //* =====================================================================
32 //* =====================================================================
33 constexpr point(coordinate_type x, coordinate_type y) noexcept // NOLINT
34 : y_(y), x_(x)
35 {
36 }
37
38 //* =====================================================================
40 //* =====================================================================
41 constexpr point &operator+=(point const &rhs) noexcept
42 {
43 x_ += rhs.x_;
44 y_ += rhs.y_;
45 return *this;
46 }
47
48 //* =====================================================================
50 //* =====================================================================
51 [[nodiscard]] constexpr friend auto operator+(
52 point lhs, point const &rhs) noexcept
53 {
54 return lhs += rhs;
55 }
56
57 //* =====================================================================
59 //* =====================================================================
60 constexpr point &operator-=(point const &rhs) noexcept
61 {
62 x_ -= rhs.x_;
63 y_ -= rhs.y_;
64 return *this;
65 }
66
67 //* =====================================================================
69 //* =====================================================================
70 [[nodiscard]] constexpr friend auto operator-(
71 point lhs, point const &rhs) noexcept
72 {
73 return lhs -= rhs;
74 }
75
76 //* =====================================================================
78 //* =====================================================================
79 [[nodiscard]] constexpr friend auto operator<=>(
80 point const &lhs, point const &rhs) noexcept = default;
81
82 coordinate_type y_;
83 coordinate_type x_;
84};
85
86//* =====================================================================
89//* =====================================================================
91std::ostream &operator<<(std::ostream &out, point const &pt);
92
93} // namespace terminalpp
A structure representing an ANSI graphics effect (e.g. intensity, underlining)
Definition effect.hpp:27
constexpr effect() noexcept
Initialises the intensity to the default (normal) value.
Definition effect.hpp:31
A class that represents a position in space.
Definition point.hpp:17
constexpr friend auto operator<=>(point const &lhs, point const &rhs) noexcept=default
Relational operators for points.
constexpr point & operator+=(point const &rhs) noexcept
Addition.
Definition point.hpp:41
constexpr point(coordinate_type x, coordinate_type y) noexcept
Constructor.
Definition point.hpp:33
constexpr point & operator-=(point const &rhs) noexcept
Subtraction.
Definition point.hpp:60
constexpr point()
Default Constructor.
Definition point.hpp:23
constexpr friend auto operator-(point lhs, point const &rhs) noexcept
Subtraction.
Definition point.hpp:70
constexpr friend auto operator+(point lhs, point const &rhs) noexcept
Addition.
Definition point.hpp:51