Rect drect = rect;
if(drect.x < screen_rect.x) {
+ drect.width -= screen_rect.x - drect.x;
drect.x = screen_rect.x;
}
if(drect.y < screen_rect.y) {
+ drect.height -= screen_rect.y - drect.y;
drect.y = screen_rect.y;
}
- if(drect.x + drect.width > screen_rect.width) {
+ if(drect.x + drect.width >= screen_rect.x + screen_rect.width) {
drect.width = screen_rect.width - drect.x;
}
- if(drect.y + drect.height > screen_rect.height) {
+ if(drect.y + drect.height >= screen_rect.y + screen_rect.height) {
drect.height = screen_rect.height - drect.y;
}