]> granicus.if.org Git - graphviz/commitdiff
add tk colors
authorellson <devnull@localhost>
Wed, 1 Oct 2008 02:11:14 +0000 (02:11 +0000)
committerellson <devnull@localhost>
Wed, 1 Oct 2008 02:11:14 +0000 (02:11 +0000)
lib/inkpot/inkpot_scheme.c
lib/inkpot/inkpot_scheme.h
lib/inkpot/inkpot_value.c
lib/inkpot/test/inkpot_define.h
lib/inkpot/test/inkpot_scheme_table.h
lib/inkpot/test/inkpot_value_table.h

index 6b2ee5d9f611601313117e4023d4e204ac754a1e..5b398ae8ad161969d10723ee7b8373be7096c80f 100644 (file)
@@ -77,7 +77,7 @@ static int string_cmpf (const char *k, const char *b)
 static int inkpot_scheme_name_cmpf ( const void *key, const void *base)
 {
     const char *k = (const char*)key;
-    const char *b = &TAB_STRINGS[((inkpot_scheme_name_t *)base)->string_idx];
+    const char *b = &TAB_SCHEME_STRINGS[((inkpot_scheme_name_t *)base)->string_idx];
 
     return string_cmpf(k, b);
 }
@@ -95,7 +95,7 @@ static inkpot_scheme_name_t *inkpot_find_scheme_name ( const char *scheme )
 static int inkpot_scheme_index_cmpf ( const void *key, const void *base)
 {
     const char *k = (const char*)key;
-    const char *b = &TAB_STRINGS[((inkpot_scheme_index_t *)base)->string_idx];
+    const char *b = &TAB_SCHEME_STRINGS[((inkpot_scheme_index_t *)base)->string_idx];
 
     return string_cmpf(k, b);
 }
@@ -225,7 +225,7 @@ inkpot_status_t inkpot_palette( inkpot_t *inkpot, int size )
 static int inkpot_name_cmpf ( const void *key, const void *base)
 {
     const char *k = (const char*)key;
-    const char *b = &TAB_STRINGS[((inkpot_name_t *)base)->string_idx];
+    const char *b = &TAB_COLOR_STRINGS[((inkpot_name_t *)base)->string_idx];
 
     return string_cmpf(k, b);
 }
@@ -259,7 +259,7 @@ static inkpot_status_t inkpot_cache_get( inkpot_t *inkpot )
            continue;
 
        cache_name_idx = inkpot->cache[i].name_idx;
-       cache_color = &TAB_STRINGS[TAB_NAMES[cache_name_idx].string_idx];
+       cache_color = &TAB_COLOR_STRINGS[TAB_NAMES[cache_name_idx].string_idx];
        if (cache_color[0] != color[0] || (strcmp(cache_color, color) != 0))
            continue;
 
@@ -482,7 +482,7 @@ inkpot_status_t inkpot_set ( inkpot_t *inkpot, const char *color )
        *++q = '\0';
        for (i=0; i < inkpot->active_schemes; i++) {
            j = inkpot->scheme_list[i];
-           p = &TAB_STRINGS[TAB_SCHEMES_INDEX[j].string_idx];
+           p = &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[j].string_idx];
            if (*p != *s || strcmp(p, s) != 0) 
                continue;
            first = TAB_SCHEMES_INDEX[j].first_value_idx;
@@ -528,7 +528,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
     
     out_name = inkpot->out_name;
     if (out_name) {  /* if we have a cached name */
-       *color = &TAB_STRINGS[out_name->string_idx];
+       *color = &TAB_COLOR_STRINGS[out_name->string_idx];
         return ((inkpot->status = INKPOT_SUCCESS));
     }
     
@@ -545,7 +545,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
                         break;
                     if (out_name->scheme_bits & inkpot->out_scheme_bit) {
                        inkpot->out_name = out_name;
-                        *color = &TAB_STRINGS[out_name->string_idx];
+                        *color = &TAB_COLOR_STRINGS[out_name->string_idx];
                        return ((inkpot->status = INKPOT_SUCCESS));
                    }
                 }
@@ -556,7 +556,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
                            maybe++;
                            if (inkpot->out_scheme_bit & TAB_ALTS[i].scheme_bits) {
                                inkpot->out_name = out_name;
-                                *color = &TAB_STRINGS[out_name->string_idx];
+                                *color = &TAB_COLOR_STRINGS[out_name->string_idx];
                                return ((inkpot->status = INKPOT_SUCCESS));
                            }
                        }
