From d8a5a284e79a38e745301693921d92ab4ee9148b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 13 Jul 2022 23:00:01 +0200 Subject: [PATCH] GRAPHICS: Added primitives drawing over bigger rectangles We do not count right and bottom edges of Common::Rect. But the original primitives.cpp was drawn _with_ this in mind. This introduces *1 methods which will be used by Director, WAGE and MacGUI. Maybe at some moment in the future we will rewrite those. --- graphics/primitives.cpp | 26 +++++++++++++++++++++++++- graphics/primitives.h | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/graphics/primitives.cpp b/graphics/primitives.cpp index 271a4b66952..7d24703f8cb 100644 --- a/graphics/primitives.cpp +++ b/graphics/primitives.cpp @@ -239,19 +239,43 @@ void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color, void ( } void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) { + for (int y = rect.top; y < rect.bottom; y++) + drawHLine(rect.left, rect.right - 1, y, color, plotProc, data); +} + +/** + * @brief Draws filled rectangle _with_ right and bottom edges + */ +void drawFilledRect1(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) { for (int y = rect.top; y <= rect.bottom; y++) drawHLine(rect.left, rect.right, y, color, plotProc, data); } void drawRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) { + drawHLine(rect.left, rect.right - 1, rect.top, color, plotProc, data); + drawHLine(rect.left, rect.right - 1, rect.bottom - 1, color, plotProc, data); + drawVLine(rect.left, rect.top, rect.bottom - 1, color, plotProc, data); + drawVLine(rect.right, rect.top, rect.bottom - 1, color, plotProc, data); +} + +/** + * @brief Draws rectangle outline _with_ right and bottom edges + */ +void drawRect1(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data) { drawHLine(rect.left, rect.right, rect.top, color, plotProc, data); drawHLine(rect.left, rect.right, rect.bottom, color, plotProc, data); drawVLine(rect.left, rect.top, rect.bottom, color, plotProc, data); drawVLine(rect.right, rect.top, rect.bottom, color, plotProc, data); } -// http://members.chello.at/easyfilter/bresenham.html void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) { + Common::Rect r(rect.left, rect.top, rect.right - 1, rect.bottom - 1); + + drawRoundRect1(r, arc, color, filled, plotProc, data); +} + +// http://members.chello.at/easyfilter/bresenham.html +void drawRoundRect1(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data) { if (rect.height() < rect.width()) { int x = -arc, y = 0, err = 2-2*arc; /* II. Quadrant */ int dy = rect.height() - arc * 2; diff --git a/graphics/primitives.h b/graphics/primitives.h index dcd70c0a5d4..5b1464ef9e1 100644 --- a/graphics/primitives.h +++ b/graphics/primitives.h @@ -33,8 +33,11 @@ void drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, int color void drawThickLine2(int x1, int y1, int x2, int y2, int thick, int color, void (*plotProc)(int, int, int, void *), void *data); void drawFilledRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data); +void drawFilledRect1(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data); void drawRect(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data); +void drawRect1(Common::Rect &rect, int color, void (*plotProc)(int, int, int, void *), void *data); void drawRoundRect(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data); +void drawRoundRect1(Common::Rect &rect, int arc, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data); void drawPolygonScan(int *polyX, int *polyY, int npoints, Common::Rect &bbox, int color, void (*plotProc)(int, int, int, void *), void *data); void drawEllipse(int x0, int y0, int x1, int y1, int color, bool filled, void (*plotProc)(int, int, int, void *), void *data);