{"id":154,"date":"2009-01-14T00:00:53","date_gmt":"2009-01-14T07:00:53","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=524"},"modified":"2009-01-14T00:00:53","modified_gmt":"2009-01-14T07:00:53","slug":"bitmapdata-trails","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=154","title":{"rendered":"BitmapData Trails"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(width=400, height=400, backgroundColor=0xCCCCCC, frameRate=30)]\r\n\r\nvar canvas:BitmapData = new BitmapData(400, 400, true, 0xCCCCCC);\r\nvar eraser:BitmapData = new BitmapData(400, 400, true, 0x22CCCCCC);\r\naddChild(new Bitmap(canvas));\r\n\r\nvar circle:Shape = Shape(addChild(new Shape()));\r\nwith (circle.graphics) beginFill(0x000000), drawCircle(0,0,20);\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\n\r\nfunction onLoop(evt:Event):void {\r\n\tcanvas.copyPixels(eraser, eraser.rect, new Point(0,0), null, null, true);\r\n\tcircle.x = mouseX;\r\n\tcircle.y = mouseY;\r\n\t\r\n\tcanvas.draw(circle, circle.transform.matrix);\r\n}\r\n<\/pre>\n<p>Create trails by slowly erasing the background with copyPixels(). The first time I ever saw this technique was back when <a href=\"http:\/\/www.setPixel.com\/\" target=\"blank\">setpixel.com<\/a> contained a bunch of great director experiments by Charles Foreman (creator of <a href=\"http:\/\/www.iminlikewithyou.com\/\">iminlikewithyou.com<\/a>). <\/p>\n<p>At some point last semester I showed <a href=\"http:\/\/iminlikewithyou.com\/#\/arcade\/gamelobby\/hamsterbattle\" target=\"blank\">iminlikewithyou hamster battle<\/a> to my undergrad students towards the end of class&#8230;. probably one of the funniest moments of that class.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;SWF(width=400, height=400, backgroundColor=0xCCCCCC, frameRate=30)] var canvas:BitmapData = new BitmapData(400, 400, true, 0xCCCCCC); var eraser:BitmapData = new BitmapData(400, 400, true, 0x22CCCCCC); addChild(new Bitmap(canvas)); var circle:Shape = Shape(addChild(new Shape())); with (circle.graphics) beginFill(0x000000), drawCircle(0,0,20); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { canvas.copyPixels(eraser, eraser.rect, new Point(0,0), null, null, true); circle.x = mouseX; circle.y = mouseY; canvas.draw(circle, circle.transform.matrix); } Create trails by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,94],"tags":[3,4],"class_list":["post-154","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-misc","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/154","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=154"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/154\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=154"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=154"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=154"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}