diff options
Diffstat (limited to 'example/cli.c')
-rw-r--r-- | example/cli.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/example/cli.c b/example/cli.c new file mode 100644 index 0000000..f3e81e0 --- /dev/null +++ b/example/cli.c @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 dwlr <dweller@cabin.digital> + * + * BSD 3-Clause License (BSD-3-Clause) + * See LICENSE for details + */ + +#define ESC "\x1B" +#define CSI ESC"[" + +void cli_draw_tex(texture* tex, bool bw) +{ + ssize x, y; + + for(y = 0; y < tex->height; y++) + { + for(x = 0; x < tex->width; x++) + { + rgba* p = tex->texels + (x + tex->width * y); + if(p->A == 0) printf(CSI"0m "); + else + { + if(bw) printf("##"); + else printf(CSI"48;2;%d;%d;%dm ", p->R, p->G, p->B); + } + } + + printf(CSI"0m\n"); + } +} + |