This sketch demonstrates the use of the Robot class in Java to perform screen capture in Processing. It will create Jodi like effect with feedback in computer screen. Have fun with it.
Here are the codes. It makes use of the Robot class.
import java.awt.Robot; import java.awt.image.BufferedImage; import java.awt.Rectangle; Robot robot; void setup() { size(640, 480); try { robot = new Robot(); } catch (Exception e) { println(e.getMessage()); } } void draw() { background(0); Rectangle r = new Rectangle(mouseX, mouseY, width, height); BufferedImage img1 = robot.createScreenCapture(r); PImage img2 = new PImage(img1); image(img2, 0, 0); } |