summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/mkpals.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/tools/mkpals.c b/tools/mkpals.c
new file mode 100644
index 0000000..dcb0a75
--- /dev/null
+++ b/tools/mkpals.c
@@ -0,0 +1,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);
+}