4#ifndef FTXUI_DOM_CANVAS_HPP
5#define FTXUI_DOM_CANVAS_HPP
10#include <unordered_map>
44 int width()
const {
return width_; }
45 int height()
const {
return height_; }
109 void DrawText(
int x,
int y,
const std::string& value);
110 void DrawText(
int x,
int y,
const std::string& value,
const Color& color);
111 void DrawText(
int x,
int y,
const std::string& value,
const Stylizer& style);
125 bool IsIn(
int x,
int y)
const {
126 return x >= 0 && x < width_ && y >= 0 && y < height_;
136 CellType type = kCell;
143 bool operator==(
const XY& other)
const {
144 return x == other.x && y == other.y;
149 size_t operator()(
const XY& xy)
const {
150 constexpr size_t shift = 1024;
151 return size_t(xy.x) * shift + size_t(xy.y);
157 std::unordered_map<XY, Cell, XYHash> storage_;
void DrawImage(int x, int y, const Image &)
在给定坐标处绘制预定义图像,左上角位于该坐标 您可以提供负坐标来随意对齐图像 - 只会绘制“可见”部分
void DrawBlockLine(int x1, int y1, int x2, int y2)
绘制由块字符组成的线条。
void DrawPointEllipseFilled(int x, int y, int r1, int r2)
绘制由盲文点组成的实心椭圆。
void DrawPointLine(int x1, int y1, int x2, int y2)
绘制由盲文点组成的线条。
void DrawText(int x, int y, const std::string &value)
绘制一段文本。
std::function< void(Pixel &)> Stylizer
void DrawBlockOn(int x, int y)
绘制一个块。
void DrawPointCircleFilled(int x, int y, int radius)
绘制由盲文点组成的实心圆。
void DrawPointOn(int x, int y)
绘制一个盲文点。
void DrawPointOff(int x, int y)
擦除一个盲文点。
Pixel GetPixel(int x, int y) const
获取单元格的内容。
void DrawBlockEllipseFilled(int x1, int y1, int r1, int r2)
绘制由块字符组成的实心椭圆。
void DrawPointEllipse(int x, int y, int r1, int r2)
绘制由盲文点组成的椭圆。
void DrawPoint(int x, int y, bool value)
绘制一个盲文点。
void DrawBlockEllipse(int x1, int y1, int r1, int r2)
绘制由块字符组成的椭圆。
void DrawBlockToggle(int x, int y)
切换一个块。如果已填充,则擦除。如果为空, 将被填充。
void DrawBlockCircle(int x1, int y1, int radius)
绘制由块字符组成的圆。
void DrawBlockCircleFilled(int x1, int y1, int radius)
绘制由块字符组成的实心圆。
void DrawPointCircle(int x, int y, int radius)
绘制由盲文点组成的圆。
void DrawBlockOff(int x, int y)
擦除一个块。
void DrawBlock(int x, int y, bool value)
绘制一个块。
void DrawPointToggle(int x, int y)
切换盲文点。已填充的将被擦除,另一个将被绘制。
void DrawPixel(int x, int y, const Pixel &)
在给定坐标处直接绘制预定义像素
Canvas 是一个与绘图操作相关的可绘制缓冲区。
#include "ftxui/component/component_base.hpp" // 用于 ComponentBase