66ee7c172964fe9665479973fa7c7536afe03fa2 kate Tue Apr 10 22:05:33 2018 -0700 Add Postscript for bezier curve. Fix ellipse. refs #21109 diff --git src/inc/vGfx.h src/inc/vGfx.h index 5de64cf..d0cbb14 100644 --- src/inc/vGfx.h +++ src/inc/vGfx.h @@ -74,30 +74,35 @@ /* Draw a 4 sided filled figure that has line x1/y1 to x2/y2 at * it's top, a horizontal line at bottom at it's bottom, and * vertical lines from the bottom to y1 on the left and bottom to * y2 on the right. */ void (*drawPoly)(void *v, struct gfxPoly *poly, Color color, boolean filled); /* Draw polygon, possibly filled in color. */ void (*ellipse)(void *v, int x1, int y1, int x2, int y2, Color color, int mode, boolean isDashed); /* Draw an ellipse or half-ellipse (top or bottom), * specified by left-most and top-most points on a rectangle. * Optionally draw with dashed line. */ + int (*curve)(void *v, int x1, int y1, int x2, int y2, int x3, int y3, Color color, + boolean isDashed); + /* Draw a segment of an anti-aliased curve within 3 points (quadratic Bezier) + * Return max y value. Optionally draw curve as dashed line. */ + void (*setHint)(void *v, char *hint, char *value); /* Set hint */ char *(*getHint)(void *v, char *hint); /* Get hint */ int (*getFontPixelHeight)(void *v, void *font); /* How high in pixels is font? */ int (*getFontStringWidth)(void *v, void *font, char *string); /* How wide is a string? */ }; struct vGfx *vgOpenPng(int width, int height, char *fileName, boolean useTransparency); /* Open up something that will write out a PNG file upon vgClose. @@ -161,36 +166,43 @@ #define vgVerticalSmear(v,x,y,w,h,dots,zeroClear) \ v->verticalSmear(v->data,x,y,w,h,dots,zeroClear) /* Take array of dots and smear them vertically. */ #define vgFillUnder(v,x1,y1,x2,y2,bottom,color) \ v->fillUnder(v->data,x1,y1,x2,y2,bottom,color) /* Draw a 4 sided filled figure that has line x1/y1 to x2/y2 at * it's top, a horizontal line at bottom at it's bottom, and * vertical lines from the bottom to y1 on the left and bottom to * y2 on the right. */ #define vgDrawPoly(v,poly,color,filled) \ v->drawPoly(v->data,poly,color,filled) /* Draw a polygon in color, optionally filled. */ -#define vgEllipse(v,x1,x2,y1,y2,color,mode,isDashed) \ - v->ellipse(v->data,x1,x2,y1,y2,color,mode,isDashed) +#define vgEllipse(v,x1,y1,x2,y2,color,mode,isDashed) \ + v->ellipse(v->data,x1,y1,x2,y2,color,mode,isDashed) /* Draw an ellipse or half-ellipse (top or bottom), * specified by left-most and top-most points on a rectangle. * Optionally draw with dashed line */ +#define vgCurve(v,x1,y1,x2,y2,x3,y3,color,isDashed) \ + v->curve(v->data,x1,y1,x2,y2,x3,y3,color,isDashed) +/* Draw a segment of an anti-aliased curve within 3 points (quadratic Bezier) + * Return max y value. Optionally draw curve as dashed line. + * Adapted trivially from code posted at http://members.chello.at/~easyfilter/bresenham.html + * Author: Zingl Alois, 8/22/2016 */ + #define vgSetHint(v,hint,value) \ v->setHint(v->data,hint,value) /* Set hint */ #define vgGetHint(v,hint) \ v->getHint(v->data,hint) /* Get hint */ #define vgGetFontPixelHeight(v,font) \ v->getFontPixelHeight(v->data,font) /* How high in pixels is font? */ #define vgGetFontStringWidth(v,font,string) \ v->getFontStringWidth(v->data,font,string) /* How wide is a string? */