Libraryless. Click here for Pure Java version (337L/2K).
static Rect intersectRects(Rect a, Rect b) { int x = max(a.x, b.x), y = max(a.y, b.y); int x2 = min(a.x+a.w, b.x+b.w), y2 = min(a.y+a.h, b.y+b.h); ret new Rect(x, y, x2-x, y2-y); } static Rect intersectRects(Rect a, int x1, int y1, int w, int h) { if (a == null || a.x >= x1 && a.y >= y1 && a.x2() < x1+w && a.y2() < y1+h) ret a; ret rectFromPoints( max(a.x, x1), max(a.y, y1), min(a.x2(), x1+w), min(a.y2(), y1+h)); }
Began life as a copy of #1005838
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006162 |
Snippet name: | intersectRects |
Eternal ID of this version: | #1006162/3 |
Text MD5: | 90692dec13719c50a97207d18ed238b5 |
Transpilation MD5: | 5ce3009ae9c4b55f60cc5b143ae2928b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-20 21:59:38 |
Source code size: | 458 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 637 / 677 |
Version history: | 2 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1019203 - clipRect - see clipRGBImage |