From 3b4422b41b93bc6b96562b2ea4d2af826a04d49b Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 14 Jun 2023 17:14:41 +0900 Subject: [PATCH] [MSPAINT] drawing.cpp: Refactor Erase, Replace and Airbrush 3 CORE-18867 --- base/applications/mspaint/drawing.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/base/applications/mspaint/drawing.cpp b/base/applications/mspaint/drawing.cpp index de9c925f396..600e7addd7a 100644 --- a/base/applications/mspaint/drawing.cpp +++ b/base/applications/mspaint/drawing.cpp @@ -117,16 +117,13 @@ void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius) { LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1))); - RECT rc; HBRUSH hbr = ::CreateSolidBrush(color); for (LONG a = 0; a <= b; a++) { - ::SetRect(&rc, (x1 * (b - a) + x2 * a) / b - radius, - (y1 * (b - a) + y2 * a) / b - radius, - (x1 * (b - a) + x2 * a) / b + radius, - (y1 * (b - a) + y2 * a) / b + radius); - + LONG cx = (x1 * (b - a) + x2 * a) / b; + LONG cy = (y1 * (b - a) + y2 * a) / b; + RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius }; ::FillRect(hdc, &rc, hbr); } @@ -137,14 +134,12 @@ void Replace(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF fg, COLORREF bg, LONG radius) { LONG b = max(1, max(abs(x2 - x1), abs(y2 - y1))); - RECT rc; for (LONG a = 0; a <= b; a++) { - ::SetRect(&rc, (x1 * (b - a) + x2 * a) / b - radius, - (y1 * (b - a) + y2 * a) / b - radius, - (x1 * (b - a) + x2 * a) / b + radius, - (y1 * (b - a) + y2 * a) / b + radius); + LONG cx = (x1 * (b - a) + x2 * a) / b; + LONG cy = (y1 * (b - a) + y2 * a) / b; + RECT rc = { cx - radius, cy - radius, cx + radius, cy + radius }; for (LONG y = rc.top; y < rc.bottom; ++y) { for (LONG x = rc.left; x < rc.right; ++x)