Libraryless. Click here for Pure Java version (7970L/45K).
static L<Rect> mergeNeighboringRects(L<Rect> boxes, int maxDistance) { while true { ping(); bool change; for (box1 : boxes) { for (box2 : boxes) { if (box1 == box2) continue; if (rectDistance(box1, box2) <= maxDistance) { //printVars("Merging", +box1, +box2); copyRect(rectUnion(box1, box2), box1); box2.w = 0; box2.h = 0; set change; }; } } if (!change) break; boxes = filter(boxes, b -> nempty(b)); } ret boxes; }
Began life as a copy of #1035379
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1035380 |
Snippet name: | mergeNeighboringRects |
Eternal ID of this version: | #1035380/1 |
Text MD5: | 344ca7c8d96c66d30747ca9c6e2980b6 |
Transpilation MD5: | 16e80e749400e7680f9db73ea6591d2a |
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:34:30 |
Source code size: | 557 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 119 / 173 |
Referenced in: | [show references] |