blob: f3e81e093ca4614f0d44553f467652ccbc6a4004 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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");
}
}
|