31059016e90d9d6d65e11f55808869efacb8d4e2 kate Tue Apr 10 18:16:17 2018 -0700 Add postscript for ellipse drawing. refs #21109 diff --git src/hg/inc/hvGfx.h src/hg/inc/hvGfx.h index 2acc739..ca7509d 100644 --- src/hg/inc/hvGfx.h +++ src/hg/inc/hvGfx.h @@ -10,34 +10,30 @@ struct hvGfx /* browser graphics interface */ { struct hvGfx *next; /* Next in list. */ struct vGfx *vg; /* virtual graphics object */ boolean rc; /* reverse-complement display (negative strand) */ boolean pixelBased; /* Real pixels, not PostScript or something. */ int width, height; /* Virtual pixel dimensions. */ int clipMinX; /* X clipping region, before reverse */ int clipMaxX; int clipMinY; int clipMaxY; }; -#define ELLIPSE_FULL 0 -#define ELLIPSE_TOP 1 -#define ELLIPSE_BOTTOM 2 - struct hvGfx *hvGfxOpenPng(int width, int height, char *fileName, boolean useTransparency); /* Open up something that we'll write out as a PNG someday. * If useTransparency, then the first color in memgfx's colormap/palette is * assumed to be the image background color, and pixels of that color * are made transparent. */ struct hvGfx *hvGfxOpenPostScript(int width, int height, char *fileName); /* Open up something that will someday be a PostScript file. */ void hvGfxClose(struct hvGfx **pHvg); /* Close down virtual graphics object, and finish writing it to file. */ INLINE int hvGfxAdjX(struct hvGfx *hvg, int x) /* Return an X position, updating if reverse-complement mode */ { @@ -229,30 +225,41 @@ for (i = 0; i < poly->ptCount; i++, pt = pt->next) pt->x = hvg->width - (pt->x+1); } INLINE void hvGfxDrawPoly(struct hvGfx *hvg, struct gfxPoly *poly, Color color, boolean filled) /* Draw polygon, possibly filled in color. */ { if (hvg->rc) hvGfxRevPoly(hvg, poly); vgDrawPoly(hvg->vg, poly, color, filled); if (hvg->rc) hvGfxRevPoly(hvg, poly); // restore } +INLINE void hvGfxEllipseDraw(struct hvGfx *hvg, int x1, int y1, int x2, int y2, Color color, + int mode, boolean isDashed) +/* Draw an ellipse (or limit to top or bottom) specified by rectangle. + * Optionally, alternate dots. + * Point 0 is left, point 1 is top of rectangle. + */ +{ +x1 = hvGfxAdjXX(hvg, x1, &x2, &y1, &y2); +vgEllipse(hvg->vg, x1, y1, x2, y2, color, mode, isDashed); +} + INLINE int hvGfxFindColorIx(struct hvGfx *hvg, int r, int g, int b) /* Find color in map if possible, otherwise create new color or * in a pinch a close color. */ { return vgFindColorIx(hvg->vg, r, g, b); } INLINE struct rgbColor hvGfxColorIxToRgb(struct hvGfx *hvg, int colorIx) /* Return rgb values for given color index. */ { return vgColorIxToRgb(hvg->vg, colorIx); }; INLINE void hvGfxSetHint(struct hvGfx *hvg, char *hint, char *value) /* Set hint */ @@ -307,33 +314,27 @@ void hvGfxNextItemButton(struct hvGfx *hvg, int x, int y, int w, int h, Color color, Color hvgColor, boolean nextItem); /* Draw a button that looks like a fast-forward or rewind button on */ /* a remote control. If nextItem is TRUE, it points right, otherwise */ /* left. color is the outline color, and hvgColor is the fill color. */ void hvGfxEllipseDraw(struct hvGfx *hvg, int x0, int y0, int x1, int y1, Color color, int mode, boolean isDotted); /* Draw an ellipse (or limit to top or bottom) specified by rectangle, using Bresenham algorithm. * Optionally, alternate dots. * Point 0 is left, point 1 is top of rectangle * Adapted trivially from code posted at http://members.chello.at/~easyfilter/bresenham.html */ -void hvGfxEllipse(struct hvGfx *hvg, int x0, int y0, int x1, int y1, Color color); -/* Draw an ellipse using Bresenham algorithm. - * Point 0 is left, point 1 is top - * Adapted trivially from code posted at http://members.chello.at/~easyfilter/bresenham.html - */ - int hvGfxCurve(struct hvGfx *hvg, int x0, int y0, int x1, int y1, int x2, int y2, Color color, boolean isDotted); /* Draw a segment of an anti-aliased curve within 3 points (quadratic Bezier) * Return max y value. Optionally alternate dots. * Adapted trivially from code posted at http://members.chello.at/~easyfilter/bresenham.html */ /* Thanks to author * @author Zingl Alois * @date 22.08.2016 */ void hvGfxDottedLine(struct hvGfx *hvg, int x1, int y1, int x2, int y2, Color color, boolean isDash); /* Brezenham line algorithm, alternating dots, by 1 pixel or two (isDash true) */ #endif