{"id":1893,"date":"2016-12-16T08:24:01","date_gmt":"2016-12-16T00:24:01","guid":{"rendered":"http:\/\/www.magicandlove.com\/blog\/?p=1893"},"modified":"2016-12-16T08:24:01","modified_gmt":"2016-12-16T00:24:01","slug":"screen-capture-in-processing","status":"publish","type":"post","link":"http:\/\/www.magicandlove.com\/blog\/2016\/12\/16\/screen-capture-in-processing\/","title":{"rendered":"Screen capture in Processing"},"content":{"rendered":"<p>This sketch demonstrates the use of the Robot class in Java to perform screen capture in Processing. It will create <a href=\"http:\/\/jodi.org\" target=\"_blank\">Jodi<\/a> like effect with feedback in computer screen. Have fun with it.<\/p>\n<p><a href=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2016\/12\/feedbback.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1894\" title=\"Feedback in Processing\" src=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2016\/12\/feedbback-300x168.png\" alt=\"\" width=\"300\" height=\"168\" srcset=\"http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2016\/12\/feedbback-300x168.png 300w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2016\/12\/feedbback-1024x575.png 1024w, http:\/\/www.magicandlove.com\/blog\/wp-content\/uploads\/2016\/12\/feedbback.png 1366w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Here are the codes. It makes use of the <a href=\"https:\/\/docs.oracle.com\/javase\/8\/docs\/api\/java\/awt\/Robot.html\" target=\"_blank\">Robot<\/a> class.<\/p>\n<pre lang=\"java\">\r\n\r\nimport java.awt.Robot;\r\nimport java.awt.image.BufferedImage;\r\nimport java.awt.Rectangle;\r\n\r\nRobot robot;\r\n\r\nvoid setup() {\r\n  size(640, 480);\r\n  try {\r\n    robot = new Robot();\r\n  } \r\n  catch (Exception e) {\r\n    println(e.getMessage());\r\n  }\r\n}\r\n\r\nvoid draw() {\r\n  background(0);\r\n  Rectangle r = new Rectangle(mouseX, mouseY, width, height);\r\n  BufferedImage img1 = robot.createScreenCapture(r);\r\n  PImage img2 = new PImage(img1);\r\n  image(img2, 0, 0);\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[79,66],"tags":[152,62,153],"class_list":["post-1893","post","type-post","status-publish","format-standard","hentry","category-software-2","category-testing","tag-jodi","tag-processing-org","tag-screen-capture"],"_links":{"self":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/comments?post=1893"}],"version-history":[{"count":1,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1893\/revisions"}],"predecessor-version":[{"id":1895,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/posts\/1893\/revisions\/1895"}],"wp:attachment":[{"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/media?parent=1893"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/categories?post=1893"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.magicandlove.com\/blog\/wp-json\/wp\/v2\/tags?post=1893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}