{"id":73,"date":"2008-10-28T23:34:45","date_gmt":"2008-10-29T06:34:45","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=21"},"modified":"2008-10-28T23:34:45","modified_gmt":"2008-10-29T06:34:45","slug":"setpixel-radial-gradient","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=73","title":{"rendered":"setPixel() Radial Gradient"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n \/\/ add a BitmapData object to the stage in one line:\r\naddChild(new Bitmap(new BitmapData(200,200,false,0x00000)));\r\n\r\n\/\/ draw a radial gradient\r\nfor (var i:int = 0; i&lt;200; i++) for (var j:int = 0; j&lt;200; j++) \r\nBitmap(getChildAt(0)).bitmapData.setPixel( i, j, 100 + 100 * Math.sin(Math.sqrt(Math.pow(i - 100, 2)+Math.pow(j - 100, 2)) * 40 * Math.PI\/180) &lt;&lt; 16 );\r\n\r\n\/*\r\nWARNING: This code was written for fun. Use at your own risk.\r\n*\/\r\n<\/pre>\n<p>Next I&#8217;ll post a readable version, just wanted to see how compact I could get this&#8230; <\/p>\n<p>This was inspired by all the pixel bender stuff that I&#8217;ve seen. I did the same thing with setVector() &#8211; will post about setVector() in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ add a BitmapData object to the stage in one line: addChild(new Bitmap(new BitmapData(200,200,false,0x00000))); \/\/ draw a radial gradient for (var i:int = 0; i&lt;200; i++) for (var j:int = 0; j&lt;200; j++) Bitmap(getChildAt(0)).bitmapData.setPixel( i, j, 100 + 100 * Math.sin(Math.sqrt(Math.pow(i &#8211; 100, 2)+Math.pow(j &#8211; 100, 2)) * 40 * Math.PI\/180) &lt;&lt; 16 ); \/* [&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,25,26],"tags":[27,28,29],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-pixel-manipulation","category-setpixel","tag-pythagorean","tag-radial-gradient","tag-sine"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/73","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=73"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}