b038f3dafce99493b0ca00305538c6a3dd6f041a jcasper Tue Sep 26 15:58:44 2023 -0700 Initial commit of track decorators, refs #30237 diff --git src/inc/memgfx.h src/inc/memgfx.h index 4eec6b9..a33b6c9 100644 --- src/inc/memgfx.h +++ src/inc/memgfx.h @@ -410,30 +410,31 @@ * saturation scale 's', and * value scale 'v' * Returns the transformed rgb value * Use H=0, S=V=1 for identity transformation */ struct rgbColor mgColorIxToRgb(struct memGfx *mg, int colorIx); /* Return rgb value at color index. */ struct rgbColor colorIxToRgb(int colorIx); /* Return rgb value at color index. */ INLINE void mixColor(Color *d, Color s) /* Blend the color at s into d, respecting alpha */ { +/* algorithm borrowed from https://en.wikipedia.org/wiki/Alpha_compositing */ int aA = COLOR_32_ALPHA(s); int rA = COLOR_32_RED(s); int gA = COLOR_32_GREEN(s); int bA = COLOR_32_BLUE(s); int aB = COLOR_32_ALPHA(*d); int rB = COLOR_32_RED(*d); int gB = COLOR_32_GREEN(*d); int bB = COLOR_32_BLUE(*d); double aOut = aA + (aB * (255.0 - aA) / 255); int rOut, gOut, bOut; if (aOut == 0) rOut = gOut = bOut = 0; else @@ -443,43 +444,24 @@ bOut = (bA * aA + bB * aB * (255 - aA) / 255)/aOut ; } *d = MAKECOLOR_32_A(rOut,gOut,bOut,aOut); } INLINE void mixDot(struct memGfx *img, int x, int y, float frac, Color col) /* Puts a single dot on the image, mixing it with what is already there * based on the frac argument. */ /* Shouldn't this pay attention to the transparency of the current pixel? */ { if ((x < img->clipMinX) || (x >= img->clipMaxX) || (y < img->clipMinY) || (y >= img->clipMaxY)) return; Color *pt = _mgPixAdr(img,x,y); -/* algorithm borrowed from https://en.wikipedia.org/wiki/Alpha_compositing */ int aA = frac * 255; int rA = COLOR_32_RED(col); int gA = COLOR_32_GREEN(col); int bA = COLOR_32_BLUE(col); int tempC = MAKECOLOR_32_A(rA, gA, bA, aA); mixColor(pt, tempC); -/* -int aB = COLOR_32_ALPHA(*pt); -int rB = COLOR_32_RED(*pt); -int gB = COLOR_32_GREEN(*pt); -int bB = COLOR_32_BLUE(*pt); - -double aOut = aA + (aB * (255.0 - aA) / 255); -int rOut, gOut, bOut; -if (aOut == 0) - rOut = gOut = bOut = 0; -else - { - rOut = (rA * aA + rB * aB * (255 - aA) / 255)/aOut ; - gOut = (gA * aA + gB * aB * (255 - aA) / 255)/aOut ; - bOut = (bA * aA + bB * aB * (255 - aA) / 255)/aOut ; - } -mgPutDot(img,x,y,MAKECOLOR_32_A(rOut,gOut,bOut,aOut)); -*/ } #endif /* MEMGFX_H */