Uses 3874K of libraries. Click here for Pure Java version (4008L/28K/99K).
1 | !7 |
2 | |
3 | static int w = 32, h = 16, ww = 400, hh = 200; |
4 | static DirectSurface ds; |
5 | static BufferedImage img; |
6 | sbool continuous = false, rareRepaint = true, shootInParallel = true; |
7 | static int speed = 0; |
8 | |
9 | static volatile BufferedImage src = null; |
10 | static long screenshotTime = 0; |
11 | static int frames; |
12 | static long start; |
13 | |
14 | sclass DirectSurface extends Surface { |
15 | BufferedImage img; |
16 | |
17 | *() {} |
18 | *(BufferedImage *img) {} |
19 | |
20 | public void render(int w, int h, Graphics2D g) { |
21 | g.drawImage(img, 0, 0, null); |
22 | } |
23 | |
24 | public Dimension getPreferredSize() { |
25 | ret new Dimension(img.getWidth(), img.getHeight()); |
26 | } |
27 | } |
28 | |
29 | p-substance { |
30 | img = newBufferedImage(ww, hh); |
31 | showPackedFrame(ds = new DirectSurface(img)); |
32 | |
33 | shootMaybe(); |
34 | if (shootInParallel) thread { |
35 | repeat with sleep 100 { |
36 | shootMaybe(); |
37 | } |
38 | } |
39 | |
40 | thread { |
41 | PerSecondCounter fps = new(5); |
42 | long consoleUpdate = 0; |
43 | repeat { |
44 | if (!shootInParallel) shootMaybe(); |
45 | |
46 | ++frames; |
47 | start = sysNow(); |
48 | for (int y = 0; y < hh; y += h) |
49 | for (int x = 0; x < ww; x += w) { |
50 | int srcw, srch; |
51 | if (src != null) { |
52 | srcw = src.getWidth(); |
53 | srch = src.getHeight(); |
54 | } else { |
55 | Dimension ss = screenSize(); |
56 | srcw = ss.width; srch = ss.height; |
57 | } |
58 | int srcX = random(srcw-w), srcY = random(srch-h); |
59 | if (continuous) |
60 | drawImageOnImage(screenshot(srcX, srcY, w, h), img, x, y); |
61 | else |
62 | copyImagePart(src, srcX, srcY, img, x, y, w, h); |
63 | if (!rareRepaint) ds.paintImmediately(x, y, w, h); |
64 | sleep(speed); |
65 | } |
66 | |
67 | if (rareRepaint) ds.repaint(); |
68 | //consoleStatus(iterationsPerSecond(frames, sysNow()-start) + " fps"); |
69 | fps.inc(); |
70 | if (sysNow() >= consoleUpdate+1000) { |
71 | consoleUpdate = sysNow(); |
72 | consoleStatus(iround(fps!) + " fps"); |
73 | } |
74 | } |
75 | } |
76 | } |
77 | |
78 | svoid shootMaybe { |
79 | if (!continuous && (src == null || sysNow() > screenshotTime+1000)) { |
80 | src = screenshot(); |
81 | screenshotTime = sysNow(); |
82 | } |
83 | } |
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008796 |
Snippet name: | Shuffle (graphical) |
Eternal ID of this version: | #1008796/42 |
Text MD5: | 1ff2e29e82b62d72d6f16db08654d9ba |
Transpilation MD5: | 26f64a54e666c7ed1cb220b16c643968 |
Author: | stefan |
Category: | javax / homepage |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-06-07 01:19:19 |
Source code size: | 2156 bytes / 83 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 559 / 821 |
Version history: | 41 change(s) |
Referenced in: | [show references] |