FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
box.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSE ファイルに見つかる MIT ライセンスによって管理されています。
4
5#include <algorithm>
6
7namespace ftxui {
8/// @return |a| と |b| の両方に含まれる最大のBoxを返します。
9// static
11 return Box{
12 std::max(a.x_min, b.x_min),
13 std::min(a.x_max, b.x_max),
14 std::max(a.y_min, b.y_min),
15 std::min(a.y_max, b.y_max),
16 };
17}
18
19/// @return |a| と |b| の両方を含む最小のBoxを返します。
20// static
22 return Box{
23 std::min(a.x_min, b.x_min),
24 std::max(a.x_max, b.x_max),
25 std::min(a.y_min, b.y_min),
26 std::max(a.y_max, b.y_max),
27 };
28}
29
30/// Boxを (x,y) だけシフトします。
31/// @param x 水平シフト。
32/// @param y 垂直シフト。
33void Box::Shift(int x, int y) {
34 x_min += x;
35 x_max += x;
36 y_min += y;
37 y_max += y;
38}
39
40/// @return (x,y) がBox内に含まれているかどうか。
41bool Box::Contain(int x, int y) const {
42 return x_min <= x && //
43 x_max >= x && //
44 y_min <= y && //
45 y_max >= y;
46}
47
48/// @return Boxが空かどうか。
49bool Box::IsEmpty() const {
50 return x_min > x_max || y_min > y_max;
51}
52
53/// @return |other| が |this| と同じかどうか。
54bool Box::operator==(const Box& other) const {
55 return (x_min == other.x_min) && (x_max == other.x_max) &&
56 (y_min == other.y_min) && (y_max == other.y_max);
57}
58
59/// @return |other| と |this| が異なるかどうか。
60bool Box::operator!=(const Box& other) const {
61 return !operator==(other);
62}
63
64} // namespace ftxui
bool operator!=(const Box &other) const
Definition box.cpp:60
bool Contain(int x, int y) const
Definition box.cpp:41
void Shift(int x, int y)
Definition box.cpp:33
int x_max
Definition box.hpp:16
int y_min
Definition box.hpp:17
static auto Intersection(Box a, Box b) -> Box
Definition box.cpp:10
bool IsEmpty() const
Definition box.cpp:49
int y_max
Definition box.hpp:18
bool operator==(const Box &other) const
Definition box.cpp:54
static auto Union(Box a, Box b) -> Box
Definition box.cpp:21
int x_min
Definition box.hpp:15
Boxは、2D空間における矩形領域を表す構造体です。
Definition box.hpp:14
FTXUI ftxui:: 名前空間
Definition animation.hpp:9