From ee3406af08853b0ffb30efd203a373460300077f Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 3 Aug 2024 16:14:38 +1000 Subject: fix rect clipping functions --- rect.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/rect.c b/rect.c index e3d3948..599d9a3 100644 --- a/rect.c +++ b/rect.c @@ -3,7 +3,6 @@ Rect* rect_clip(Rect* r, const Rect* c) { int n; - int x = r->x, y = r->y; if ((n = c->x - r->x) > 0) { r->w -= n; r->x += n; @@ -12,16 +11,15 @@ Rect* rect_clip(Rect* r, const Rect* c) { r->h -= n; r->y += n; } - if ((n = x + r->w - (c->x + c->w)) > 0) + if ((n = r->x + r->w - (c->x + c->w)) > 0) r->w -= n; - if ((n = y + r->h - (c->y + c->h)) > 0) + if ((n = r->y + r->h - (c->y + c->h)) > 0) r->h -= n; return r; } Rect* rect_clipr(Rect* r, const int* c) { int n; - int x = r->x, y = r->y; if ((n = c[0] - r->x) > 0) { r->w -= n; r->x += n; @@ -30,16 +28,15 @@ Rect* rect_clipr(Rect* r, const int* c) { r->h -= n; r->y += n; } - if ((n = x + r->w - c[2]) > 0) + if ((n = r->x + r->w - c[2]) > 0) r->w -= n; - if ((n = y + r->h - c[3]) > 0) + if ((n = r->y + r->h - c[3]) > 0) r->h -= n; return r; } Rect* rect_clips(Rect* r, Rect* s, const Rect* c) { int n; - int x = r->x, y = r->y; if ((n = c->x - r->x) > 0) { r->w -= n; r->x += n; @@ -52,11 +49,11 @@ Rect* rect_clips(Rect* r, Rect* s, const Rect* c) { s->h -= n; s->y += n; } - if ((n = x + r->w - (c->x + c->w)) > 0) { + if ((n = r->x + r->w - (c->x + c->w)) > 0) { r->w -= n; s->w -= n; } - if ((n = y + r->h - (c->y + c->h)) > 0) { + if ((n = r->y + r->h - (c->y + c->h)) > 0) { r->h -= n; s->h -= n; } @@ -65,7 +62,6 @@ Rect* rect_clips(Rect* r, Rect* s, const Rect* c) { Rect* rect_clipsr(Rect* r, Rect* s, const int* c) { int n; - int x = r->x, y = r->y; if ((n = c[0] - r->x) > 0) { r->w -= n; r->x += n; @@ -78,11 +74,11 @@ Rect* rect_clipsr(Rect* r, Rect* s, const int* c) { s->h -= n; s->y += n; } - if ((n = x + r->w - c[2]) > 0) { + if ((n = r->x + r->w - c[2]) > 0) { r->w -= n; s->w -= n; } - if ((n = y + r->h - c[3]) > 0) { + if ((n = r->y + r->h - c[3]) > 0) { r->h -= n; s->h -= n; } -- cgit v1.2.3-54-g00ecf