Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1007266 // Random Smiley Emotions [WORKS]

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Uses 3874K of libraries. Click here for Pure Java version (6143L/41K/150K).

1  
!7
2  
3  
static double zoom = 0.5;
4  
5  
sS imageID = #1007256;
6  
sS rects = [[ [Rect(h=415, w=392, x=104, y=168), Rect(h=420, w=393, x=552, y=168), Rect(h=414, w=392, x=1008, y=168), Rect(h=416, w=392, x=1448, y=168), Rect(h=416, w=400, x=112, y=640), Rect(h=416, w=392, x=560, y=640), Rect(h=424, w=400, x=1000, y=632), Rect(h=421, w=393, x=1447, y=632), Rect(h=419, w=400, x=112, y=1112), Rect(h=416, w=392, x=560, y=1112), Rect(h=416, w=392, x=1000, y=1112), Rect(h=424, w=394, x=1446, y=1104), /* the gray one: Rect(h=422, w=393, x=1447, y=1576),*/ Rect(h=420, w=400, x=96, y=1584), Rect(h=420, w=400, x=552, y=1583), Rect(h=416, w=392, x=1000, y=1584)] ]];
7  
8  
static Map<Int, S> names = littreemap(
9  
  1, "happy",
10  
  2, "sad",
11  
  3, "extremely happy",
12  
  4, "happy with tongue",
13  
  5, "whaaat",
14  
  6, "crying",
15  
  7, "shocked",
16  
  8, "worried",
17  
  9, "winking",
18  
  10, "closed eyes",
19  
  11, "uuuhm",
20  
  12, "super-lol",
21  
  13, "oooh",
22  
  14, "angry",
23  
  15, "disappointed"
24  
);
25  
26  
static ImageSurface is;
27  
static JCheckBox cbAnimate;
28  
static int idx;
29  
30  
p-subst {
31  
  BufferedImage bi = loadImage2(imageID);
32  
  L<Rect> theRects = cast unstructure(rects);
33  
  final Pt size = ceilScalePt(rectsMaxSize(theRects), zoom);
34  
  repeat with sleep 4 {
35  
    bool first = is == null;
36  
    if (first || isChecked(cbAnimate)) {
37  
      Rect r = random(theRects);
38  
      idx = theRects.indexOf(r);
39  
      is = showZoomedImage_centered(is, clipBufferedImage(bi, r), zoom);
40  
      setFrameTitle(is, "Emotion " + (idx + 1) + "/" + l(theRects) + " - " + or2(names.get(idx+1), "?"));
41  
      if (first) awt {
42  
        moveToTopRightCorner(frameInnerSize(size, getFrame(is)));
43  
        addToWindow(is, withMargin(cbAnimate = jCheckBox("Cycle", true)));
44  
        hideConsole();
45  
      }
46  
    }
47  
  }
48  
}

Author comment

Began life as a copy of #1007258

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, iveijnkanddl, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1007266
Snippet name: Random Smiley Emotions [WORKS]
Eternal ID of this version: #1007266/32
Text MD5: 2c38c2cbf51035833b98485709276e50
Transpilation MD5: 95245926afe1f3e98315518f6b087bed
Author: stefan
Category: javax / imaging
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-15 14:58:06
Source code size: 1774 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 558 / 706
Version history: 31 change(s)
Referenced in: [show references]