diff options
author | quou <quou@disroot.org> | 2024-08-03 16:14:38 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-08-03 16:14:38 +1000 |
commit | ee3406af08853b0ffb30efd203a373460300077f (patch) | |
tree | 22035701497da06bd57a7cda2c43ccb3b262235f | |
parent | a5b1732c36b0a2b896521efacfb3bff485cef127 (diff) |
fix rect clipping functions
-rw-r--r-- | rect.c | 20 |
1 files changed, 8 insertions, 12 deletions
@@ -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; } |