@@ -750,28 +750,27 @@ inkpot_status_t inkpot_debug_schemes( inkpot_t *inkpot )
        found = 0;
         if ((1<<i) & inkpot->scheme_bits) {
             errputs(inkpot, " ");
-            errputs(inkpot, &TAB_STRINGS[TAB_SCHEMES[i].string_idx]);
-            errputs(inkpot, "(names) (in)");
+            errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES[i].string_idx]);
+            errputs(inkpot, "(in)");
            found++;
         }
         if ((1<<i) & inkpot->out_scheme_bit) {
            if (! found) {
                 errputs(inkpot, " ");
-                errputs(inkpot, &TAB_STRINGS[TAB_SCHEMES[i].string_idx]);
-                errputs(inkpot, "(names)");
+                errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES[i].string_idx]);
+                errputs(inkpot, "(out)");
            }
-            errputs(inkpot, " (out)");
         }
     }
     for (j = 0; j < inkpot->active_schemes; j++) {
         errputs(inkpot, " ");
-        errputs(inkpot, &TAB_STRINGS[TAB_SCHEMES_INDEX[inkpot->scheme_list[j]].string_idx]);
-        errputs(inkpot, "(index) (in)\n");
+        errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->scheme_list[j]].string_idx]);
+        errputs(inkpot, "#(in)");
     }
     for (j = 0; j < inkpot->active_out_schemes; j++) {
         errputs(inkpot, " ");
-        errputs(inkpot, &TAB_STRINGS[TAB_SCHEMES_INDEX[inkpot->out_scheme_list[j]].string_idx]);
-        errputs(inkpot, "(index) (out)\n");
+        errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_INDEX[inkpot->out_scheme_list[j]].string_idx]);
+        errputs(inkpot, "#(out)");
     }
     errputs(inkpot, "\n");
 
@@ -789,7 +788,7 @@ static inkpot_status_t inkpot_debug_scheme_names( inkpot_t *inkpot, int scheme_b
         if ((1 << i) & scheme_bits) {
             if (found++)
                 errputs(inkpot, " ");
-            errputs(inkpot, &TAB_STRINGS[TAB_SCHEMES_NAME[i].string_idx]);
+            errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES_NAME[i].string_idx]);
         }
     }
     errputs(inkpot, ")");
