c43e813a238e650c17e8dee441653d9037a86e18
kate
  Sun Apr 15 21:51:04 2018 -0700
Fix problem with r,g,b color specs.  Now also supports #RRGGBB anand 16 HTML color names. refs #21109

diff --git src/lib/basicBed.c src/lib/basicBed.c
index 63e10f5..ccfac91 100644
--- src/lib/basicBed.c
+++ src/lib/basicBed.c
@@ -8,30 +8,31 @@
  * stuff that's independent of the database and other genomic structures. */
 
 /* Copyright (C) 2014 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 
 #include "common.h"
 #include "hash.h"
 #include "linefile.h"
 #include "dystring.h"
 #include "sqlNum.h"
 #include "sqlList.h"
 #include "rangeTree.h"
 #include "binRange.h"
 #include "asParse.h"
+#include "htmlColor.h"
 #include "basicBed.h"
 
 
 void bedStaticLoad(char **row, struct bed *ret)
 /* Load a row from bed table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 ret->chrom = row[0];
 ret->chromStart = sqlUnsigned(row[1]);
 ret->chromEnd = sqlUnsigned(row[2]);
 ret->name = row[3];
 }
 
 struct bed *bedLoad(char **row)
 /* Load a bed from row fetched with select * from bed
@@ -1032,30 +1033,45 @@
 int wordCount;
 char *row[4];
 
 strncpy(dupe, itemRgb, sizeof(dupe));
 wordCount = chopString(dupe, ",", row, ArraySize(row));
 
 if ((wordCount != 3) || (!isdigit(row[0][0]) ||
     !isdigit(row[1][0]) || !isdigit(row[2][0])))
         return (-1);
 
 return ( ((atoi(row[0]) & 0xff) << 16) |
         ((atoi(row[1]) & 0xff) << 8) |
         (atoi(row[2]) & 0xff) );
 }
 
+int bedParseColor(char *colorSpec)
+/* Parse an HTML color string, a  string of 3 comma-sep unsigned color values 0-255, 
+ * or a 6-digit hex string  preceded by #. 
+ * O/w return unsigned integer value.  Return -1 on error */
+{
+if (strchr(colorSpec,','))
+    return bedParseRgb(colorSpec);
+unsigned rgb;
+if (htmlColorForCode(colorSpec, &rgb))
+    return rgb;
+if (htmlColorForName(colorSpec, &rgb))
+    return rgb;
+return sqlUnsigned(colorSpec);
+}
+
 long long bedTotalSize(struct bed *bedList)
 /* Add together sizes of all beds in list. */
 {
 long long total=0;
 struct bed *bed;
 for (bed = bedList; bed != NULL; bed = bed->next)
     total += (bed->chromEnd - bed->chromStart);
 return total;
 }
 
 void bedIntoRangeTree(struct bed *bed, struct rbTree *rangeTree)
 /* Add all blocks in bed to range tree.  For beds without blocks,
  * add entire bed. */
 {
 int i;