]> granicus.if.org Git - graphviz/commitdiff
add inkpot to the builds, although not yet used by dot
authorellson <devnull@localhost>
Wed, 1 Oct 2008 13:59:48 +0000 (13:59 +0000)
committerellson <devnull@localhost>
Wed, 1 Oct 2008 13:59:48 +0000 (13:59 +0000)
lib/inkpot/inkpot.c [new file with mode: 0644]
lib/inkpot/inkpot_scheme.c

diff --git a/lib/inkpot/inkpot.c b/lib/inkpot/inkpot.c
new file mode 100644 (file)
index 0000000..7da858a
--- /dev/null
@@ -0,0 +1,107 @@
+/* $Id$ $Revision$ */
+/* vim:set shiftwidth=4 ts=8: */
+
+/***********************************************************
+ *      This software is part of the graphviz package      *
+ *                http://www.graphviz.org/                 *
+ *                                                         *
+ *            Copyright (c) 1994-2008 AT&T Corp.           *
+ *                and is licensed under the                *
+ *            Common Public License, Version 1.0           *
+ *                      by AT&T Corp.                      *
+ *                                                         *
+ *        Information and Software Systems Research        *
+ *              AT&T Research, Florham Park NJ             *
+ **********************************************************/
+
+#include <stdio.h>
+#include <assert.h>
+
+#include "inkpot.h"
+
+int main (int argc, char *argv[])
+{
+    inkpot_t *inkpot;
+    inkpot_status_t rc;
+    char *color;
+    double rgba[4], hsva[4], cmyk[4];
+
+    inkpot = inkpot_init();
+    if (!inkpot) {
+       fprintf(stderr, "failure to initialize inkpot\n");
+       return 0;
+    }
+    /* requested color */
+    if (argc < 2)
+        color = NULL;
+    else
+        color = argv[1];
+
+    /* requested schemes (comma-separated) */
+    if (argc < 3) {
+        rc = inkpot_schemes(inkpot, "x11");
+        assert(rc == INKPOT_SUCCESS);
+    }
+    else {
+        rc = inkpot_schemes(inkpot, argv[2]);
+        if (rc == INKPOT_SCHEME_UNKNOWN)
+           inkpot_debug_error(inkpot);
+        else
+            assert(rc == INKPOT_SUCCESS);
+    }
+
+    /* target scheme */
+    if (argc < 4) {
+        rc = inkpot_translate(inkpot, "x11");
+        assert(rc == INKPOT_SUCCESS);
+    }
+    else {
+        rc = inkpot_translate(inkpot, argv[3]);
+        if (rc == INKPOT_SCHEME_UNKNOWN)
+           inkpot_debug_error(inkpot);
+        else
+            assert(rc == INKPOT_SUCCESS);
+    }
+
+    inkpot_debug_schemes(inkpot);
+    
+#if 0
+    inkpot_debug_names(inkpot);
+
+    inkpot_debug_out_names(inkpot);
+
+    inkpot_debug_values(inkpot);
+#endif
+
+    fprintf(stdout, "%s ", color); /* ' ' after %s so it doesn't crash on NULL */
+    rc = inkpot_set(inkpot, color);
+    if (rc == INKPOT_COLOR_UNKNOWN)
+        fprintf(stdout, "(unknown)");
+    fprintf(stdout, "\n text: ");
+
+    rc = inkpot_write(inkpot);
+    if (rc == INKPOT_COLOR_NONAME || rc == INKPOT_NOPALETTE) {
+        fprintf(stdout, "#");
+        rc = inkpot_write_rgba8(inkpot);
+    }
+    assert (rc == INKPOT_SUCCESS);
+
+    rc = inkpot_get_rgba(inkpot, rgba);
+    assert (rc == INKPOT_SUCCESS);
+    fprintf(stdout, "\n rgba: %.3f,%.3f,%.3f,%.3f\n",
+               rgba[0], rgba[1], rgba[2], rgba[3]);
+
+    rc = inkpot_get_hsva(inkpot, hsva);
+    assert (rc == INKPOT_SUCCESS);
+    fprintf(stdout, " hsva: %.3f,%.3f,%.3f,%.3f\n",
+               hsva[0], hsva[1], hsva[2], hsva[3]);
+
+    rc = inkpot_get_cmyk(inkpot, cmyk);
+    assert (rc == INKPOT_SUCCESS);
+    fprintf(stdout, " cmyk: %.3f,%.3f,%.3f,%.3f\n",
+               cmyk[0], cmyk[1], cmyk[2], cmyk[3]);
+
+    inkpot_destroy(inkpot);
+    return 0;
+}
index 5b398ae8ad161969d10723ee7b8373be7096c80f..ae05414bb660276d6c36b75ce044be2296c5bf36 100644 (file)
@@ -140,7 +140,7 @@ static inkpot_status_t inkpot_scheme ( inkpot_t *inkpot, const char *scheme )
  
 inkpot_status_t inkpot_schemes ( inkpot_t *inkpot, const char *schemes )
 {
-    inkpot_status_t rc;
+    inkpot_status_t rc = INKPOT_SUCCESS;
     const char *q;
     char *p, *s, c;
     int len;
@@ -923,7 +923,7 @@ inkpot_status_t inkpot_debug_values( inkpot_t *inkpot )
 
 inkpot_status_t inkpot_debug_error ( inkpot_t *inkpot )
 {
-    const char *m;
+    const char *m = "\nINKPOT_FAIL\n";
 
     assert(inkpot);
     switch (inkpot->status) {