libepaper 2.0.0
A C++23 library for controlling Waveshare e-paper displays on Raspberry Pi, featuring transparent sleep/wake management and a fluent builder API.
Loading...
Searching...
No Matches
geometry.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4
5namespace epaper {
6
37struct Point {
38 std::size_t x;
39 std::size_t y;
40
44 constexpr Point() noexcept : x(0), y(0) {}
45
52 constexpr Point(std::size_t x_coord, std::size_t y_coord) noexcept : x(x_coord), y(y_coord) {}
53
60 [[nodiscard]] constexpr auto translate(const Point &offset) const noexcept -> Point {
61 return Point{x + offset.x, y + offset.y};
62 }
63
67 [[nodiscard]] constexpr auto operator==(const Point &other) const noexcept -> bool {
68 return x == other.x && y == other.y;
69 }
70
74 [[nodiscard]] constexpr auto operator!=(const Point &other) const noexcept -> bool { return !(*this == other); }
75};
76
105struct Size {
106 std::size_t width;
107 std::size_t height;
108
112 constexpr Size() noexcept : width(0), height(0) {}
113
120 constexpr Size(std::size_t w, std::size_t h) noexcept : width(w), height(h) {}
121
127 [[nodiscard]] constexpr auto area() const noexcept -> std::size_t { return width * height; }
128
132 [[nodiscard]] constexpr auto operator==(const Size &other) const noexcept -> bool {
133 return width == other.width && height == other.height;
134 }
135
139 [[nodiscard]] constexpr auto operator!=(const Size &other) const noexcept -> bool { return !(*this == other); }
140};
141
142} // namespace epaper
Definition color.hpp:5
Definition geometry.hpp:37
std::size_t y
Y coordinate (vertical position)
Definition geometry.hpp:39
constexpr auto operator!=(const Point &other) const noexcept -> bool
Inequality comparison.
Definition geometry.hpp:74
constexpr Point() noexcept
Default constructor initializes to origin (0, 0).
Definition geometry.hpp:44
constexpr auto operator==(const Point &other) const noexcept -> bool
Equality comparison.
Definition geometry.hpp:67
constexpr Point(std::size_t x_coord, std::size_t y_coord) noexcept
Construct a point at the specified coordinates.
Definition geometry.hpp:52
std::size_t x
X coordinate (horizontal position)
Definition geometry.hpp:38
constexpr auto translate(const Point &offset) const noexcept -> Point
Translate this point by an offset.
Definition geometry.hpp:60
Definition geometry.hpp:105
constexpr auto operator!=(const Size &other) const noexcept -> bool
Inequality comparison.
Definition geometry.hpp:139
constexpr auto operator==(const Size &other) const noexcept -> bool
Equality comparison.
Definition geometry.hpp:132
constexpr auto area() const noexcept -> std::size_t
Calculate the area (width × height).
Definition geometry.hpp:127
std::size_t width
Width in pixels.
Definition geometry.hpp:106
constexpr Size() noexcept
Default constructor initializes to zero size.
Definition geometry.hpp:112
std::size_t height
Height in pixels.
Definition geometry.hpp:107
constexpr Size(std::size_t w, std::size_t h) noexcept
Construct a size with the specified dimensions.
Definition geometry.hpp:120