{"id":121,"date":"2008-12-12T00:00:31","date_gmt":"2008-12-12T07:00:31","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=340"},"modified":"2008-12-12T00:00:31","modified_gmt":"2008-12-12T07:00:31","slug":"texture-cosatan2","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=121","title":{"rendered":"Texture cos(atan2())"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar col:int, i:int, j:int, s:int = 500, div:Number =20, outcoord:Point = new Point(), points:Vector.&lt;Point&gt; = new Vector.&lt;Point&gt;();\r\nfor (i = 0; i&lt;5; i++) points.push(new Point(int(Math.random()*s),int(Math.random()*s)));\r\nvar canvas:Bitmap = Bitmap(addChild(new Bitmap(new BitmapData(s,s, false, 0xFF0000), &quot;auto&quot;, true)));\r\nfor (i  = 0; i&lt;canvas.width * canvas.height; i++){\r\n\toutcoord= new Point( i % canvas.width, i \/ canvas.width);\r\n\tcol = 0;\r\n\tfor (j= 0; j&lt;points.length; j++) col += Math.max(0,255 * Math.cos(Math.atan2(outcoord.y - points&#x5B;j].y, outcoord.x - points&#x5B;j].x)*outcoord.x\/div) );\r\n\tcol \/= points.length;\r\n    canvas.bitmapData.setPixel(outcoord.x, outcoord.y,  col &lt;&lt; 16 |  col &lt;&lt; 8 |  col);\r\n}\r\n<\/pre>\n<p>This is inspired by some stuff I&#8217;ve been doing with PixelBender. I think I&#8217;m going to convert this to processing to see how fast I can get it to run&#8230; will post that over at <a href=\"http:\/\/www.shapevent.com\/\">shapevent<\/a>. People have been asking me to post swfs&#8230;. and I plan on starting to that a little bit&#8230; but since this one doesn&#8217;t animate, here are a few jpgs:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.actionsnippet.com\/imgs\/tex_one.jpg\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.actionsnippet.com\/imgs\/tex_two.jpg\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.actionsnippet.com\/imgs\/tex_three.jpg\" \/><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.actionsnippet.com\/imgs\/tex_four.jpg\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var col:int, i:int, j:int, s:int = 500, div:Number =20, outcoord:Point = new Point(), points:Vector.&lt;Point&gt; = new Vector.&lt;Point&gt;(); for (i = 0; i&lt;5; i++) points.push(new Point(int(Math.random()*s),int(Math.random()*s))); var canvas:Bitmap = Bitmap(addChild(new Bitmap(new BitmapData(s,s, false, 0xFF0000), &quot;auto&quot;, true))); for (i = 0; i&lt;canvas.width * canvas.height; i++){ outcoord= new Point( i % canvas.width, i \/ canvas.width); col = 0; [&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":[3,4],"class_list":["post-121","post","type-post","status-publish","format-standard","hentry","category-bitmapdata","category-pixel-manipulation","category-setpixel","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/121","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=121"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/121\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}