avcpp 3.1.0
Wrapper for the FFmpeg that simplify usage from C++ projects.
Loading...
Searching...
No Matches
rect.h
Go to the documentation of this file.
1#pragma once
2
9
10namespace av {
11
18class Rect
19{
20public:
24 Rect() noexcept = default;
31 Rect(int width, int height) noexcept;
40 Rect(int x, int y, int width, int height) noexcept;
41
47 void setX(int x) noexcept { this->x = x; }
53 void setY(int y) noexcept { this->y = y; }
59 void setWidth(int w) noexcept { width = w; }
65 void setHeight(int h) noexcept { height = h; }
66
72 int getX() const noexcept { return x; }
78 int getY() const noexcept { return y; }
84 int getWidth() const noexcept { return width; }
90 int getHeight() const noexcept { return height; }
91
92private:
93 int x{};
94 int y{};
95 int width{};
96 int height{};
97};
98
99} // ::av
100
101#if __has_include(<format>)
102#include <format>
103#ifdef __cpp_lib_format
104// std::format
105template <typename CharT>
106struct std::formatter<av::Rect, CharT>
107{
108 template<typename ParseContext>
109 constexpr auto parse(ParseContext& ctx)
110 {
111 return ctx.begin();
112 }
113 template<typename ParseContext>
114 auto format(const av::Rect& value, ParseContext& ctx) const
115 {
116 return std::format_to(ctx.out(), "{}x{}{:+}{:+}", value.getWidth(), value.getHeight(), value.getX(), value.getY());
117 }
118};
119#endif // __cpp_lib_format
120#endif // __has_include
Rect() noexcept=default
Create a zero-sized rectangle at the origin.
int getY() const noexcept
The top edge.
Definition rect.h:78
void setHeight(int h) noexcept
Set the height.
Definition rect.h:65
int getWidth() const noexcept
The width.
Definition rect.h:84
void setX(int x) noexcept
Set the left edge.
Definition rect.h:47
int getX() const noexcept
The left edge.
Definition rect.h:72
int getHeight() const noexcept
The height.
Definition rect.h:90
void setWidth(int w) noexcept
Set the width.
Definition rect.h:59
void setY(int y) noexcept
Set the top edge.
Definition rect.h:53
Root namespace of the library.
Definition audioresampler.h:19