aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 00:06:16 +0200
committerNathan Reiner <nathan@nathanreiner.xyz>2023-04-11 00:06:16 +0200
commite267c4c16028d0cbe662bb821709179d95164888 (patch)
tree1953cfe7474c2082b30a53362f7d8aed51786bbb
parent821887424d3a80042d159f380014000f0cc41320 (diff)
add grayscale colors
-rw-r--r--swt.c11
1 files 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;
}
}