7216fbf3ffc72cb77bf509c0bffe719a1daa0ed5 braney Sun Sep 6 16:20:34 2020 -0700 first cut at using FreeType for font support diff --git src/inc/memgfx.h src/inc/memgfx.h index 330df0e..f70a1f4 100644 --- src/inc/memgfx.h +++ src/inc/memgfx.h @@ -86,30 +86,31 @@ unsigned short s, l; }; extern struct rgbColor mgFixedColors[9]; /* Contains MG_WHITE - MG_GRAY */ struct memGfx { Color *pixels; int width, height; struct rgbColor colorMap[256]; int colorsUsed; int clipMinX, clipMaxX; int clipMinY, clipMaxY; struct colHash *colorHash; /* Hash for fast look up of color. */ unsigned int writeMode; + unsigned int fontMethod; }; struct memGfx *mgNew(int width, int height); /* Get a new thing to draw on in memory. */ void mgFree(struct memGfx **pmg); /* Free up memory raster. */ void mgClearPixelsTrans(struct memGfx *mg); /* Set all pixels to transparent. */ void mgClearPixels(struct memGfx *mg); /* Set all pixels to background. */ void mgSetClip(struct memGfx *mg, int x, int y, int width, int height); @@ -396,16 +397,31 @@ struct rgbColor mgRgbTransformHsv(struct rgbColor in, double h, double s, double v); /* Transform rgb 'in' value using * hue shift 'h' (0..360 degrees), * 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 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. */ +{ +if ((x < img->clipMinX) || (x >= img->clipMaxX) || (y < img->clipMinY) || (y >= img->clipMaxY)) + return; + +Color *pt = _mgPixAdr(img,x,y); +float invFrac = 1 - frac; + +int r = COLOR_32_RED(*pt) * invFrac + COLOR_32_RED(col) * frac; +int g = COLOR_32_GREEN(*pt) * invFrac + COLOR_32_GREEN(col) * frac; +int b = COLOR_32_BLUE(*pt) * invFrac + COLOR_32_BLUE(col) * frac; +mgPutDot(img,x,y,MAKECOLOR_32(r,g,b)); +} #endif /* MEMGFX_H */