118c85b08418e8420033074af04884865ff07edd kate Thu Feb 19 17:12:17 2015 -0800 Libify graphics routine used for GTEX bar graph display. refs #13504 diff --git src/hg/inc/hvGfx.h src/hg/inc/hvGfx.h index 85a0a44..90f502b 100644 --- src/hg/inc/hvGfx.h +++ src/hg/inc/hvGfx.h @@ -69,30 +69,56 @@ } INLINE void hvGfxDot(struct hvGfx *hvg, int x, int y, int colorIx) /* Draw a single pixel. Try to work at a higher level when possible! */ { vgDot(hvg->vg, hvGfxAdjX(hvg, x), y, colorIx); } INLINE void hvGfxBox(struct hvGfx *hvg, int x, int y, int width, int height, int colorIx) /* Draw a box. */ { vgBox(hvg->vg, hvGfxAdjXW(hvg, x, width), y, width, height, colorIx); } +INLINE void hvGfxOutlinedBox(struct hvGfx *hvg, int x, int y, + int width, int height, int fillColorIx, int lineColorIx) +/* Draw a box in fillColor outlined by lineColor */ +{ +/* If nothing to draw bail out early. */ +if (width <= 0 || height <= 0) + return; + +/* Draw outline first, it may be all we need. We may not even need all 4 lines of it. */ +hvGfxBox(hvg, x, y, width, 1, lineColorIx); +if (height == 1) + return; +hvGfxBox(hvg, x, y+1, 1, height-1, lineColorIx); +if (width == 1) + return; +hvGfxBox(hvg, x+width-1, y+1, 1, height-1, lineColorIx); +if (width == 2) + return; +hvGfxBox(hvg, x+1, y+height-1, width-2, 1, lineColorIx); +if (height == 2) + return; + +/* Can draw fill with a single */ +hvGfxBox(hvg, x+1, y+1, width-2, height-2, fillColorIx); +} + INLINE void hvGfxLine(struct hvGfx *hvg, int x1, int y1, int x2, int y2, int colorIx) /* Draw a line from one point to another. */ { x1 = hvGfxAdjXX(hvg, x1, &x2, &y1, &y2); vgLine(hvg->vg, x1, y1, x2, y2, colorIx); } INLINE void hvGfxText(struct hvGfx *hvg, int x, int y, int colorIx, void *font, char *text) /* Draw a line of text with upper left corner x,y. */ { if (hvg->rc) { // FIXME: test