{"id":1070,"date":"2015-04-05T21:06:16","date_gmt":"2015-04-05T09:06:16","guid":{"rendered":"http:\/\/www.davidbrebner.com\/?p=1070"},"modified":"2015-04-06T21:53:22","modified_gmt":"2015-04-06T09:53:22","slug":"javascript-and-umajin","status":"publish","type":"post","link":"https:\/\/www.davidbrebner.com\/?p=1070","title":{"rendered":"Javascript and Umajin!"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/javascript1.jpg\" alt=\"javascript\" width=\"900\" height=\"250\" class=\"alignnone size-full wp-image-1073\" srcset=\"https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/javascript1.jpg 900w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/javascript1-150x42.jpg 150w, https:\/\/www.davidbrebner.com\/wp-content\/uploads\/2015\/04\/javascript1-300x83.jpg 300w\" sizes=\"(max-width: 900px) 100vw, 900px\" \/><\/p>\n<p>Along with Lua support you can now create custom actions in ECMA Javascript.  Thanks to the <a href=\"http:\/\/duktape.org\/\">duktape<\/a> project Umajin can now access a very clean embedded Javascript runtime implementation.  This is perfect for lightweight custom logic which you need to deploy as part of your application.<\/p>\n<p>Youku link <a href=\"http:\/\/player.youku.com\/embed\/XOTI3OTM1Nzgw\">here<\/a><\/p>\n<p><iframe width=\"900\" height=\"600\" src=\"https:\/\/www.youtube.com\/embed\/auVfLMKR71Y\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p>This video shows the performance which the javascript code executes at driving the Umajin rendering system to display lots of animated sprites.  As well as the default Umajin API we are working on matching Cordova\/PhoneGap API for hardware access as well as a NodeJS API using the Umajin network capabilities with Curl and LibUV.<\/p>\n<pre>\r\nfunction tick(){\r\n\tfor(a=1;a&lt;p_count;a++){\r\n\t\t\/\/update the sprite \r\n\t\tsprite_update(a-1, a%47, '', p_x[a], p_y[a], p_scale[a], p_angle[a], 255);\r\n\t\t\/\/update position\r\n\t\tp_angle[a] += 1;\r\n\t\tp_scale[a] += 0.005;\r\n\t\tp_x[a] += p_vx[a];\r\n\t\tp_y[a] -= p_vy[a];\r\n\t\t\/\/apply gravity\r\n\t\tp_vy[a] -= 0.05; \r\n\t\t\/\/recycle particles dropped off the bottom\r\n\t\tif (p_y[a]&gt;1000){\r\n\t\t\tinit_particle(a);\r\n\t\t}\r\n\t}\r\n}\r\n<\/pre>\n<p>Cheers<br \/>\n  David<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Along with Lua support you can now create custom actions in ECMA Javascript. Thanks to the duktape project Umajin can [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"image","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-1070","post","type-post","status-publish","format-image","hentry","category-umaijn","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1070","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1070"}],"version-history":[{"count":9,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1079,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=\/wp\/v2\/posts\/1070\/revisions\/1079"}],"wp:attachment":[{"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.davidbrebner.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}