mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-17 00:18:11 +08:00
Separate a reusable Image class from Screen (#834)
Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include <unordered_map> // for unordered_map
|
||||
|
||||
#include "ftxui/screen/color.hpp" // for Color
|
||||
#include "ftxui/screen/screen.hpp" // for Pixel
|
||||
#include "ftxui/screen/image.hpp" // for Pixel, Image
|
||||
|
||||
#ifdef DrawText
|
||||
// Workaround for WinUsr.h (via Windows.h) defining macros that break things.
|
||||
@@ -94,6 +94,12 @@ struct Canvas {
|
||||
void DrawText(int x, int y, const std::string& value);
|
||||
void DrawText(int x, int y, const std::string& value, const Color& color);
|
||||
void DrawText(int x, int y, const std::string& value, const Stylizer& style);
|
||||
|
||||
// Draw using directly pixels or images --------------------------------------
|
||||
// x is considered to be a multiple of 2.
|
||||
// y is considered to be a multiple of 4.
|
||||
void DrawPixel(int x, int y, const Pixel&);
|
||||
void DrawImage(int x, int y, const Image&);
|
||||
|
||||
// Decorator:
|
||||
// x is considered to be a multiple of 2.
|
||||
@@ -104,15 +110,18 @@ struct Canvas {
|
||||
bool IsIn(int x, int y) const {
|
||||
return x >= 0 && x < width_ && y >= 0 && y < height_;
|
||||
}
|
||||
|
||||
enum CellType {
|
||||
kBraille,
|
||||
kBlock,
|
||||
kText,
|
||||
kCell, // Units of size 2x4
|
||||
kBlock, // Units of size 2x2
|
||||
kBraille, // Units of size 1x1
|
||||
};
|
||||
|
||||
struct Cell {
|
||||
CellType type = kText;
|
||||
CellType type = kCell;
|
||||
Pixel content;
|
||||
};
|
||||
|
||||
struct XY {
|
||||
int x;
|
||||
int y;
|
||||
|
Reference in New Issue
Block a user