Libraryless. Click here for Pure Java version (7986L/45K).
1 | static L<Rect> mergeOverlappingRects(L<Rect> boxes) { |
2 | while true { |
3 | ping(); |
4 | bool change; |
5 | for (box1 : boxes) { |
6 | for (box2 : boxes) { |
7 | if (box1 == box2) continue; |
8 | if (rectsOverlap(box1, box2)) { |
9 | //printVars("Merging", +box1, +box2); |
10 | copyRect(rectUnion(box1, box2), box1); |
11 | box2.w = 0; |
12 | box2.h = 0; |
13 | set change; |
14 | }; |
15 | } |
16 | } |
17 | |
18 | if (!change) break; |
19 | boxes = filter(boxes, b -> nempty(b)); |
20 | } |
21 | ret boxes; |
22 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035379 |
Snippet name: | mergeOverlappingRects |
Eternal ID of this version: | #1035379/4 |
Text MD5: | 9b1477ec9a8a0ba8b827b253f747e1fb |
Transpilation MD5: | 0f417fb00f81b0ef6140208d5049ce59 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-05-03 20:30:05 |
Source code size: | 525 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 132 / 188 |
Version history: | 3 change(s) |
Referenced in: | [show references] |