Libraryless. Click here for Pure Java version (9561L/54K).
1 | sclass PatchworkImage<A> extends AbstractWAndH is MakesBufferedImage { |
2 | new L<Patch> patches; |
3 | settable Color backgroundColor = grayToColor(0.9); |
4 | |
5 | class Patch { |
6 | Rect bounds; |
7 | BufferedImage image; |
8 | settable A userValue; |
9 | |
10 | *(Rect *bounds, BufferedImage *image) {} |
11 | } |
12 | |
13 | *() {} |
14 | *(int w, int h) { super(w, h); } |
15 | |
16 | void addPatch(BufferedImage image, Pt etc p, A userValue) { |
17 | addPatch(p, image, userValue); |
18 | } |
19 | |
20 | void addPatch(Pt etc p, BufferedImage image, A userValue) { |
21 | patches.add(new Patch( |
22 | rect(p.x, p.y, image.getWidth(), image.getHeight()), |
23 | image) |
24 | .userValue(userValue)); |
25 | } |
26 | |
27 | public BufferedImage getBufferedImage() { |
28 | BufferedImage out = newBufferedImage(w(), h(), backgroundColor); |
29 | for (patch : patches) |
30 | copyBufferedImage(patch.image, out, topLeft(patch.bounds)); |
31 | ret out; |
32 | } |
33 | } |
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036004 |
Snippet name: | PatchworkImage |
Eternal ID of this version: | #1036004/9 |
Text MD5: | 2923a053ade4c56fb0222b4b25be3598 |
Transpilation MD5: | f76f4538c5f89953d464fb0b7aecb6f3 |
Author: | stefan |
Category: | javax / imaging |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-08-23 16:57:44 |
Source code size: | 896 bytes / 33 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 142 / 244 |
Version history: | 8 change(s) |
Referenced in: | [show references] |