// f: func(int x, int y) -> bool/Color/RGB static BufferedImage renderImage(int w, int h, O f) { RGBImage rgb = new RGBImage(w, h, Color.black); for y to h: for x to w: { O o = callF(f, x, y); if (o instanceof Bool) rgb.setPixel(x, y, isTrue(o) ? Color.white : Color.black); else if (o instanceof RGB) rgb.setPixel(x, y, (RGB) o); else if (o instanceof Color) rgb.setPixel(x, y, (Color) o); else if (o != null) fail("Woot?! " + _getClass(o)); } ret rgb.getBufferedImage(); } static BufferedImage renderImage(int w, int h default w, IF2_Int f) { ret imageFromFunction(w, h, f); }
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: | #1007281 |
Snippet name: | renderImage - render a BufferedImage pixel by pixel |
Eternal ID of this version: | #1007281/5 |
Text MD5: | abcaf02d8983c0cb2b1177225bae3390 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-08-23 04:05:22 |
Source code size: | 624 bytes / 16 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 490 / 525 |
Version history: | 4 change(s) |
Referenced in: | [show references] |