Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.awt.*;
  2.  
  3. //Set the output boundaries
  4. static final int x1 = 0;
  5. static final int x2 = 1920;
  6. static final int y1 = 0;
  7. static final int y2 = 1080;
  8.  
  9. //There's no need to keep creating new Rectangles
  10. Rectangle captureSpace;
  11. Image img;
  12. PImage pimg;
  13. Robot robot;
  14.  
  15. void settings() {
  16. size(x2, y2, FX2D);
  17. noSmooth();
  18. }
  19.  
  20. void setup() {
  21. frameRate(30);
  22. try {
  23. robot = new Robot();
  24. }
  25. catch (AWTException cause) {
  26. println(cause);
  27. exit();
  28. }
  29. //Set the input boundaries
  30. captureSpace = new Rectangle(0, 0, displayWidth, displayHeight-50);
  31. //inputDimensions = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
  32. }
  33.  
  34. void draw() {
  35. //Set the window title to the current framerate.
  36. surface.setTitle("FPS: " + Math.round(frameRate));
  37.  
  38. //You have more control over how the image is resized with getScaledInstance
  39. img = robot.createScreenCapture(captureSpace).getScaledInstance(x2, y2, Image.SCALE_FAST);
  40. pimg = new PImage(img);
  41. image(pimg, 0, 0);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement