FTXUI  5.0.0
C++ functional terminal UI.
image.hpp
Go to the documentation of this file.
1 // Copyright 2024 Arthur Sonzogni. All rights reserved.
2 // Use of this source code is governed by the MIT license that can be found in
3 // the LICENSE file.
4 #ifndef FTXUI_SCREEN_IMAGE_HPP
5 #define FTXUI_SCREEN_IMAGE_HPP
6 
7 #include <string> // for string, basic_string, allocator
8 #include <vector> // for vector
9 
10 #include "ftxui/screen/box.hpp" // for Box
11 #include "ftxui/screen/pixel.hpp" // for Pixel
12 
13 namespace ftxui {
14 
15 /// @brief A rectangular grid of Pixel.
16 /// @ingroup screen
17 class Image {
18  public:
19  // Constructors:
20  Image() = delete;
21  Image(int dimx, int dimy);
22 
23  // Access a character in the grid at a given position.
24  std::string& at(int x, int y);
25  const std::string& at(int x, int y) const;
26 
27  // Access a cell (Pixel) in the grid at a given position.
28  Pixel& PixelAt(int x, int y);
29  const Pixel& PixelAt(int x, int y) const;
30 
31  // Get screen dimensions.
32  int dimx() const { return dimx_; }
33  int dimy() const { return dimy_; }
34 
35  // Fill the image with space and default style
36  void Clear();
37 
39 
40  protected:
41  int dimx_;
42  int dimy_;
43  std::vector<std::vector<Pixel>> pixels_;
44 };
45 
46 } // namespace ftxui
47 
48 #endif // FTXUI_SCREEN_IMAGE_HPP
A rectangular grid of Pixel.
Definition: image.hpp:17
int dimy() const
Definition: image.hpp:33
int dimx_
Definition: image.hpp:41
Pixel & PixelAt(int x, int y)
Access a cell (Pixel) at a given position.
Definition: image.cpp:43
std::string & at(int x, int y)
Access a character in a cell at a given position.
Definition: image.cpp:29
Image()=delete
Box stencil
Definition: image.hpp:38
int dimy_
Definition: image.hpp:42
void Clear()
Clear all the pixel from the screen.
Definition: image.cpp:55
int dimx() const
Definition: image.hpp:32
std::vector< std::vector< Pixel > > pixels_
Definition: image.hpp:43
A Unicode character and its associated style.
Definition: pixel.hpp:15