Separated Image from Screen to avoid tinkering with Windows console; Added Canvas methods for drawing Pixels/Images directly

This commit is contained in:
Epixu
2024-03-29 17:08:09 +02:00
parent ce5ac6b12f
commit 3d6c48e800
10 changed files with 232 additions and 102 deletions

View File

@@ -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,11 @@ 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 --------------------------------------
// Pixel/image coordinates correspond 1:1
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.