b8180d9f6d41dc708a2f249ba892cbca311e7a06 jcasper Mon Feb 27 11:38:55 2023 -0800 Adding transparency support for colors refs #30569 diff --git src/inc/vGfx.h src/inc/vGfx.h index 8594a2c..9802031 100644 --- src/inc/vGfx.h +++ src/inc/vGfx.h @@ -47,30 +47,34 @@ int colorIx, void *font, char *text); /* Draw a line of text right justified in box defined by x/y/width/height */ void (*textCentered)(void *v, int x, int y, int width, int height, int colorIx, void *font, char *text); /* Draw a line of text in middle of box. */ void (*textInBox)(void *v, int x, int y, int width, int height, int colorIx, void *font, char *text); /* Draw text that fills a box. */ int (*findColorIx)(void *v, int r, int g, int b); /* Find color in map if possible, otherwise create new color or * in a pinch a close color. */ + int (*findAlphaColorIx)(void *v, int r, int g, int b, int a); + /* Find color in map if possible, otherwise create new color or + * in a pinch a close color. This one includes an alpha value. */ + struct rgbColor (*colorIxToRgb)(void *v, int colorIx); /* Return rgb values for given color index. */ void (*setWriteMode)(void *v, unsigned int writeMode); /* Set write mode. */ void (*setClip)(void *v, int x, int y, int width, int height); /* Set clipping rectangle. */ void (*unclip)(void *v); /* Set clipping rect cover full thing. */ void (*verticalSmear)(void *v, int xOff, int yOff, int width, int height, Color *dots, boolean zeroClear); @@ -152,30 +156,33 @@ #define vgTextRight(v,x,y,width,height,color,font,string) \ v->textRight(v->data,x,y,width,height,color,font,string) /* Draw a line of text right justified in box defined by x/y/width/height */ #define vgTextCentered(v,x,y,width,height,color,font,string) \ v->textCentered(v->data,x,y,width,height,color,font,string) /* Draw a line of text in middle of box. */ #define vgTextInBox(v,x,y,width,height,color,font,string) \ v->textInBox(v->data,x,y,width,height,color,font,string) /* Draw text that fills a box. */ #define vgFindColorIx(v,r,g,b) v->findColorIx(v->data, r, g, b) /* Find index of RGB color. */ +#define vgFindAlphaColorIx(v,r,g,b,a) v->findAlphaColorIx(v->data, r, g, b, a) +/* Find index of RGBA color. */ + #define vgColorIxToRgb(v,colorIx) v->colorIxToRgb(v->data, colorIx) /* Return rgb values for given color index. */ #define vgSetWriteMode(v, writeMode) \ v->setWriteMode(v->data, writeMode) /* Set write mode. */ #define vgSetClip(v,x,y,width,height) \ v->setClip(v->data, x, y, width, height) /* Set clipping rectangle. */ #define vgUnclip(v) v->unclip(v->data); /* Get rid of clipping rectangle. Note this is not completely * the same in PostScript and the memory images. PostScript * demands that vgSetClip/vgUnclip come in pairs, and that @@ -219,22 +226,22 @@ 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? */ #define vgSetFontMethod(v,method,fontName,fontFile) \ v->setFontMethod(v->data,method,fontName,fontFile) int vgFindRgb(struct vGfx *vg, struct rgbColor *rgb); -/* Find color index corresponding to rgb color. */ +/* Find color index corresponding to rgba color. */ Color vgContrastingColor(struct vGfx *vg, int backgroundIx); /* Return black or white whichever would be more visible over - * background. */ + * background. Note: ignores alpha. */ #endif /* VGFX_H */