{"id":286,"date":"2009-05-16T21:20:23","date_gmt":"2009-05-17T04:20:23","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1375"},"modified":"2009-05-16T21:20:23","modified_gmt":"2009-05-17T04:20:23","slug":"messy-code","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=286","title":{"rendered":"Messy Code"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar xp:Number=0,yp:Number=0;\r\nvar r:Number=0,t:Number=0;\r\nvar speed:Number=.01;\r\nvar scale:Number=10;\r\nvar shape:Shape = Shape(addChild(new Shape()));\r\nshape.x=stage.stageWidth\/2;\r\nshape.y=stage.stageHeight\/2;\r\nshape.graphics.lineStyle(0,0x000000);\r\n\r\nvar s:Number=100;\r\nvar range:Number=.2;\r\nvar b:Number=20;\r\nvar a:Number =b*range;\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\trange=.2;\r\n\tb=20;\r\n\ta=b*range;\r\n\tt=0;\r\n\tshape.graphics.clear();\r\n\tshape.graphics.lineStyle(0,0);\r\n\tfor (var i:int = 0; i&lt;6000; i++) {\r\n\t\tvar sin:Number=Math.cos(t*int(mouseY\/20));\r\n\t\tr =  Math.sqrt(40 * b * (b - a * (Math.pow(sin, int(mouseX\/20)))));\r\n\t\txp=r*Math.cos(t);\r\n\t\typ=r*Math.sin(t);\r\n\r\n\t\tif (t==0) {\r\n\t\t\tshape.graphics.lineStyle(0, 0);\r\n\t\t\tshape.graphics.moveTo(xp, yp);\r\n\t\t} else {\r\n\t\t\tshape.graphics.lineTo(xp, yp);\r\n\t\t}\r\n\t\tt+=speed;\r\n\t\tif (t &gt; (2 * Math.PI + speed)) {\r\n\t\t\trange+=.3;\r\n\t\t\ta=b*range;\r\n\t\t\tt=0;\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>This is an example of raw messy code that draws some interesting shapes. I was waiting somewhere with my laptop a few weeks back and I wrote this and e-mailed this to myself &#8211; it&#8217;s completely unoptimized and unedited.<\/p>\n<p>I was working on documentation for QuickBox2D today but didn&#8217;t finish it &#8211; so I posted this instead. I hope to finish the docs for tomorrow&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>var xp:Number=0,yp:Number=0; var r:Number=0,t:Number=0; var speed:Number=.01; var scale:Number=10; var shape:Shape = Shape(addChild(new Shape())); shape.x=stage.stageWidth\/2; shape.y=stage.stageHeight\/2; shape.graphics.lineStyle(0,0&#215;000000); var s:Number=100; var range:Number=.2; var b:Number=20; var a:Number =b*range; addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { range=.2; b=20; a=b*range; t=0; shape.graphics.clear(); shape.graphics.lineStyle(0,0); for (var i:int = 0; i&lt;6000; i++) { var sin:Number=Math.cos(t*int(mouseY\/20)); r = Math.sqrt(40 * b * (b &#8211; a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[94],"tags":[3,4],"class_list":["post-286","post","type-post","status-publish","format-standard","hentry","category-misc","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/286","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=286"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/286\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}