Created
September 19, 2013 04:56
-
-
Save tboydar/6619271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage; | |
import java.awt.*; | |
PImage screenShot; | |
void setup() { | |
size(800, 600); | |
screenShot = getScreen(); | |
} | |
void draw () { | |
pushMatrix(); | |
translate(mouseX,mouseY); | |
rotate(radians(270)); | |
image(screenShot,0,0, 300,300); | |
popMatrix(); | |
delay(1000); | |
screenShot = getScreen(); | |
} | |
PImage getScreen() { | |
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
GraphicsDevice[] gs = ge.getScreenDevices(); | |
DisplayMode mode = gs[0].getDisplayMode(); | |
Rectangle bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight()); | |
BufferedImage desktop = new BufferedImage(mode.getWidth(), mode.getHeight(), BufferedImage.TYPE_INT_RGB); | |
try { | |
desktop = new Robot(gs[0]).createScreenCapture(bounds); | |
} | |
catch(AWTException e) { | |
System.err.println("Screen capture failed."); | |
} | |
return (new PImage(desktop)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment