Libraryless. Click here for Pure Java version (2819L/18K).
static Rect randomRect_enclosing_in(int w, int h, Rect inner, Rect outer) { if (inner.w > w || inner.h > h) null; if (outer.w < w || outer.h < h) null; IntRange x1range = intersectIntRanges( intRange_incl(inner.x2()-w, inner.x), intRange_incl(outer.x1(), outer.x2()-w)); if (x1range.isEmpty()) null; IntRange y1range = intersectIntRanges( intRange_incl(inner.y2()-h, inner.y), intRange_incl(outer.y1(), outer.y2()-h)); if (y1range.isEmpty()) null; ret rect(random(x1range), random(y1range), w, h); }
Began life as a copy of #1006676
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1029737 |
Snippet name: | randomRect_enclosing_in - rect that contains x and is contained in y [dev.] |
Eternal ID of this version: | #1029737/5 |
Text MD5: | 1fcf2971547596881a94873d93e2dc08 |
Transpilation MD5: | d35934d06645c79297787442734e0812 |
Author: | stefan |
Category: | javax / maths |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-09-10 00:36:09 |
Source code size: | 541 bytes / 13 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 196 / 305 |
Version history: | 4 change(s) |
Referenced in: | [show references] |