{"id":236,"date":"2009-03-29T00:00:57","date_gmt":"2009-03-29T07:00:57","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1062"},"modified":"2009-03-29T00:00:57","modified_gmt":"2009-03-29T07:00:57","slug":"fermats-spiral","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=236","title":{"rendered":"Fermat&#8217;s Spiral"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nx = stage.stageWidth \/ 2;\r\ny = stage.stageHeight \/ 2;\r\n\r\nvar xp:Number = 0, yp:Number = 0;\r\nvar r:Number = 0, t:Number = 0;\r\nvar speed:Number = .07;\r\nvar scale:Number = 20;\r\n\r\nvar plot0:Shape = Shape(addChild(new Shape()));\r\nvar plot1:Shape = Shape(addChild(new Shape()));\r\nplot0.graphics.lineStyle(0,0x000000);\r\nplot1.graphics.lineStyle(0,0x000000);\r\n\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t r =  scale * Math.sqrt(t);\r\n\t xp =  r * Math.cos(t);\r\n\t yp =  r * Math.sin(t);\r\n\t t += speed;\r\n\t \r\n\tplot0.graphics.lineTo(xp, yp);\r\n    plot1.graphics.lineTo(-xp, -yp);\r\n}\r\n<\/pre>\n<p>This snippet draws <a href=\"http:\/\/mathworld.wolfram.com\/FermatsSpiral.html\" target=\"blank\">Fermat&#8217;s Spiral<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>x = stage.stageWidth \/ 2; y = stage.stageHeight \/ 2; var xp:Number = 0, yp:Number = 0; var r:Number = 0, t:Number = 0; var speed:Number = .07; var scale:Number = 20; var plot0:Shape = Shape(addChild(new Shape())); var plot1:Shape = Shape(addChild(new Shape())); plot0.graphics.lineStyle(0,0&#215;000000); plot1.graphics.lineStyle(0,0&#215;000000); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { r = scale * Math.sqrt(t); xp [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,121,13],"tags":[3,4],"class_list":["post-236","post","type-post","status-publish","format-standard","hentry","category-graphics","category-math","category-motion","tag-actionscript","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/236","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=236"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/236\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=236"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=236"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=236"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}