23 using NodeDecorator::NodeDecorator;
25 void ComputeRequirement()
override {
26 NodeDecorator::ComputeRequirement();
27 requirement_ = children_[0]->requirement();
31 void SetBox(
Box box)
override {
34 children_[0]->SetBox(box);
37 void Render(
Screen& screen)
final {
38 NodeDecorator::Render(screen);
42 const int size_inner = box_.y_max - box_.y_min;
43 if (size_inner <= 0) {
46 const int size_outter = stencil.
y_max - stencil.
y_min + 1;
47 if (size_outter >= size_inner) {
51 int size = 2 * size_outter * size_outter / size_inner;
52 size = std::max(size, 1);
56 2 * (stencil.
y_min - box_.y_min) * size_outter / size_inner;
58 const int x = stencil.
x_max;
59 for (
int y = stencil.
y_min; y <= stencil.
y_max; ++y) {
60 const int y_up = 2 * y + 0;
61 const int y_down = 2 * y + 1;
62 const bool up = (start_y <= y_up) && (y_up <= start_y + size);
63 const bool down = (start_y <= y_down) && (y_down <= start_y + size);
65 const char* c = up ? (
down ?
"┃" :
"╹") : (
down ?
"╻" :
" ");
70 return std::make_shared<Impl>(std::move(child));
78 using NodeDecorator::NodeDecorator;
80 void ComputeRequirement()
override {
81 NodeDecorator::ComputeRequirement();
82 requirement_ = children_[0]->requirement();
86 void SetBox(
Box box)
override {
89 children_[0]->SetBox(box);
92 void Render(
Screen& screen)
final {
93 NodeDecorator::Render(screen);
97 const int size_inner = box_.x_max - box_.x_min;
98 if (size_inner <= 0) {
101 const int size_outter = stencil.
x_max - stencil.
x_min + 1;
102 if (size_outter >= size_inner) {
106 int size = 2 * size_outter * size_outter / size_inner;
107 size = std::max(size, 1);
111 2 * (stencil.
x_min - box_.x_min) * size_outter / size_inner;
113 const int y = stencil.
y_max;
114 for (
int x = stencil.
x_min; x <= stencil.
x_max; ++x) {
115 const int x_left = 2 * x + 0;
116 const int x_right = 2 * x + 1;
117 const bool left = (start_x <= x_left) && (x_left <= start_x + size);
118 const bool right = (start_x <= x_right) && (x_right <= start_x + size);
126 return std::make_shared<Impl>(std::move(child));