diff options
| author | Ray <[email protected]> | 2022-03-24 11:44:52 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2022-03-24 11:44:52 +0100 |
| commit | ca12ef48e9e9f4eae03b1ca43ec3eb0a78d63dd3 (patch) | |
| tree | bbb1911de1c3a3265f735b3589df1873424c59b9 | |
| parent | 65f28460a14dbf8c537ec361a60c37100439f4a2 (diff) | |
| download | raylib-ca12ef48e9e9f4eae03b1ca43ec3eb0a78d63dd3.tar.gz raylib-ca12ef48e9e9f4eae03b1ca43ec3eb0a78d63dd3.zip | |
Fixes #2408
| -rw-r--r-- | examples/shapes/shapes_rectangle_scaling.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/examples/shapes/shapes_rectangle_scaling.c b/examples/shapes/shapes_rectangle_scaling.c index bd1f0648..76b54c09 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; } |
