{"id":329,"date":"2009-06-28T05:00:04","date_gmt":"2009-06-28T12:00:04","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1646"},"modified":"2009-06-28T05:00:04","modified_gmt":"2009-06-28T12:00:04","slug":"2x-mod-1-map","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=329","title":{"rendered":"2x mod 1 map"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\n&#x5B;SWF(width=800, height=600)]\r\nvar xn1:Number;\r\nvar xn:Number = Math.random() * Math.random() * .2;\r\nvar inc:int = 0;\r\nvar xp:Number = 10;\r\nvar yp:Number = 10;\r\nvar count:int = 1;\r\nscaleX = scaleY = 2;\r\ngraphics.lineStyle(0,0x00000);\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n\t\r\n     xn1 = 2 * xn % 1;\r\n\t xn = xn1;\r\n\t if (inc == 0){\r\n\t\t  graphics.moveTo(xp + inc, yp + 30 - xn1 * 30);\r\n\t }else{\r\n\t\t graphics.lineTo(xp + inc, yp + 30 - xn1 * 30);\r\n\t }\r\n\t inc++\r\n\t if (inc == 50){\r\n\t\t inc = 0;\r\n\t\t xp = 10 + count % 6 * 60;\r\n\t\t yp = 10 + int(count \/ 6) * 60;\r\n\t\t xn = Math.random() * Math.random() * .2;\r\n\t\t trace(xn);\r\n\t\t count++;\r\n\t }\r\n}\r\n<\/pre>\n<p>This snippet plots 2x mod 1 maps with random starting values for xn. More info over at <a href=\"http:\/\/en.wikipedia.org\/wiki\/2x_mod_1_map\">wikipedia<\/a> and <a href=\"http:\/\/mathworld.wolfram.com\/2xmod1Map.html\">mathworld<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#x5B;SWF(width=800, height=600)] var xn1:Number; var xn:Number = Math.random() * Math.random() * .2; var inc:int = 0; var xp:Number = 10; var yp:Number = 10; var count:int = 1; scaleX = scaleY = 2; graphics.lineStyle(0,0&#215;00000); addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { xn1 = 2 * xn % 1; xn = xn1; if (inc == 0){ graphics.moveTo(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":[121,94,13],"tags":[3,14,4],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-math","category-misc","category-motion","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/329","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=329"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}