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

32
LINES

< > BotCompany Repo | #1034401 // VolatileImageSurfaceDemo

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (10228L/58K).

1  
sclass VolatileImageSurfaceDemo is Swingable {
2  
  new Timings timings;
3  
  JLabel lblTimings = jlabel();
4  
  JVolatileImageSurface surface;
5  
  
6  
  settable Renderable renderable = (g, w, h) -> {
7  
    time("background", -> {
8  
      g.setColor(Color.green);
9  
      g.fillRect(0, 0, w, h);
10  
    });
11  
    time("circle", ->
12  
      fillCircle(g, w/2, h/2, w/4, Color.blue));
13  
  };
14  
  
15  
  visualize {
16  
    surface = new JVolatileImageSurface(renderable);
17  
18  
    awtDoEvery(lblTimings, 1.0, -> lblTimings.setText(timings.toStringSingleLine()));
19  
    
20  
   JCheckBox cbVolatileMode = jCheckBox(true, "Use volatile image", b -> surface.setVolatileMode(b));
21  
   
22  
   ret northCenterAndSouthWithMargin(
23  
     jcenteredline(cbVolatileMode),
24  
     surface,
25  
     lblTimings);
26  
  }
27  
  
28  
  void time(S name, Runnable r) {
29  
    S mode = surface.volatileMode() ? " [vol]" : "";
30  
    timings.time(name + mode, r);
31  
  }
32  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034401
Snippet name: VolatileImageSurfaceDemo
Eternal ID of this version: #1034401/8
Text MD5: f1bc604457243dcb92734df788497b0d
Transpilation MD5: 9728bd2ed310e7bc16a920778b16d6ae
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-05 23:21:44
Source code size: 899 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 86 / 188
Version history: 7 change(s)
Referenced in: [show references]