FTXUI 6.1.9
C++ functional terminal UI.
Loading...
Searching...
No Matches
image.cpp
Go to the documentation of this file.
1// Copyright 2020 Arthur Sonzogni. All rights reserved.
2// このソースコードの使用は、LICENSEファイルにあるMITライセンスに従います。
3#include <sstream> // IWYU pragma: keep
4#include <string>
5#include <vector>
6
9
10namespace ftxui {
11
12namespace {
13Pixel& dev_null_pixel() {
14 static Pixel pixel;
15 return pixel;
16}
17} // namespace
18
19Image::Image(int dimx, int dimy)
20 : stencil{0, dimx - 1, 0, dimy - 1},
21 dimx_(dimx),
22 dimy_(dimy),
23 pixels_(dimy, std::vector<Pixel>(dimx)) {}
24
25/// @brief 指定された位置のセル内の文字にアクセスします。
26/// @param x x軸に沿ったセルの位置。
27/// @param y y軸に沿ったセルの位置。
28 return PixelAt(x, y).character;
29}
30
31/// @brief 指定された位置のセル内の文字にアクセスします。
32/// @param x x軸に沿ったセルの位置。
33/// @param y y軸に沿ったセルの位置。
34const std::string& Image::at(int x, int y) const {
35 return PixelAt(x, y).character;
36}
37
38/// @brief 指定された位置のセル (ピクセル) にアクセスします。
39/// @param x x軸に沿ったセルの位置。
40/// @param y y軸に沿ったセルの位置。
41Pixel& Image::PixelAt(int x, int y) {
42 return stencil.Contain(x, y) ? pixels_[y][x] : dev_null_pixel();
43}
44
45/// @brief 指定された位置のセル (ピクセル) にアクセスします。
46/// @param x x軸に沿ったセルの位置。
47/// @param y y軸に沿ったセルの位置。
48const Pixel& Image::PixelAt(int x, int y) const {
49 return stencil.Contain(x, y) ? pixels_[y][x] : dev_null_pixel();
50}
51
52/// @brief 画面からすべてのピクセルをクリアします。
53void Image::Clear() {
54 for (auto& line : pixels_) {
55 for (auto& cell : line) {
56 cell = Pixel();
57 }
58 }
59}
60
61} // namespace ftxui
Image()=delete
Unicode文字とそれに関連付けられたスタイル。
Definition pixel.hpp:14
FTXUI ftxui:: 名前空間
Definition animation.hpp:9
return PixelAt(x, y).character
指定された位置のセル内の文字にアクセスします。