{"id":515,"date":"2010-05-13T08:44:08","date_gmt":"2010-05-13T15:44:08","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2927"},"modified":"2010-05-13T08:44:08","modified_gmt":"2010-05-13T15:44:08","slug":"fish-curve","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=515","title":{"rendered":"Fish Curve"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar xp:Number = 0;\r\nvar yp:Number = 0;\r\nvar t:Number = 0;\r\nvar a:Number = 200;\r\nx = stage.stageWidth \/ 2;\r\ny = stage.stageHeight \/ 2;\r\n\r\ngraphics.lineStyle(0,0x000000);\r\naddEventListener(Event.ENTER_FRAME, onRun);\r\nfunction onRun(evt:Event):void {\r\n\txp = a * Math.cos(t) - (a * Math.pow(Math.sin(t),2))\/Math.sqrt(2);\r\n\typ = a * Math.cos(t) * Math.sin(t);\r\n\tif (t == 0){\r\n\t  graphics.moveTo(xp, yp);\r\n\t}else{\r\n\t  graphics.lineTo(xp, yp);\r\n\t}\r\n\tt += 0.05;\r\n}\r\n<\/pre>\n<p>While surfing mathworld I stumbled upon the equation for something called the <a href=\"http:\/\/mathworld.wolfram.com\/FishCurve.html\">Fish Curve<\/a>. This snippet will draw something like this:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/fishcurve.gif\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>var xp:Number = 0; var yp:Number = 0; var t:Number = 0; var a:Number = 200; x = stage.stageWidth \/ 2; y = stage.stageHeight \/ 2; graphics.lineStyle(0,0&#215;000000); addEventListener(Event.ENTER_FRAME, onRun); function onRun(evt:Event):void { xp = a * Math.cos(t) &#8211; (a * Math.pow(Math.sin(t),2))\/Math.sqrt(2); yp = a * Math.cos(t) * Math.sin(t); if (t == 0){ graphics.moveTo(xp, yp); }else{ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,94],"tags":[3,14,4],"class_list":["post-515","post","type-post","status-publish","format-standard","hentry","category-math","category-misc","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/515","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=515"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/515\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}