add pixelate func and example

This commit is contained in:
Chimezie-Josias Iwu
2024-06-25 18:36:25 +02:00
parent b28d57086a
commit 91f853431f
5 changed files with 104 additions and 1 deletions

View File

@@ -12,6 +12,8 @@
#include "ftxui/screen/color.hpp" // for Color
#include "ftxui/screen/image.hpp" // for Pixel, Image
#include <opencv2/opencv.hpp> //for OpenCV
#ifdef DrawText
// Workaround for WinUsr.h (via Windows.h) defining macros that break things.
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-drawtext
@@ -106,6 +108,10 @@ struct Canvas {
// y is considered to be a multiple of 4.
void Style(int x, int y, const Stylizer& style);
static void DrawImageOnTerminal(const std::string& image_path, int width = 80, int height = 24);
private:
bool IsIn(int x, int y) const {
return x >= 0 && x < width_ && y >= 0 && y < height_;