From 0c9caab59e25081181c422b48d92d488840c3a47 Mon Sep 17 00:00:00 2001 From: Shaohua Tong Date: Wed, 8 Jan 2020 17:02:11 +0100 Subject: [PATCH] limit cycle radius --- src/DrawRender.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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;