Skip to content

Commit 753883f

Browse files
committed
Improve rectangle extend calculation
1 parent d4bba92 commit 753883f

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

applications/libwindow/inc/libwindow/metrics/rectangle.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,12 @@ struct g_rectangle
186186
return;
187187
}
188188

189-
int newX = std::min(x, p.x);
190-
int newY = std::min(y, p.y);
191-
int newWidth = std::max(x + width, p.x + 1) - newX;
192-
int newHeight = std::max(y + height, p.y + 1) - newY;
193-
194-
x = newX;
195-
y = newY;
196-
width = newWidth;
197-
height = newHeight;
189+
int right = std::max(x + width, p.x + 1);
190+
int bottom = std::max(y + height, p.y + 1);
191+
x = std::min(x, p.x);
192+
y = std::min(y, p.y);
193+
width = right - x;
194+
height = bottom - y;
198195
}
199196

200197
/**

0 commit comments

Comments
 (0)