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).

!7

static double zoom = 0.5;

sS imageID = #1007256;
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)] ]];

static Map<Int, S> names = littreemap(
  1, "happy",
  2, "sad",
  3, "extremely happy",
  4, "happy with tongue",
  5, "whaaat",
  6, "crying",
  7, "shocked",
  8, "worried",
  9, "winking",
  10, "closed eyes",
  11, "uuuhm",
  12, "super-lol",
  13, "oooh",
  14, "angry",
  15, "disappointed"
);

static ImageSurface is;
static JCheckBox cbAnimate;
static int idx;

p-subst {
  BufferedImage bi = loadImage2(imageID);
  L<Rect> theRects = cast unstructure(rects);
  final Pt size = ceilScalePt(rectsMaxSize(theRects), zoom);
  repeat with sleep 4 {
    bool first = is == null;
    if (first || isChecked(cbAnimate)) {
      Rect r = random(theRects);
      idx = theRects.indexOf(r);
      is = showZoomedImage_centered(is, clipBufferedImage(bi, r), zoom);
      setFrameTitle(is, "Emotion " + (idx + 1) + "/" + l(theRects) + " - " + or2(names.get(idx+1), "?"));
      if (first) awt {
        moveToTopRightCorner(frameInnerSize(size, getFrame(is)));
        addToWindow(is, withMargin(cbAnimate = jCheckBox("Cycle", true)));
        hideConsole();
      }
    }
  }
}

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: 556 / 704
Version history: 31 change(s)
Referenced in: [show references]