From e267c4c16028d0cbe662bb821709179d95164888 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Tue, 11 Apr 2023 00:06:16 +0200 Subject: add grayscale colors --- swt.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/swt.c b/swt.c index 7427d3b..76380c9 100644 --- a/swt.c +++ b/swt.c @@ -50,6 +50,7 @@ typedef struct { /* function prototypes */ +ushort sixd_to_8bit(int x); static void setup(); static void cleanup(); static void run(); @@ -155,7 +156,6 @@ void wclipcopy() { void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) { - draw_rect( win.canvas, ox * win.fontcache->box.width, @@ -178,7 +178,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) { cy * win.fontcache->box.height, win.fontcache->box.width, win.fontcache->box.height, - colors[g.bg] + colors[g.fg] ); draw_char( win.canvas, @@ -186,7 +186,7 @@ void wdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og) { g.u, cx * win.fontcache->box.width, cy * win.fontcache->box.height + win.fontcache->fontsize, - colors[g.fg] + colors[g.bg] ); } @@ -237,6 +237,7 @@ sixd_to_8bit(int x) void wloadcols() { int i; + int c; for (i = 0; i < sizeof(colors) / sizeof(uint32_t); ++i) { if (colors[i] == 0) { @@ -244,6 +245,10 @@ void wloadcols() { colors[i] = sixd_to_8bit(((i - 16) / 36) % 6) << 16 | sixd_to_8bit(((i - 16) / 6) % 6) << 8 | sixd_to_8bit(((i - 16) / 1) % 6); + } else { + c = 0x08 + 0x0a * (i - (6 * 6 * 6 * 6 + 16)); + c &= 0xff; + colors[i] = (c << 16) | (c << 8) | c; } } -- cgit v1.2.3-70-g09d2