summaryrefslogtreecommitdiff
path: root/example/cli.c
diff options
context:
space:
mode:
authordweller <dweller@cabin.digital>2024-07-31 02:37:41 +0300
committerdweller <dweller@cabin.digital>2024-07-31 02:37:41 +0300
commit6c080c486f987ba30e7efe209f1310c6cfca0beb (patch)
treeb18984337e4c53cd1b83a33701c875e0cacfa81f /example/cli.c
initial commitHEADmaster
Diffstat (limited to 'example/cli.c')
-rw-r--r--example/cli.c31
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");
+ }
+}
+