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

sclass VolatileImageSurfaceDemo is Swingable {
  new Timings timings;
  JLabel lblTimings = jlabel();
  JVolatileImageSurface surface;
  
  settable Renderable renderable = (g, w, h) -> {
    time("background", -> {
      g.setColor(Color.green);
      g.fillRect(0, 0, w, h);
    });
    time("circle", ->
      fillCircle(g, w/2, h/2, w/4, Color.blue));
  };
  
  visualize {
    surface = new JVolatileImageSurface(renderable);

    awtDoEvery(lblTimings, 1.0, -> lblTimings.setText(timings.toStringSingleLine()));
    
   JCheckBox cbVolatileMode = jCheckBox(true, "Use volatile image", b -> surface.setVolatileMode(b));
   
   ret northCenterAndSouthWithMargin(
     jcenteredline(cbVolatileMode),
     surface,
     lblTimings);
  }
  
  void time(S name, Runnable r) {
    S mode = surface.volatileMode() ? " [vol]" : "";
    timings.time(name + mode, r);
  }
}

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: 155 / 285
Version history: 7 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)
#1034407 - volatileImageScalingDemo