4 #ifndef FTXUI_DOM_CANVAS_HPP
5 #define FTXUI_DOM_CANVAS_HPP
10 #include <unordered_map>
29 int width()
const {
return width_; }
30 int height()
const {
return height_; }
94 void DrawText(
int x,
int y,
const std::string& value);
96 void DrawText(
int x,
int y,
const std::string& value,
const Stylizer& style);
110 bool IsIn(
int x,
int y)
const {
111 return x >= 0 && x < width_ && y >= 0 && y < height_;
121 CellType type = kCell;
128 bool operator==(
const XY& other)
const {
129 return x == other.x && y == other.y;
134 size_t operator()(
const XY& xy)
const {
135 constexpr
size_t shift = 1024;
136 return size_t(xy.x) * shift + size_t(xy.y);
142 std::unordered_map<XY, Cell, XYHash> storage_;
A class representing terminal colors.
A rectangular grid of Pixel.
Decorator color(Color)
Decorate using a foreground color.
void DrawImage(int x, int y, const Image &)
Draw a predefined image, with top-left corner at the given coordinate You can supply negative coordin...
void DrawBlockLine(int x1, int y1, int x2, int y2)
Draw a line made of block characters.
void DrawPointEllipseFilled(int x, int y, int r1, int r2)
Draw a filled ellipse made of braille dots.
void DrawPointLine(int x1, int y1, int x2, int y2)
Draw a line made of braille dots.
void DrawText(int x, int y, const std::string &value)
Draw a piece of text.
std::function< void(Pixel &)> Stylizer
void DrawBlockOn(int x, int y)
Draw a block.
void DrawPointCircleFilled(int x, int y, int radius)
Draw a filled circle made of braille dots.
void DrawPointOn(int x, int y)
Draw a braille dot.
void DrawPointOff(int x, int y)
Erase a braille dot.
Pixel GetPixel(int x, int y) const
Get the content of a cell.
void DrawBlockEllipseFilled(int x1, int y1, int r1, int r2)
Draw a filled ellipse made of block characters.
void DrawPointEllipse(int x, int y, int r1, int r2)
Draw an ellipse made of braille dots.
void DrawPoint(int x, int y, bool value)
Draw a braille dot.
void DrawBlockEllipse(int x1, int y1, int r1, int r2)
Draw an ellipse made of block characters.
void DrawBlockToggle(int x, int y)
Toggle a block. If it is filled, it will be erased. If it is empty, it will be filled.
void DrawBlockCircle(int x1, int y1, int radius)
Draw a circle made of block characters.
void DrawBlockCircleFilled(int x1, int y1, int radius)
Draw a filled circle made of block characters.
void DrawPointCircle(int x, int y, int radius)
Draw a circle made of braille dots.
void DrawBlockOff(int x, int y)
Erase a block.
void DrawBlock(int x, int y, bool value)
Draw a block.
void Style(int x, int y, const Stylizer &style)
Modify a pixel at a given location.
void DrawPointToggle(int x, int y)
Toggle a braille dot. A filled one will be erased, and the other will be drawn.
void DrawPixel(int x, int y, const Pixel &)
Directly draw a predefined pixel at the given coordinate.
A Unicode character and its associated style.