diff --git a/src/DrawRender.cpp b/src/DrawRender.cpp index baf886b..c531f38 100644 --- a/src/DrawRender.cpp +++ b/src/DrawRender.cpp @@ -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;