!7 static int w = 32, h = 16, ww = 400, hh = 200; static DirectSurface ds; static BufferedImage img; sbool continuous = false, rareRepaint = true, shootInParallel = true; static int speed = 0; static volatile BufferedImage src = null; static long screenshotTime = 0; static int frames; static long start; sclass DirectSurface extends Surface { BufferedImage img; *() {} *(BufferedImage *img) {} public void render(int w, int h, Graphics2D g) { g.drawImage(img, 0, 0, null); } public Dimension getPreferredSize() { ret new Dimension(img.getWidth(), img.getHeight()); } } p-substance { img = newBufferedImage(ww, hh); showPackedFrame(ds = new DirectSurface(img)); shootMaybe(); if (shootInParallel) thread { repeat with sleep 100 { shootMaybe(); } } thread { PerSecondCounter fps = new(5); long consoleUpdate = 0; repeat { if (!shootInParallel) shootMaybe(); ++frames; start = sysNow(); for (int y = 0; y < hh; y += h) for (int x = 0; x < ww; x += w) { int srcw, srch; if (src != null) { srcw = src.getWidth(); srch = src.getHeight(); } else { Dimension ss = screenSize(); srcw = ss.width; srch = ss.height; } int srcX = random(srcw-w), srcY = random(srch-h); if (continuous) drawImageOnImage(screenshot(srcX, srcY, w, h), img, x, y); else copyImagePart(src, srcX, srcY, img, x, y, w, h); if (!rareRepaint) ds.paintImmediately(x, y, w, h); sleep(speed); } if (rareRepaint) ds.repaint(); //consoleStatus(iterationsPerSecond(frames, sysNow()-start) + " fps"); fps.inc(); if (sysNow() >= consoleUpdate+1000) { consoleUpdate = sysNow(); consoleStatus(iround(fps!) + " fps"); } } } } svoid shootMaybe { if (!continuous && (src == null || sysNow() > screenshotTime+1000)) { src = screenshot(); screenshotTime = sysNow(); } }