{"id":505,"date":"2010-04-06T08:28:45","date_gmt":"2010-04-06T15:28:45","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=2887"},"modified":"2010-04-06T08:28:45","modified_gmt":"2010-04-06T15:28:45","slug":"relaxing-with-sine-and-cosine","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=505","title":{"rendered":"Relaxing with Sine and Cosine"},"content":{"rendered":"<p>Last night I wanted to play with sine and cosine waves so I created this snippet:<\/p>\n<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nvar wave:Number = 0;\r\naddEventListener(Event.ENTER_FRAME, onLoop);\r\nfunction onLoop(evt:Event):void {\r\n       graphics.clear()\r\n       graphics.lineStyle(0,0);\r\n       var time:Number = (stage.stageWidth\/2 - mouseX)\/10\r\n       for (var j:int = 0; j&lt;100; j++){\r\n               var offset:Number = j\/10;\r\n               var t:Number = 0;\r\n               var wh:Number = j * 4;\r\n               for (var i:int = 0; i&lt;300; i++){\r\n                       wave = cos(10-offset, t + time + offset) \r\n\t\t\t\t\t          + sin(time, t\/2 + time - offset) + wh\r\n                              + cos(3, t * 4);\r\n                       t += 0.1;\r\n\t\t\t\t\t   var xoff:Number = i * 2;\r\n                       if (i == 0){\r\n                               graphics.moveTo(100 + xoff, 100 + wave);\r\n                       }else{\r\n                               graphics.lineTo(100 + xoff, 100 + wave);\r\n                       }\r\n\r\n               }\r\n       }\r\n}\r\n\r\nfunction cos(radius:Number, theta:Number):Number{\r\n       return radius * Math.cos(theta);\r\n}\r\nfunction sin(radius:Number, theta:Number):Number{\r\n       return radius * Math.sin(theta);\r\n}\r\n<\/pre>\n<p><a data-asruffle-linked=\"true\" href=\"http:\/\/www.actionsnippet.com\/swfs\/cos_sin_waves.html\" target=\"blank\"><br \/>\nHave a look at the swf&#8230;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/actionsnippet.com\/wp-content\/waves.jpg\" \/><\/a> <span class=\"asruffle-link\" data-swf=\"{&quot;url&quot;:&quot;https:\\\/\\\/actionsnippet.com\\\/swfs\\\/simple_waves.swf&quot;,&quot;title&quot;:&quot;simple waves&quot;,&quot;width&quot;:800,&quot;height&quot;:600,&quot;missing&quot;:false,&quot;allowScriptAccess&quot;:false,&quot;backgroundColor&quot;:&quot;#ffffff&quot;}\"><button type=\"button\" hidden aria-expanded=\"false\">Play demo<span class=\"screen-reader-text\">: simple waves<\/span><\/button><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last night I wanted to play with sine and cosine waves so I created this snippet: var wave:Number = 0; addEventListener(Event.ENTER_FRAME, onLoop); function onLoop(evt:Event):void { graphics.clear() graphics.lineStyle(0,0); var time:Number = (stage.stageWidth\/2 &#8211; mouseX)\/10 for (var j:int = 0; j&lt;100; j++){ var offset:Number = j\/10; var t:Number = 0; var wh:Number = j * 4; for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-505","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/505","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=505"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/505\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=505"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=505"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=505"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}