修复温差图模式下矩形绘制方向问题:确保无论从左上到右下还是右下到左上绘制矩形都符合预期行为
This commit is contained in:
@@ -1291,27 +1291,21 @@ namespace JoyD.Windows.CS
|
||||
float scaledHalfBrushSizeX = _currentBrushSize / 2 * scaleX;
|
||||
float scaledHalfBrushSizeY = _currentBrushSize / 2 * scaleY;
|
||||
|
||||
int x = _rectangleStartPoint.X;
|
||||
int y = _rectangleStartPoint.Y;
|
||||
// 右下角为当前鼠标位置+画笔一半的宽高(基于光标大小转换)
|
||||
// 计算起始点和结束点
|
||||
Point startPoint = new Point(
|
||||
(int)(_rectangleStartPoint.X),
|
||||
(int)(_rectangleStartPoint.Y)
|
||||
);
|
||||
Point endPoint = new Point(
|
||||
(int)(currentImagePoint.X + scaledHalfBrushSizeX),
|
||||
(int)(currentImagePoint.Y + scaledHalfBrushSizeY)
|
||||
);
|
||||
int width = endPoint.X - x;
|
||||
int height = endPoint.Y - y;
|
||||
|
||||
// 确保矩形大小为正数,调整起点和大小
|
||||
if (width < 0)
|
||||
{
|
||||
x += width;
|
||||
width = -width;
|
||||
}
|
||||
if (height < 0)
|
||||
{
|
||||
y += height;
|
||||
height = -height;
|
||||
}
|
||||
// 无论绘制方向如何,都确保左上角为起始点
|
||||
int x = Math.Min(startPoint.X, endPoint.X);
|
||||
int y = Math.Min(startPoint.Y, endPoint.Y);
|
||||
int width = Math.Abs(endPoint.X - startPoint.X);
|
||||
int height = Math.Abs(endPoint.Y - startPoint.Y);
|
||||
|
||||
Rectangle rect = new Rectangle(x, y, width, height);
|
||||
|
||||
@@ -1783,27 +1777,21 @@ namespace JoyD.Windows.CS
|
||||
float scaledHalfBrushSizeX = _currentBrushSize / 2 * scaleX;
|
||||
float scaledHalfBrushSizeY = _currentBrushSize / 2 * scaleY;
|
||||
|
||||
int x = _rectangleStartPoint.X;
|
||||
int y = _rectangleStartPoint.Y;
|
||||
// 右下角为当前鼠标位置+画笔一半的宽高(基于光标大小转换)
|
||||
// 计算起始点和结束点
|
||||
Point startPoint = new Point(
|
||||
(int)(_rectangleStartPoint.X),
|
||||
(int)(_rectangleStartPoint.Y)
|
||||
);
|
||||
Point endPoint = new Point(
|
||||
(int)(currentImagePoint.X + scaledHalfBrushSizeX),
|
||||
(int)(currentImagePoint.Y + scaledHalfBrushSizeY)
|
||||
);
|
||||
int width = endPoint.X - x;
|
||||
int height = endPoint.Y - y;
|
||||
|
||||
// 确保矩形大小为正数,调整起点和大小
|
||||
if (width < 0)
|
||||
{
|
||||
x += width;
|
||||
width = -width;
|
||||
}
|
||||
if (height < 0)
|
||||
{
|
||||
y += height;
|
||||
height = -height;
|
||||
}
|
||||
// 无论绘制方向如何,都确保左上角为起始点
|
||||
int x = Math.Min(startPoint.X, endPoint.X);
|
||||
int y = Math.Min(startPoint.Y, endPoint.Y);
|
||||
int width = Math.Abs(endPoint.X - startPoint.X);
|
||||
int height = Math.Abs(endPoint.Y - startPoint.Y);
|
||||
|
||||
Rectangle rect = new Rectangle(x, y, width, height);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user