b8180d9f6d41dc708a2f249ba892cbca311e7a06 jcasper Mon Feb 27 11:38:55 2023 -0800 Adding transparency support for colors refs #30569 diff --git src/lib/vGfx.c src/lib/vGfx.c index cb5e282..a4252f4 100644 --- src/lib/vGfx.c +++ src/lib/vGfx.c @@ -20,32 +20,32 @@ freez(pVg); } } struct vGfx *vgHalfInit(int width, int height) /* Close down virtual graphics object, and finish writing it to file. */ { struct vGfx *vg; AllocVar(vg); vg->width = width; vg->height = height; return vg; } int vgFindRgb(struct vGfx *vg, struct rgbColor *rgb) -/* Find color index corresponding to rgb color. */ +/* Find color index corresponding to rgba color. */ { -return vgFindColorIx(vg, rgb->r, rgb->g, rgb->b); +return vgFindAlphaColorIx(vg, rgb->r, rgb->g, rgb->b, rgb->a); } Color vgContrastingColor(struct vGfx *vg, int backgroundIx) /* Return black or white whichever would be more visible over - * background. */ + * background. Note: ignores alpha. */ { struct rgbColor c = vgColorIxToRgb(vg, backgroundIx); int val = (int)c.r + c.g + c.g + c.b; if (val > 512) return MG_BLACK; else return MG_WHITE; }