b8180d9f6d41dc708a2f249ba892cbca311e7a06 jcasper Mon Feb 27 11:38:55 2023 -0800 Adding transparency support for colors refs #30569 diff --git src/hg/hgTracks/variation.c src/hg/hgTracks/variation.c index b792bd3..59cd5cf 100644 --- src/hg/hgTracks/variation.c +++ src/hg/hgTracks/variation.c @@ -587,32 +587,32 @@ static char mapName[256]; struct snp125 *snp = item; safecpy(mapName, sizeof(mapName), snp->name); char *ptr = strchr(mapName, ' '); if (ptr != NULL) *ptr = '\0'; return mapName; } static Color snp132ColorByAlleleFreq(struct snp132Ext *snp, struct hvGfx *hvg) /* If snp has allele freq data, return a shade from red (rare) to blue (common); * otherwise return black. */ { static boolean colorsInited = FALSE; static Color redToBlue[EXPR_DATA_SHADES]; -static struct rgbColor red = {255, 0, 0}; -static struct rgbColor blue = {0, 0, 255}; +static struct rgbColor red = {255, 0, 0, 255}; +static struct rgbColor blue = {0, 0, 255, 255}; if (!colorsInited) hvGfxMakeColorGradient(hvg, &red, &blue, EXPR_DATA_SHADES, redToBlue); if (snp->alleleFreqCount > 0) { float majorAlF = snp132MajorAlleleFreq(snp); // >2 common alleles (e.g. at VNTR sites) can cause low major allele freq; // cap at 0.5 to avoid overflow in the shade calculation. if (majorAlF < 0.5) majorAlF = 0.5; if (majorAlF > 1.0) majorAlF = 1.0; // Shade on a scale of 100% (red) to 50% (blue): int shadeIndex = (int)((1.0 - 2.0*(majorAlF - 0.5)) * (EXPR_DATA_SHADES-1)); return redToBlue[shadeIndex]; } @@ -1541,34 +1541,34 @@ tg->itemName = perlegenName; } /*******************************************************************/ /* Declare our color gradients and the the number of colors in them */ Color ldShadesPos[LD_DATA_SHADES]; Color ldHighLodLowDprime; /* pink */ Color ldHighDprimeLowLod; /* blue */ int colorLookup[256]; void ldShadesInit(struct track *tg, struct hvGfx *hvg, boolean isDprime) /* Allocate the LD for positive and negative values, and error cases */ { -static struct rgbColor white = {255, 255, 255}; -static struct rgbColor red = {255, 0, 0}; -static struct rgbColor green = { 0, 255, 0}; -static struct rgbColor blue = { 0, 0, 255}; +static struct rgbColor white = {255, 255, 255, 255}; +static struct rgbColor red = {255, 0, 0, 255}; +static struct rgbColor green = { 0, 255, 0, 255}; +static struct rgbColor blue = { 0, 0, 255, 255}; char *ldPos = NULL; ldPos = cartUsualStringClosestToHome(cart, tg->tdb, FALSE, "_pos", ldPosDefault); ldHighLodLowDprime = hvGfxFindColorIx(hvg, 255, 224, 224); /* pink */ ldHighDprimeLowLod = hvGfxFindColorIx(hvg, 192, 192, 240); /* blue */ if (sameString(ldPos,"red")) hvGfxMakeColorGradient(hvg, &white, &red, LD_DATA_SHADES, ldShadesPos); else if (sameString(ldPos,"blue")) hvGfxMakeColorGradient(hvg, &white, &blue, LD_DATA_SHADES, ldShadesPos); else if (sameString(ldPos,"green")) hvGfxMakeColorGradient(hvg, &white, &green, LD_DATA_SHADES, ldShadesPos); else errAbort("LD fill color must be 'red', 'blue', or 'green'; '%s' is not recognized", ldPos); }