#include "inkpot.h"
#include "inkpot_tables.h"
-#include "inkpot_xlate.h"
static size_t inkpot_writer (void *closure, const char *data, size_t length)
{
last = SZT_IXVALUES;
else
last = TAB_SCHEMES_INDEX[j].first_value_idx;
+ last = last-1-first;
/* clip user-provided index to fit available range */
- index = MAX(index, 0);
- index = MIN(index, (last-1-first));
+ index = (index < 0) ? 0 : index;
+ index = (index > last) ? last : index;
index += first;
assert(index < SZT_IXVALUES);
- v = inkpot->value_idx = TAB_IXVALUES[index];
+ v = TAB_IXVALUES[index];
if (v >= SZT_VALUES)
assert(v < SZT_VALUES + SZT_NONAME_VALUES);
+
+ if (inkpot->value_idx != v) {
+ inkpot->value_idx = v;
+ inkpot->name = NULL;
+ inkpot->out_name = NULL;
+ }
+
return ((inkpot->status = INKPOT_SUCCESS));
}
{
if (inkpot->value_idx != inkpot->default_value_idx) {
inkpot->value_idx = inkpot->default_value_idx;
- inkpot->name = NULL; /* FIXME - should set this */
+ inkpot->name = NULL;
inkpot->out_name = NULL;
}
return ((inkpot->status = INKPOT_SUCCESS));
default_value_idx, /* The default color */
value_idx; /* The current color value. */
+ IDX_IXVALUES
+ index, /* The index for the current value, if indexed scheme not NULL */
+ out_index; /* The index for the current value, if indexed output scheme not NULL */
+
inkpot_scheme_index_t
*scheme_index, /* Indexed input scheme, or NULL. */
*out_scheme_index; /* Indexed output scheme, or NULL */
#include "inkpot.h"
#include "inkpot_xlate.h"
+#ifndef MIN
+#define MIN(a,b) ((a)<(b)?(a):(b))
+#endif
+
+#ifndef MAX
+#define MAX(a,b) ((a)>(b)?(a):(b))
+#endif
+
static void hsv2rgb(double h, double s, double v, double *r, double *g, double *b)
{
int i;
extern "C" {
#endif
-#ifndef MIN
-#define MIN(a,b) ((a)<(b)?(a):(b))
-#endif
-
-#ifndef MAX
-#define MAX(a,b) ((a)>(b)?(a):(b))
-#endif
-
/* possible representations of color in gvcolor_t */
typedef enum { HSVA_DOUBLE, RGBA_BYTE, RGBA_WORD, CMYK_BYTE,
RGBA_DOUBLE, COLOR_STRING, COLOR_INDEX } color_type_t;