d30c1af4dafde144c9b83d129a97ebb65399e77d
kent
  Thu Feb 21 14:57:46 2013 -0800
Making reverse work with new transparency code.
diff --git src/hg/hgTracks/multiWig.c src/hg/hgTracks/multiWig.c
index 9c07c61..f73392c 100644
--- src/hg/hgTracks/multiWig.c
+++ src/hg/hgTracks/multiWig.c
@@ -104,50 +104,66 @@
     p[1] *= g;
     p[2] *= b;
     }
 }
 
 struct wigGraphOutput *wigGraphOutputTransparent(struct floatPic *image)
 /* Get appropriate wigGraphOutput for non-transparent rendering */
 {
 struct wigGraphOutput *wgo;
 AllocVar(wgo);
 wgo->image = image;
 wgo->vLine = vLineViaFloat;
 return wgo;
 }
 
+static void reverseLineOfColors(Color *line, int length)
+/* Reverse order of colors in line. */
+{
+long halfLen = (length>>1);
+Color *end = line+length;
+char c;
+while (--halfLen >= 0)
+    {
+    c = *line;
+    *line++ = *--end;
+    *end = c;
+    }
+}
+
 void floatPicIntoHvg(struct floatPic *pic, int xOff, int yOff, struct hvGfx *hvg)
 /* Copy float pic into hvg at given offset. */
 {
 int width = pic->width, height = pic->height;
 Color *lineBuf;
 AllocArray(lineBuf, width);
 int y;
 for (y=0; y<height; ++y)
     {
     float *fp = pic->lines[y];
     Color *cp = lineBuf;
     int i = width;
     while (--i >= 0)
         {
 	int red = fp[0]*255.9;
 	int green = fp[1]*255.9;
 	int blue = fp[2]*255.9;
 	*cp++ = MAKECOLOR_32(red, green, blue);
 	fp += 3;
 	}
+    if (hvg->rc)
+        reverseLineOfColors(lineBuf, width);
     hvGfxVerticalSmear(hvg, xOff, y + yOff, width, 1, lineBuf, TRUE);
     }
 freez(&lineBuf);
 }
 
 
 static void minMaxVals(struct slRef *refList, double *retMin, double *retMax,
      enum wiggleAlwaysZeroEnum alwaysZero)
 /* Figure out min/max of everything in list.  The refList contains pointers to
  * preDrawContainers */
 {
 /* Turns out to be *much* shorter to rewrite than to reuse preDrawAutoScale */
 double max = -BIGDOUBLE, min = BIGDOUBLE;
 struct slRef *ref;
 for (ref = refList; ref != NULL; ref = ref->next)