@@ -828,7 +827,7 @@ static inkpot_status_t inkpot_debug_names_schemes( inkpot_t *inkpot, MSK_SCHEMES
         for (i = 0; i < SZT_NAMES; i++) {
             name = &TAB_NAMES[i];
             if (scheme_bits & name->scheme_bits) {
-                errputs(inkpot, &TAB_STRINGS[TAB_NAMES[i].string_idx]);
+                errputs(inkpot, &TAB_SCHEME_STRINGS[TAB_NAMES[i].string_idx]);
                inkpot_debug_scheme_names(inkpot, scheme_bits);
                errputs(inkpot, " ");
                inkpot_debug_rgba(inkpot, TAB_VALUES[name->value_idx].value);
@@ -849,7 +848,7 @@ static inkpot_status_t inkpot_debug_names_schemes( inkpot_t *inkpot, MSK_SCHEMES
            v = TAB_IXVALUES[k];
            sprintf(buf, "%d(", k - first);
            errputs(inkpot, buf);
-           errputs(inkpot, &TAB_STRINGS[scheme_index->string_idx]);
+           errputs(inkpot, &TAB_COLOR_STRINGS[scheme_index->string_idx]);
            errputs(inkpot, ") ");
            if (v < SZT_VALUES)
                inkpot_debug_rgba(inkpot, TAB_VALUES[v].value);
@@ -909,7 +908,7 @@ inkpot_status_t inkpot_debug_values( inkpot_t *inkpot )
                 else
                    inkpot_debug_rgba(inkpot, TAB_VALUES[i].value);
                 errputs(inkpot, " ");
-                errputs(inkpot, &TAB_STRINGS[name->string_idx]);
+                errputs(inkpot, &TAB_COLOR_STRINGS[name->string_idx]);
                inkpot_debug_scheme_names(inkpot, scheme_bits);
             }
         }
index 59950c922496c9f21702497440f0d2539219e910..497d4f3ee03d2fdfd47af96882eb29f81a767992 100644 (file)
@@ -21,12 +21,12 @@ typedef unsigned char IDX_MRU_CACHE;
 #define SZT_MRU_CACHE 4
 
 typedef struct inkpot_scheme_name_s {
-       IDX_STRINGS
+       IDX_SCHEME_STRINGS
             string_idx;        /* The scheme name in TAB_STRINGS.  (e.g. "x11") */
 } inkpot_scheme_name_t;
 
 typedef struct inkpot_scheme_index_s { 
-       IDX_STRINGS
+       IDX_SCHEME_STRINGS
             string_idx;        /* The indexed scheme name in TAB_STRINGS. 
                                 * e.g "blues7" from Brewer */
        IDX_IXVALUES
@@ -45,8 +45,8 @@ typedef struct inkpot_name_s {        /* Color_name used by one or more
                                 * inkpot_names_t are alpha sorted in
                                 * TAB_NAMES[] */
 
-       IDX_STRINGS
-           string_idx;         /* The color name in TAB_STRINGS.
+       IDX_COLOR_STRINGS
+           string_idx;         /* The color name in TAB_COLOR_STRINGS.
                                 * (e.g. "green") */
 
        IDX_VALUES
index b25e4ea6887b8023172b3141689d13bf58e5605b..a0afb91532a9d39276ee489a80be630923d1fbd0 100644 (file)
@@ -49,7 +49,14 @@ inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *valu
        value->vtype = VTYPE_rgba;  /* FIXME */
     }
     else if (value->index - SZT_VALUES < SZT_NONAME_VALUES) {
-       value->value = TAB_NONAME_VALUES[value->index - SZT_VALUES];
+       i = 3 * value->index;
+
+       value->value  = TAB_NONAME_VALUES_24[i++] << 16;
+       value->value |= TAB_NONAME_VALUES_24[i++] << 16;
+       value->value |= TAB_NONAME_VALUES_24[i] << 16;
+       value->value |= 0xff;
+       value->value |= value->value << 8;
+
        value->vtype = VTYPE_rgba;  /* FIXME */
     }
     else if (value->index == SZT_VALUES + SZT_NONAME_VALUES) {
index 0ca7b10b466562b847f2d346be59415da3c62238..bad79ca10cf6610a725753fbea0a846850a920ac 100644 (file)
  *              AT&T Research, Florham Park NJ             *
  **********************************************************/
 
-typedef unsigned int   IDX_STRINGS;
-#define SZT_STRINGS 79
-#define SZL_STRINGS 6
+#define SZT_COLOR_STRINGS 57
+#define SZL_COLOR_STRINGS 6
+typedef unsigned int   IDX_COLOR_STRINGS;
 
+#define SZT_SCHEME_STRINGS 23
+#define SZL_SCHEME_STRINGS 6
+typedef unsigned int   IDX_SCHEME_STRINGS;
+
+#define SZT_SCHEMES 3
 typedef unsigned short MSK_SCHEMES;
 typedef unsigned char  IDX_SCHEMES;
-#define SZT_SCHEMES 3
 
-typedef unsigned char  IDX_SCHEMES_INDEX;
 #define SZT_SCHEMES_INDEX 2
+typedef unsigned char  IDX_SCHEMES_INDEX;
 
-typedef unsigned int   IDX_NAMES;
 #define SZT_NAMES 10
+typedef unsigned int   IDX_NAMES;
 
-typedef unsigned char  IDX_ALTS;
 #define SZT_ALTS 2
+typedef unsigned char  IDX_ALTS;
 
-typedef unsigned int   IDX_IXVALUES;
 #define SZT_IXVALUES 7
+typedef unsigned int   IDX_IXVALUES;
 
-typedef unsigned int   IDX_VALUE_TO;
 #define SZT_VALUE_TO 7
+typedef unsigned int   IDX_VALUE_TO;
 
-typedef unsigned int   IDX_TO_NAMES;
 #define SZT_TO_NAMES 11
+typedef unsigned int   IDX_TO_NAMES;
+
 
-typedef unsigned int   IDX_VALUES;
 #define SZT_VALUES 7
+typedef unsigned char  IDX_VALUES;
+
+#define SZT_VALUES_64 7
+typedef unsigned char  IDX_VALUES_64;
+
+#define SZT_VALUES_24 21
+typedef unsigned char  IDX_VALUES_24;
+
 #define SZT_NONAME_VALUES 4
+#define SZT_NONAME_VALUES_64 4
+#define SZT_NONAME_VALUES_24 12
index 8f3e6be2afede0ec702dc85aa6a24a47e683a223..700555b76fa048b950260015e2baaa8f08b7428b 100644 (file)
  *              AT&T Research, Florham Park NJ             *
  **********************************************************/
 
-const char TAB_STRINGS[SZT_STRINGS] = {
-       "french\0"
-       "svg\0"
-       "x11\0" 
+const char TAB_COLOR_STRINGS[SZT_COLOR_STRINGS] = {
        "black\0"
        "bleu\0"
        "blue\0"
@@ -26,8 +23,14 @@ const char TAB_STRINGS[SZT_STRINGS] = {
        "red\0" 
        "rouge\0"
        "vert\0"
-       "yellow\0"
        "white\0"
+       "yellow\0"
+};
+
+const char TAB_SCHEME_STRINGS[SZT_SCHEME_STRINGS] = {
+       "french\0"
+       "svg\0"
+       "x11\0" 
        "xxx\0"
        "yyy\0"
 };
@@ -39,21 +42,21 @@ inkpot_scheme_name_t TAB_SCHEMES[SZT_SCHEMES] = { /* schemes of named colors */
 };
 
 inkpot_scheme_index_t TAB_SCHEMES_INDEX[SZT_SCHEMES_INDEX] = { /* schemes of indexed colors */
-       { 71, 0, }, /* xxx */
-       { 75, 5, }, /* yyy */
+       { 15, 0, }, /* xxx */
+       { 19, 5, }, /* yyy */
 };
 
 inkpot_name_t TAB_NAMES[SZT_NAMES] = { /* Must be LC_ALL=C sort'ed by name with each alt */
-       { 15, 0, 0x6, }, /* black */
-       { 21, 1, 0x1, }, /* bleu */
-       { 26, 1, 0x6, }, /* blue */
-       { 31, 2, 0x6, }, /* green */
-       { 37, 5, 0x1, }, /* jaune */
-       { 43, 3, 0x6, }, /* red */ 
-       { 47, 3, 0x1, }, /* rouge */
-       { 53, 2, 0x1, }, /* vert */
-       { 65, 6, 0x6, }, /* white */
-       { 58, 0, 0, },   /* yellow */
+       { 0,  0, 0x6, }, /* black */
+       { 6,  1, 0x1, }, /* bleu */
+       { 11, 1, 0x6, }, /* blue */
+       { 16, 2, 0x6, }, /* green */
+       { 22, 5, 0x1, }, /* jaune */
+       { 28, 3, 0x6, }, /* red */ 
+       { 32, 3, 0x1, }, /* rouge */
+       { 38, 2, 0x1, }, /* vert */
+       { 43, 6, 0x6, }, /* white */
+       { 50, 0,   0, }, /* yellow (w. alts) */
 };
 
 inkpot_name_t TAB_ALTS[SZT_ALTS] = {
index 0c8a410bbbc4cc187101adbffd9577f8f941bb63..620183b2300a447aa3d1ca64ef421d4f600e6f9c 100644 (file)
@@ -14,7 +14,7 @@
  *              AT&T Research, Florham Park NJ             *
  **********************************************************/
 
-unsigned long TAB_VALUES[SZT_VALUES] = {
+unsigned long TAB_VALUES_64[SZT_VALUES_64] = {
     0x000000000000ffff,  /* black */
     0x00000000ffffffff,  /* bleu, blue */
     0x0000ffff0000ffff,  /* green, vert */
@@ -24,9 +24,26 @@ unsigned long TAB_VALUES[SZT_VALUES] = {
     0xffffffffffffffff,  /* white */
 }; 
 
-unsigned long TAB_NONAME_VALUES[SZT_NONAME_VALUES] = {
+unsigned long TAB_NONAME_VALUES_64[SZT_NONAME_VALUES_64] = {
     0x000000008000ffff,
     0x00000000a400ffff,
     0x00000000c800ffff,
     0x00000000ea00ffff,
 }; 
+
+unsigned char TAB_VALUES_24[SZT_VALUES_24] = {
+      0,   0,   0,  /* black */
+      0,   0, 255,  /* bleu, blue */
+      0, 255,   0,  /* green, vert */
+    255,   0,   0,  /* red, rouge */
+    255, 192,   0,  /* yellow (svg) */
+    255, 255, 255,  /* yellow (x11), jaune */
+    255, 255, 255,  /* white */
+}; 
+
+unsigned char TAB_NONAME_VALUES_24[SZT_NONAME_VALUES_24] = {
+      0,   0, 128,
+      0,   0, 160,
+      0,   0, 192,
+      0,   0, 224,
+};