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

1  
!7
2  
3  
sS imageID = #1006973;
4  
static int width = 200;
5  
6  
module MouseHeart > DynEnabled {
7  
  transient JWindow w;
8  
  transient java.util.Timer timer;
9  
  
10  
  //*() { enabled = false; }
11  
  
12  
  start { update(); }
13  
  
14  
  void cleanMeUp { disposeWindow(w); }
15  
  
16  
  void update {
17  
    print("update " + enabled);
18  
    if (!enabled) {
19  
      setVisible(w, false);
20  
      cancelTimer(timer); timer = null;
21  
      ret;
22  
    }
23  
    
24  
    if (w == null) {
25  
      BufferedImage img = loadBufferedImage(imageID);
26  
      BufferedImage resized = resizeImage(img, width);
27  
      w = showAnimation(resized);
28  
      final Shape shape = scaleShape(alphaToShape(img), width/(double) img.getWidth());
29  
      swing { w.setShape(shape); }
30  
    }
31  
    
32  
    setVisible(w, true);
33  
  
34  
    if (timer == null) timer = doEvery(20, r {
35  
      setLocation(w, mouseX()+2, mouseY()+2)
36  
    });
37  
  }
38  
}

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