]> git.cworth.org Git - acre/commitdiff
Add some distinguishing colors for the datasets
authorCarl Worth <cworth@cworth.org>
Tue, 27 Jan 2009 19:48:46 +0000 (11:48 -0800)
committerCarl Worth <cworth@cworth.org>
Thu, 16 Apr 2009 19:05:55 +0000 (12:05 -0700)
This is quite cheesy for now. It's just three hard-coded, primary colors.
(Much nicer would be to take N evenly-spaced colors from a percpetually
linear space.) But this gives us parity with the functionality of the
original motorsim plot, so it's enough for getting us closer to being
able to replace that.

acre.c

diff --git a/acre.c b/acre.c
index e444e30557222e0ee73b7af7138a32a3f46213f9..12be71d249952421f0fb17caa956e3cd74377a0f 100644 (file)
--- a/acre.c
+++ b/acre.c
@@ -502,6 +502,16 @@ _draw_data (acre_t *acre)
     cairo_t *cr = acre->cr;
     unsigned int d, i;
     acre_data_t *data;
+#define NUM_COLORS 3
+    struct {
+       double r;
+       double g;
+       double b;
+    } colors [NUM_COLORS] = {
+       {1, 0, 0},
+       {0, 1, 0},
+       {0, 0, 1}
+    };
 
     cairo_save (cr);
 
@@ -510,6 +520,11 @@ _draw_data (acre_t *acre)
     _set_transform_to_data_space (acre);
 
     for (d = 0; d < acre->num_data; d++) {
+       int color = d % NUM_COLORS;
+       cairo_set_source_rgb (cr,
+                             colors[color].r,
+                             colors[color].g,
+                             colors[color].b);
        data = acre->data[d];
        cairo_new_path (cr);
        for (i = 0; i < data->num_points; i++) {