make it easier to change the color theme for svg and tty - chess-puzzles - ches… | |
git clone git://git.codemadness.org/chess-puzzles | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit cbf34cae81cb9545e3854c19eb15040f106ab02f | |
parent b55e73ad95fbbe333cdac344ca25a84dc61151b0 | |
Author: Hiltjo Posthuma <[email protected]> | |
Date: Wed, 20 Dec 2023 21:16:42 +0100 | |
make it easier to change the color theme for svg and tty | |
Diffstat: | |
M fen_to_svg.c | 33 ++++++++++++++---------------… | |
1 file changed, 15 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/fen_to_svg.c b/fen_to_svg.c | |
@@ -19,6 +19,13 @@ static int enpassantsquare[2] = { -1, -1 }; | |
static int movenumber = 1; | |
static int halfmove = 0; | |
+/* lichess default theme colors */ | |
+static const int border[] = { 0x70, 0x49, 0x2d }; | |
+static const int darksquare[] = { 0xb5, 0x88, 0x63 }; | |
+static const int lightsquare[] = { 0xf0, 0xd9, 0xb5 }; | |
+static const int darksquarehi[] = { 0xaa, 0xa2, 0x3a }; | |
+static const int lightsquarehi[] = { 0xcd, 0xd2, 0x6a }; | |
+ | |
static const int showcoords = 1; /* config: show board coordinates? */ | |
int | |
@@ -151,12 +158,7 @@ svg_showpiece(int c) | |
void | |
svg_showboard(void) | |
{ | |
- /* lichess default theme colors */ | |
- const char *darksquare = "#b58863"; | |
- const char *lightsquare = "#f0d9b5"; | |
- const char *darksquarehi = "#aaa23a"; | |
- const char *lightsquarehi = "#cdd26a"; | |
- const char *color; | |
+ const int *color; | |
int x, y, piece; | |
fputs("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" | |
@@ -182,8 +184,8 @@ svg_showboard(void) | |
color = highlight[y][x] ? lightsquareh… | |
} | |
- printf("<g><rect x=\"%d\" y=\"%d\" width=\"45\" height… | |
- x * 45, y * 45, color); | |
+ printf("<g><rect x=\"%d\" y=\"%d\" width=\"45\" height… | |
+ x * 45, y * 45, color[0], color[1], color[2]); | |
piece = getpiece(x, y); | |
if (piece) { | |
@@ -201,8 +203,8 @@ svg_showboard(void) | |
color = highlight[y][x] ? lightsquarehi : ligh… | |
else | |
color = highlight[y][x] ? darksquarehi : darks… | |
- printf("<text x=\"%d\" y=\"%d\" fill=\"%s\" text-ancho… | |
- (x + 1) * 45 - 2, (y * 45) + 10, color, '8' - … | |
+ printf("<text x=\"%d\" y=\"%d\" fill=\"#%02x%02x%02x\"… | |
+ (x + 1) * 45 - 2, (y * 45) + 10, color[0], col… | |
} | |
y = 7; | |
for (x = 0; x < 8; x++) { | |
@@ -210,8 +212,8 @@ svg_showboard(void) | |
color = highlight[y][x] ? lightsquarehi : ligh… | |
else | |
color = highlight[y][x] ? darksquarehi : darks… | |
- printf("<text x=\"%d\" y=\"%d\" fill=\"%s\" text-ancho… | |
- (x * 45) + 2, (y + 1) * 45 - 3, color, x + 'a'… | |
+ printf("<text x=\"%d\" y=\"%d\" fill=\"#%02x%02x%02x\"… | |
+ (x * 45) + 2, (y + 1) * 45 - 3, color[0], colo… | |
} | |
} | |
@@ -252,12 +254,7 @@ tty_showpiece(int c) | |
void | |
tty_showboard(void) | |
{ | |
- int *color; | |
- int border[] = { 0x70, 0x49, 0x2d }; | |
- int darksquare[] = { 0xb5, 0x88, 0x63 }; | |
- int lightsquare[] = { 0xf0, 0xd9, 0xb5 }; | |
- int darksquarehi[] = { 0xaa, 0xa2, 0x3a }; | |
- int lightsquarehi[] = { 0xcd, 0xd2, 0x6a }; | |
+ const int *color; | |
int x, y, piece; | |
printf("Board FEN:\n"); |