summaryrefslogtreecommitdiff
path: root/palettes.h
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2015-03-15 17:08:55 +0100
committerLars-Dominik Braun <lars@6xq.net>2015-05-02 21:36:45 +0200
commitd5a00c0d05030a875ebd85356509ee270bdb7410 (patch)
tree0886c3e0bbc1ee6015f8b160eb3e0a3ea640a9aa /palettes.h
parentb2fc4eb99e9eb6207505252227d716df0527deec (diff)
downloadpucket-d5a00c0d05030a875ebd85356509ee270bdb7410.tar.gz
pucket-d5a00c0d05030a875ebd85356509ee270bdb7410.tar.bz2
pucket-d5a00c0d05030a875ebd85356509ee270bdb7410.zip
Rewrite color palettes
Supports palettes with != 256 colors properly now. A lot of old code still (silently!) relies on that number though.
Diffstat (limited to 'palettes.h')
-rw-r--r--palettes.h33
1 files changed, 25 insertions, 8 deletions
diff --git a/palettes.h b/palettes.h
index 967c30b..2603c99 100644
--- a/palettes.h
+++ b/palettes.h
@@ -1,5 +1,6 @@
/*
Copyright (C) 1992-2009 Spotworks LLC
+ Copyright (C) 2015 pucket contributors
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,15 +16,27 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef palettes_included
-#define palettes_included
+#pragma once
+#include <stdlib.h>
+#include <stdbool.h>
+#include "flam3.h"
+
+/* One palette */
+typedef struct {
+ /* number of items allocated */
+ size_t allocated;
+ /* number of items in palette */
+ size_t count;
+ double4 *color;
+} palette;
+
+/* A collection/array of palettes */
typedef struct {
- int number;
- char name[flam3_name_len];
- double colors[256][3];
-} lib_palette;
+ size_t count;
+ palette *p;
+} palette_collection;
#include "vector.h"
@@ -32,6 +45,10 @@ double4 hsv2rgb(double4);
double flam3_calc_alpha(double density, double gamma, double linrange);
double4 flam3_calc_newrgb(double4 cbuf, double ls, double highpow);
-
-#endif
+void palette_add (palette * const p, const double4 c);
+const palette *palette_random (const palette_collection * const pc, randctx * const rc);
+void palette_copy (const palette * const src, palette * const dest);
+void palette_rotate_hue (palette * const p, double rot);
+bool palette_read_collection (const char * const filename,
+ palette_collection * const pc);