static Puzzle makeClickPuzzle(S instruction, L<RGBImage> images, L<Rect> solutions) { ret makeClickPuzzle(instruction, null, images, solutions); } static Puzzle makeClickPuzzle(S instruction, S nullAnswer, L<RGBImage> images, L<Rect> solutions) { // select image int i = random(l(images)); RGBImage mainImage = images.get(i); Rect solution = solutions.get(i); Rect clip; if (solution != null) { // select random portion clip = selectRandomPartContaining(mainImage, solution, w, h); solution = translateRect(solution, -clip.x, -clip.y); } else { clip = selectRandomPart(mainImage, w, h); if (clip == null) fail("No fit: " + w + "/" + h + " vs " + mainImage.w() + "/" + mainImage.h()); } RGBImage img = mainImage.clip(clip); // return puzzle ret new Puzzle(instruction, nullAnswer, img, llNonNulls(solution)); }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006906 |
Snippet name: | makeClickPuzzle |
Eternal ID of this version: | #1006906/5 |
Text MD5: | d6e2f0907b6dc059f2f03666a9dd21b0 |
Author: | stefan |
Category: | javax / a.i. games |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-03-03 01:46:04 |
Source code size: | 886 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 507 / 507 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |