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

38
LINES

< > BotCompany Repo | #1020030 // Follow the mouse cursor with a heart [Dyn Module]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (15443L/107K).

!7

sS imageID = #1006973;
static int width = 200;

module MouseHeart > DynEnabled {
  transient JWindow w;
  transient java.util.Timer timer;
  
  //*() { enabled = false; }
  
  start { update(); }
  
  void cleanMeUp { disposeWindow(w); }
  
  void update {
    print("update " + enabled);
    if (!enabled) {
      setVisible(w, false);
      cancelTimer(timer); timer = null;
      ret;
    }
    
    if (w == null) {
      BufferedImage img = loadBufferedImage(imageID);
      BufferedImage resized = resizeImage(img, width);
      w = showAnimation(resized);
      final Shape shape = scaleShape(alphaToShape(img), width/(double) img.getWidth());
      swing { w.setShape(shape); }
    }
    
    setVisible(w, true);
  
    if (timer == null) timer = doEvery(20, r {
      setLocation(w, mouseX()+2, mouseY()+2)
    });
  }
}

Author comment

Began life as a copy of #1006974

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020030
Snippet name: Follow the mouse cursor with a heart [Dyn Module]
Eternal ID of this version: #1020030/8
Text MD5: 5f974103f4bdcd83292b25463984ecec
Transpilation MD5: aec951a13c928946fd5712e343d0fc8a
Author: stefan
Category: javax / gui effects
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-04 16:03:00
Source code size: 871 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 266 / 352
Version history: 7 change(s)
Referenced in: [show references]