Add a functor fill mode to GfxFillPolygon
This commit is contained in:
@@ -226,8 +226,9 @@ static std::vector<LineSegment> MakePolygonSegments(const std::vector<Point> &sh
|
||||
* FILLRECT_OPAQUE: Fill the polygon with the specified colour.
|
||||
* FILLRECT_CHECKER: Fill every other pixel with the specified colour, in a checkerboard pattern.
|
||||
* FILLRECT_RECOLOUR: Apply a recolour sprite to every pixel in the polygon.
|
||||
* FILLRECT_FUNCTOR: Apply a functor to a line of pixels.
|
||||
*/
|
||||
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode)
|
||||
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode, GfxFillRectModeFunctor *fill_functor)
|
||||
{
|
||||
Blitter *blitter = BlitterFactory::GetCurrentBlitter();
|
||||
const DrawPixelInfo *dpi = _cur_dpi;
|
||||
@@ -308,6 +309,10 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
|
||||
blitter->SetPixel(dst, x, 0, (uint8)colour);
|
||||
}
|
||||
break;
|
||||
case FILLRECT_FUNCTOR:
|
||||
/* Call the provided fill functor. */
|
||||
fill_functor(dst, x2 - x1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str,
|
||||
void DrawCharCentered(WChar c, const Rect &r, TextColour colour);
|
||||
|
||||
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE);
|
||||
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
|
||||
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE, GfxFillRectModeFunctor *fill_functor = nullptr);
|
||||
void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
|
||||
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
|
||||
|
||||
|
@@ -288,8 +288,11 @@ enum FillRectMode {
|
||||
FILLRECT_OPAQUE, ///< Fill rectangle with a single colour
|
||||
FILLRECT_CHECKER, ///< Draw only every second pixel, used for greying-out
|
||||
FILLRECT_RECOLOUR, ///< Apply a recolour sprite to the screen content
|
||||
FILLRECT_FUNCTOR, ///< Apply a functor to a line of pixels
|
||||
};
|
||||
|
||||
typedef void GfxFillRectModeFunctor(void *pixel, int count);
|
||||
|
||||
/** Palettes OpenTTD supports. */
|
||||
enum PaletteType {
|
||||
PAL_DOS, ///< Use the DOS palette.
|
||||
|
Reference in New Issue
Block a user