static Rect randomRect(int w, int h, int border, int rw, int rh) { if (rw > w-border*2 || rh > h-border*2) null; ret new Rect(random(border, w-border-rw), random(border, h-border-rh), rw, rh); } static Rect randomRect(int w, int h) { ret randomRect(w, h, 0, random(w), random(h)); } ifclass RGBImage static Rect randomRect(RGBImage img, int rw, int rh) { ret randomRect(img.w(), img.h(), 0, rw, rh); } static Rect randomRect(RGBImage img) { ret randomRect(img.w(), img.h()); } endif // on currentImage() static Rect randomRect() { ret randomRect(currentImage().getWidth(), currentImage().getHeight()); } static Rect randomRect(BufferedImage img, int rw, int rh) { ret randomRect(img.getWidth(), img.getHeight(), 0, rw, rh); }