{"id":386,"date":"2011-12-09T12:05:04","date_gmt":"2011-12-09T20:05:04","guid":{"rendered":"http:\/\/new.joyofprocessing.com\/blog\/?p=386"},"modified":"2011-12-10T17:12:32","modified_gmt":"2011-12-11T01:12:32","slug":"frame-feedback","status":"publish","type":"post","link":"https:\/\/joyofprocessing.com\/blog\/2011\/12\/frame-feedback\/","title":{"rendered":"Frame Feedback"},"content":{"rendered":"<p><script type=\"application\/processing\">int currentFrame = 0;\nPImage[] frames = new PImage[24];\n\nvoid setup() {\n  size(500,400);\n  smooth();\n  background(255);\n  frameRate(24);\n  fill(0);\n}\n\nvoid draw()\n{\n  noCursor();\n  frames[currentFrame] = get(); \/\/ Get the display window\n  currentFrame = (currentFrame + 1) % frames.length;\n  if (frames[currentFrame] != null)\n    image(frames[currentFrame], 0, 0);\n\n  if (mouseX > 0 && mouseY > 0 && mouseX < width &&  mouseY < height)\n    ellipse(mouseX, mouseY, 10, 10);\n}\n\n\n<\/script><\/p>\n<div class=\"ps_cap\"><a href=\"\/showexample.php?ex=frame_feedback\">source<\/a><\/div>\n<p>\nWave the mouse slowly (or quickly) over the sketch to see something interesting.<\/p>\n<p>I was made aware of this clever technique from a beginner named <a href=\"https:\/\/forum.processing.org\/topic\/qwerty-colour\">textextex on the processing forum<\/a>.  He in turn was playing with the <a href=\"http:\/\/processing.org\/learning\/topics\/animator.html\">Drawing\/Animator<\/a> sketch in the examples that come with Processing. Here, I&#8217;ve stripped the idea to its essentials. <\/p>\n<p>An array of 24 images is used to make a one second circular buffer.  Each frame, we capture the current image, render the one from 1-second ago, and then draw a circle at the current mouse position.<\/p>\n<p>That&#8217;s it!  The cool thing is that you can create the impression of thousands of stored particles, using only a single particle.  The following GIF animation is made using this technique, recording the path of a single randomly moving particle for a few minutes, and then saving 24 frames to make a short loop.  The particle&#8217;s path starts in the exact middle.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.imgur.com\/MV6Nf.gif\" \/><\/p>\n<p>Here&#8217;s another one with different settings.  I&#8217;m still drawing dots, but I started with a large radius, and then worked my way down to a point radius.  This illustrates the power of this technique &#8211; individually tracking this many particles would kill the CPU if we weren&#8217;t using this feedback technique.<\/p>\n<p><img decoding=\"async\" src=\"\/assets\/frame_feedback_15.gif\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>source Wave the mouse slowly (or quickly) over the sketch to see something interesting. I was made aware of this clever technique from a beginner named textextex on the processing forum. He in turn was playing with the Drawing\/Animator sketch in the examples that come with Processing. Here, I&#8217;ve stripped the idea to its essentials. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[11,7,9,5,20],"class_list":["post-386","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-animation","tag-beginner","tag-circles","tag-easy","tag-tiny-sketch"],"_links":{"self":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/comments?post=386"}],"version-history":[{"count":10,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/386\/revisions"}],"predecessor-version":[{"id":401,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/posts\/386\/revisions\/401"}],"wp:attachment":[{"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/media?parent=386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/categories?post=386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/joyofprocessing.com\/blog\/wp-json\/wp\/v2\/tags?post=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}