diff --git a/base/applications/mspaint/common.h b/base/applications/mspaint/common.h index bfea7368523..e6864cc21a8 100644 --- a/base/applications/mspaint/common.h +++ b/base/applications/mspaint/common.h @@ -13,6 +13,7 @@ /* FUNCTIONS ********************************************************/ BOOL zoomTo(int newZoom, int mouseX, int mouseY); +BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1); static inline int Zoomed(int xy) { diff --git a/base/applications/mspaint/mouse.cpp b/base/applications/mspaint/mouse.cpp index 0f2f1b36312..8c81c88562c 100644 --- a/base/applications/mspaint/mouse.cpp +++ b/base/applications/mspaint/mouse.cpp @@ -4,6 +4,7 @@ * FILE: base/applications/mspaint/mouse.cpp * PURPOSE: Things which should not be in the mouse event handler itself * PROGRAMMERS: Benedikt Freisen + * Katayama Hirofumi MZ */ /* INCLUDES *********************************************************/ @@ -50,6 +51,13 @@ roundTo8Directions(LONG x0, LONG y0, LONG& x1, LONG& y1) } } +BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1) +{ + INT cxThreshold = toolsModel.GetLineWidth() + UnZoomed(GetSystemMetrics(SM_CXDRAG)); + INT cyThreshold = toolsModel.GetLineWidth() + UnZoomed(GetSystemMetrics(SM_CYDRAG)); + return (abs(x1 - x0) <= cxThreshold) && (abs(y1 - y0) <= cyThreshold); +} + POINT pointStack[256]; short pointSP; @@ -297,8 +305,7 @@ endPaintingL(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) pointSP++; if (pointSP >= 2) { - if ((pointStack[0].x - x) * (pointStack[0].x - x) + - (pointStack[0].y - y) * (pointStack[0].y - y) <= toolsModel.GetLineWidth() * toolsModel.GetLineWidth() + 1) + if (nearlyEqualPoints(x, y, pointStack[0].x, pointStack[0].y)) { Poly(hdc, pointStack, pointSP, fg, bg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), TRUE, FALSE); pointSP = 0; @@ -500,8 +507,7 @@ endPaintingR(HDC hdc, LONG x, LONG y, COLORREF fg, COLORREF bg) pointSP++; if (pointSP >= 2) { - if ((pointStack[0].x - x) * (pointStack[0].x - x) + - (pointStack[0].y - y) * (pointStack[0].y - y) <= toolsModel.GetLineWidth() * toolsModel.GetLineWidth() + 1) + if (nearlyEqualPoints(x, y, pointStack[0].x, pointStack[0].y)) { Poly(hdc, pointStack, pointSP, bg, fg, toolsModel.GetLineWidth(), toolsModel.GetShapeStyle(), TRUE, FALSE); pointSP = 0;