66ee7c172964fe9665479973fa7c7536afe03fa2 kate Tue Apr 10 22:05:33 2018 -0700 Add Postscript for bezier curve. Fix ellipse. refs #21109 diff --git src/hg/inc/hvGfx.h src/hg/inc/hvGfx.h index ca7509d..f16d472 100644 --- src/hg/inc/hvGfx.h +++ src/hg/inc/hvGfx.h @@ -33,31 +33,31 @@ 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 */ { if (hvg->rc) return hvg->width - (x+1); else return x; } INLINE int hvGfxAdjXX(struct hvGfx *hvg, int x1, int *x2Ptr, int *y1Ptr, int *y2Ptr) -/* Update a pair of coordinates if reverse-coordiates mode */ +/* Update a pair of coordinates if reverse-coordinates mode */ { if (hvg->rc) { reverseIntRange(&x1, x2Ptr, hvg->width); int hold = *y1Ptr; *y1Ptr = *y2Ptr; *y2Ptr = hold; } return x1; } INLINE int hvGfxAdjXW(struct hvGfx *hvg, int x, int width) /* Update a X position and width if reverse-complement mode */ { if (hvg->rc) @@ -236,30 +236,41 @@ 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 hvGfxCurve(struct hvGfx *hvg, int x1, int y1, int x2, int y2, int x3, int y3, + Color color, 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); +return vgCurve(hvg->vg, x1, y1, x2, y2, x3, y3, color, 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 */ @@ -306,35 +317,39 @@ /* Draw a ruler inside the indicated part of mg with numbers that start at * startNum and span range. Bump text positions slightly. */ void hvGfxDrawRuler(struct hvGfx *hvg, int xOff, int yOff, int height, int width, Color color, MgFont *font, int startNum, int range); /* Draw a ruler inside the indicated part of mg with numbers that start at * startNum and span range. */ 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 */ +/* 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