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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
* Copyright (C) 2013 Patrick "P. J." McDermott
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <stdio.h>
static void parse_day_palette(void);
int
main(void)
{
parse_day_palette();
return 0;
}
static void
parse_day_palette(void)
{
FILE *in_fp, *day_fp, *night_fp, *eve_fp, *morn_fp;
unsigned int n, r, g, b;
in_fp = fopen("palette.txt", "rb");
day_fp = fopen("data/palettes/day.gpl", "wb");
night_fp = fopen("data/palettes/night.gpl", "wb");
eve_fp = fopen("data/palettes/eve.gpl", "wb");
morn_fp = fopen("data/palettes/morn.gpl", "wb");
fputs("GIMP Palette\nName: Day colors\n#\n", day_fp);
fputs("GIMP Palette\nName: Night colors\n#\n", night_fp);
fputs("GIMP Palette\nName: Evening colors\n#\n", eve_fp);
fputs("GIMP Palette\nName: Morning colors\n#\n", morn_fp);
while (1) {
if (fscanf(in_fp, "%3u %2x %2x %2x", &n, &r, &g, &b) == EOF) {
break;
}
fprintf(day_fp, "%3u %3u %3u\tColor %02x%02x%02x\n",
r, g, b, r, g, b);
fprintf(night_fp, "%3u %3u %3u\tColor %02x%02x%02x\n",
(unsigned int) (r * 0.250),
(unsigned int) (g * 0.250),
(unsigned int) (b * 0.500), /* was 0.375 */
(unsigned int) (r * 0.250),
(unsigned int) (g * 0.250),
(unsigned int) (b * 0.500));
fprintf(eve_fp, "%3u %3u %3u\tColor %02x%02x%02x\n",
(unsigned int) (r * 0.875), /* was 0.750 */
(unsigned int) (g * 0.625),
(unsigned int) (b * 0.625),
(unsigned int) (r * 0.875),
(unsigned int) (g * 0.625),
(unsigned int) (b * 0.625));
fprintf(morn_fp, "%3u %3u %3u\tColor %02x%02x%02x\n",
(unsigned int) (r * 1.000),
(unsigned int) (g * 0.875), /* was 0.750 */
(unsigned int) (b * 0.625),
(unsigned int) (r * 1.000),
(unsigned int) (g * 0.875),
(unsigned int) (b * 0.625));
}
fclose(in_fp);
fclose(day_fp);
fclose(night_fp);
fclose(eve_fp);
fclose(morn_fp);
}
|