FTXUI
6.0.2
C++ functional terminal UI.
Toggle main menu visibility
Tutorial
Examples
File List
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Loading...
Searching...
No Matches
image.cpp
Go to the documentation of this file.
1
// Copyright 2020 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
#include <sstream>
// IWYU pragma: keep
5
#include <string>
6
#include <vector>
7
8
#include "
ftxui/screen/image.hpp
"
9
#include "
ftxui/screen/pixel.hpp
"
10
11
namespace
ftxui
{
12
13
namespace
{
14
Pixel&
dev_null_pixel
() {
15
static
Pixel
pixel
;
16
return
pixel
;
17
}
18
}
// namespace
19
20
Image::Image
(
int
dimx,
int
dimy)
21
: stencil{0, dimx - 1, 0, dimy - 1},
22
dimx_(dimx),
23
dimy_(dimy),
24
pixels_(dimy,
std
::
vector
<
Pixel
>(dimx)) {}
20
Image::Image
(
int
dimx,
int
dimy) {
…
}
25
26
/// @brief Access a character in a cell at a given position.
27
/// @param x The cell position along the x-axis.
28
/// @param y The cell position along the y-axis.
29
std::string&
Image::at
(
int
x,
int
y) {
30
return
PixelAt
(x, y).
character
;
31
}
29
std::string&
Image::at
(
int
x,
int
y) {
…
}
32
33
/// @brief Access a character in a cell at a given position.
34
/// @param x The cell position along the x-axis.
35
/// @param y The cell position along the y-axis.
36
const
std::string&
Image::at
(
int
x,
int
y)
const
{
37
return
PixelAt
(x, y).
character
;
38
}
36
const
std::string&
Image::at
(
int
x,
int
y)
const
{
…
}
39
40
/// @brief Access a cell (Pixel) at a given position.
41
/// @param x The cell position along the x-axis.
42
/// @param y The cell position along the y-axis.
43
Pixel
&
Image::PixelAt
(
int
x,
int
y) {
44
return
stencil
.
Contain
(x, y) ?
pixels_
[y][x] :
dev_null_pixel
();
45
}
43
Pixel
&
Image::PixelAt
(
int
x,
int
y) {
…
}
46
47
/// @brief Access a cell (Pixel) at a given position.
48
/// @param x The cell position along the x-axis.
49
/// @param y The cell position along the y-axis.
50
const
Pixel
&
Image::PixelAt
(
int
x,
int
y)
const
{
51
return
stencil
.
Contain
(x, y) ?
pixels_
[y][x] :
dev_null_pixel
();
52
}
50
const
Pixel
&
Image::PixelAt
(
int
x,
int
y)
const
{
…
}
53
54
/// @brief Clear all the pixel from the screen.
55
void
Image::Clear
() {
56
for
(
auto
& line :
pixels_
) {
57
for
(
auto
&
cell
: line) {
58
cell
=
Pixel
();
59
}
60
}
61
}
55
void
Image::Clear
() {
…
}
62
63
}
// namespace ftxui
ftxui::Image::PixelAt
Pixel & PixelAt(int x, int y)
Access a cell (Pixel) at a given position.
Definition
image.cpp:43
ftxui::Image::at
std::string & at(int x, int y)
Access a character in a cell at a given position.
Definition
image.cpp:29
ftxui::Image::Image
Image()=delete
ftxui::Image::stencil
Box stencil
Definition
image.hpp:38
ftxui::Image::Clear
void Clear()
Clear all the pixel from the screen.
Definition
image.cpp:55
ftxui::Image::pixels_
std::vector< std::vector< Pixel > > pixels_
Definition
image.hpp:43
image.hpp
ftxui
Definition
animation.hpp:10
ftxui::Make
std::shared_ptr< T > Make(Args &&... args)
Definition
component.hpp:26
pixel.hpp
ftxui::Box::Contain
bool Contain(int x, int y) const
Definition
box.cpp:46
ftxui::Pixel
A Unicode character and its associated style.
Definition
pixel.hpp:15
ftxui::Pixel::character
std::string character
Definition
pixel.hpp:45