Libraryless. Click here for Pure Java version (13493L/83K).
1 | static ImageSurface showImageWithSelections(MakesBufferedImage img, final Cl<Rect> rects) { |
2 | ret showImageWithSelections(img.getBufferedImage(), rects); |
3 | } |
4 | |
5 | static ImageSurface showImageWithSelections(S title, BufferedImage img, Cl<Rect> rects) { |
6 | ret frameTitle(title, showImageWithSelections(img, rects)); |
7 | } |
8 | |
9 | static ImageSurface showImageWithSelections(BufferedImage img, Cl<Rect> rects) { |
10 | ret showImageWithSelections(img, null, rects); |
11 | } |
12 | |
13 | static ImageSurface showImageWithSelections(BufferedImage img, Rect... rects) { |
14 | ret showImageWithSelections(img, asList(rects)); |
15 | } |
16 | |
17 | // for callers to use |
18 | static Var<Rect> showImageWithSelections_highlighted; |
19 | |
20 | static ImageSurface showImageWithSelections(BufferedImage img, ImageSurface _is, Cl<Rect> _rects) { |
21 | final ImageSurface is = showImage(img, _is); |
22 | final L<Rect> rects = sortRectsBySize(_rects); |
23 | final new Var<Rect> highlighted; |
24 | showImageWithSelections_highlighted = highlighted; |
25 | is.overlay = voidfunc(Graphics2D g) { |
26 | for (Rect r : rects) |
27 | is.drawSelectionRect(g, r.getRectangle(), Color.blue, Color.white); |
28 | if (highlighted.has()) |
29 | fillRect(g, scaleRect(highlighted!, is.getZoomX(), is.getZoomY()), new Color(0, 0, 0, 0x30)); // semi-transparent black |
30 | }; |
31 | imageSurfaceOnMouseMove(is, voidfunc(Pt p) { |
32 | repaintIf(is, setVarIfNeq(highlighted, smallestRectContaining(rects, p))); |
33 | }); |
34 | |
35 | is.repaint(); |
36 | ret is; |
37 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005839 |
Snippet name: | showImageWithSelections |
Eternal ID of this version: | #1005839/13 |
Text MD5: | 3fb0b28183915e00af147e817ee308a3 |
Transpilation MD5: | e2d98787a7ab594c3603f99599439301 |
Author: | stefan |
Category: | javax / imaging / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-09-09 19:00:49 |
Source code size: | 1435 bytes / 37 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 595 / 653 |
Version history: | 12 change(s) |
Referenced in: | [show references] |