]> git.draconx.ca Git - rrace.git/blob - src/icon.h
Make EWMH icon generation more abstract.
[rrace.git] / src / icon.h
1 /*
2  * Icon generation helpers for slide puzzle game
3  * Copyright © 2022 Nick Bowler
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  */
18
19 #ifndef RRACE_ICON_H_
20 #define RRACE_ICON_H_
21
22 /*
23  * Generate one tile of the program icon at various sizes, which is a 3x3 grid
24  * of coloured tiles.
25  *
26  * These functions all operate as follows:
27  *
28  *   - icon points to the start of the complete image buffer, in row-major
29  *     order.  Each byte represents one pixel of the icon, so for example the
30  *     16x16 icon requires a 256-byte buffer.
31  *
32  *   - c controls the byte values that are written to the icon for this tile.
33  *     The least significant 8 bits of c encode the primary colour, bits 8-15
34  *     encode the dark shade colour, and bits 16-23 encode the light shade
35  *     colour.
36  *
37  *   - tile_x and tile_y select which tile to render (each may be 0, 1 or 2).
38  *
39  * By calling the function 9 times with all combinations of tile_x/tile_y
40  * values, a complete icon is generated.
41  */
42
43 void icon_tile16(unsigned char *icon, unsigned long c, int tile_x, int tile_y);
44 void icon_tile24(unsigned char *icon, unsigned long c, int tile_x, int tile_y);
45 void icon_tile32(unsigned char *icon, unsigned long c, int tile_x, int tile_y);
46 void icon_tile48(unsigned char *icon, unsigned long c, int tile_x, int tile_y);
47
48 #endif