limit cycle radius

This commit is contained in:
Shaohua Tong 2020-01-08 17:02:11 +01:00
parent f19688ace6
commit 0c9caab59e

View File

@ -24,10 +24,16 @@ void DrawRender::graphicsUpdate(int type) {
oldCircle.getUperLeft().x, oldCircle.getUperLeft().y);
int radius = utils::getDistance(getMouseLeftDownPosition(), getMousePostion()) / 2;
vkvm::Coordinates center;
center.x = (mousePosition.x + mouseLeftDownPosition.x) / 2;
center.y = (mousePosition.y + mouseLeftDownPosition.y) / 2;
if(center.x + radius > windowWidth || center.x - radius < 0
|| center.y + radius > windowHeight || center.y - radius < 0) {
radius = utils::min(utils::min(center.x, windowWidth - center.x), utils::min(center.y, windowHeight - center.y));
}
oldCircle = Circle(center, radius, penWidth, false);
painting = true;