diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c index bd1f0648a..76b54c093 100644 --- a/examples/shapes/shapes_rectangle_scaling.c +++ b/examples/shapes/shapes_rectangle_scaling.c @@ -41,8 +41,7 @@ int main(void) //---------------------------------------------------------------------------------- mousePosition = GetMousePosition(); - if (CheckCollisionPointRec(mousePosition, rec) && - CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE })) + if (CheckCollisionPointRec(mousePosition, (Rectangle){ rec.x + rec.width - MOUSE_SCALE_MARK_SIZE, rec.y + rec.height - MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE, MOUSE_SCALE_MARK_SIZE })) { mouseScaleReady = true; if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) mouseScaleMode = true; @@ -56,8 +55,13 @@ int main(void) rec.width = (mousePosition.x - rec.x); rec.height = (mousePosition.y - rec.y); + // Check minimum rec size if (rec.width < MOUSE_SCALE_MARK_SIZE) rec.width = MOUSE_SCALE_MARK_SIZE; if (rec.height < MOUSE_SCALE_MARK_SIZE) rec.height = MOUSE_SCALE_MARK_SIZE; + + // Check maximum rec size + if (rec.width > (GetScreenWidth() - rec.x)) rec.width = GetScreenWidth() - rec.x; + if (rec.height > (GetScreenHeight() - rec.y)) rec.height = GetScreenHeight() - rec.y; if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT)) mouseScaleMode = false; }