mirror of
https://github.com/reactos/reactos.git
synced 2025-02-20 15:35:04 +00:00
[MSPAINT] drawing.cpp: Refactor Erase, Replace and Airbrush 3
CORE-18867
This commit is contained in:
parent
0334498068
commit
3b4422b41b
1 changed files with 6 additions and 11 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue