Libraryless. Click here for Pure Java version (3481L/21K).
1 | static BufferedImage renderBackgroundPlusBoxes(int w, int h, BackgroundPlusBoxes s) {
|
2 | BufferedImage bi = newBufferedImage(w, h, toColor(s.background)); |
3 | Graphics2D g = imageGraphics(bi); |
4 | for (BoxWithColor e : s.boxes) {
|
5 | int x1 = min(e.a.x, e.b.x), y1 = min(e.a.y, e.b.y); |
6 | int x2 = max(e.a.x, e.b.x), y2 = max(e.a.y, e.b.y); |
7 | fillRect(g, x1, y1, x2-x1+1, y2-y1+1, toColor(e.color)); |
8 | } |
9 | g.dispose(); |
10 | ret bi; |
11 | } |
12 | |
13 | static BufferedImage renderBackgroundPlusBoxes(int w, int h, Color background, Color boxColor, L<Rect> rects) {
|
14 | ret renderBackgroundPlusBoxes(w, h, BackgroundPlusBoxes(background, |
15 | map(rects, r -> BoxWithColor(r, boxColor)))); |
16 | } |
17 | |
18 | // default to black on white |
19 | static BufferedImage renderBackgroundPlusBoxes(int w, int h, L<Rect> rects) {
|
20 | ret renderBackgroundPlusBoxes(w, h, Color.white, Color.black, rects); |
21 | } |
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: | #1014951 |
| Snippet name: | renderBackgroundPlusBoxes |
| Eternal ID of this version: | #1014951/5 |
| Text MD5: | 24a86a920fd3b720e12f9a0026fe9e84 |
| Transpilation MD5: | 545dea75c6810282497c8b39d0ae76b4 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2021-01-07 17:59:17 |
| Source code size: | 865 bytes / 21 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 706 / 885 |
| Version history: | 4 change(s) |
| Referenced in: | [show references] |