FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
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
13namespace ftxui {
14
15/// @brief A rectangular grid of Pixel.
16/// @ingroup screen
17class Image {
18 public:
19 // Constructors:
20 Image() = delete;
21 Image(int dimx, int dimy);
22
23 // Destructor:
24 virtual ~Image() = default;
25
26 // Access a character in the grid at a given position.
27 std::string& at(int x, int y);
28 const std::string& at(int x, int y) const;
29
30 // Access a cell (Pixel) in the grid at a given position.
31 Pixel& PixelAt(int x, int y);
32 const Pixel& PixelAt(int x, int y) const;
33
34 // Get screen dimensions.
35 int dimx() const { return dimx_; }
36 int dimy() const { return dimy_; }
37
38 // Fill the image with space and default style
39 void Clear();
40
42
43 protected:
44 int dimx_;
45 int dimy_;
46 std::vector<std::vector<Pixel>> pixels_;
47};
48
49} // namespace ftxui
50
51#endif // FTXUI_SCREEN_IMAGE_HPP
int dimy() const
Definition image.hpp:36
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:41
void Clear()
Clear all the pixel from the screen.
Definition image.cpp:55
int dimx() const
Definition image.hpp:35
std::vector< std::vector< Pixel > > pixels_
Definition image.hpp:46
virtual ~Image()=default
A rectangular grid of Pixel.
Definition image.hpp:17
Box is a structure that represents a rectangular area in a 2D space.
Definition box.hpp:16
A Unicode character and its associated style.
Definition pixel.hpp:15
The FTXUI ftxui:: namespace.
Definition animation.hpp:10