{"id":9720,"date":"2013-05-08T10:57:56","date_gmt":"2013-05-08T01:57:56","guid":{"rendered":"http:\/\/www.softantenna.com\/wp\/?p=9720"},"modified":"2013-05-08T10:57:57","modified_gmt":"2013-05-08T01:57:57","slug":"two-js","status":"publish","type":"post","link":"https:\/\/softantenna.com\/blog\/two-js\/","title":{"rendered":"SVG\u3001Canvas\u3001WebGL\u5bfe\u5fdc\u306e2\u6b21\u5143\u63cf\u753b\u30e9\u30a4\u30d6\u30e9\u30ea\u300cTwo.js\u300d"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2013\/05\/blogTwo.js.png\" alt=\"Two js\" title=\"Two.js.png\" border=\"0\" width=\"463\" height=\"229\" \/><\/p>\n<p><a href=\"http:\/\/jonobr1.github.io\/two.js\/\">Two.js<\/a>\u306f\u3001\u30e2\u30c0\u30f3\u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306e2\u6b21\u5143\u63cf\u753b\u30e9\u30a4\u30d6\u30e9\u30ea\u3002SVG\u3001Canvas\u3001WebGL\u306e\u74b0\u5883\u306b\u5bfe\u3057\u3066\u3001\u540c\u3058API\u3092\u4f7f\u3063\u3066\u63cf\u753b\u3067\u304d\u308b\u3053\u3068\u304c\u58f2\u308a\u306e\u3088\u3046\u3067\u3059\u3002<\/p>\n<p><a href=\"https:\/\/raw.github.com\/jonobr1\/two.js\/master\/build\/two.js\">\u958b\u767a\u7248<\/a>\u3068\u3001<a href=\"https:\/\/raw.github.com\/jonobr1\/two.js\/master\/build\/two.min.js\">\u5b89\u5b9a\u7248<\/a>\u304c\u3042\u308a\u3001\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u306b<a href=\"http:\/\/underscorejs.org\/\">Underscore.js<\/a>\u3001<a href=\"http:\/\/backbonejs.org\/\">Backbone.js<\/a>\u3001<a href=\"https:\/\/github.com\/jonobr1\/two.js\">Events<\/a>\u304c\u5fc5\u8981\u3068\u3044\u3046\u3053\u3068\u3002\u3053\u306e\u8fba\u306f<a href=\"https:\/\/github.com\/jonobr1\/two.js\">Github<\/a>\u3092\u78ba\u8a8d\u3057\u305f\u307b\u3046\u304c\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><!--more--><\/p>\n<h3>\u4e38\u3068\u56db\u89d2<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2013\/05\/blogTwo.js-1.png\" alt=\"Two js 1\" title=\"Two.js-1.png\" border=\"0\" width=\"285\" height=\"198\" \/><br \/>\n\u3053\u3046\u3044\u3046\u4e38\u3068\u56db\u89d2\u306e\u7c21\u5358\u306a\u56f3\u5f62\u306e\u63cf\u753b\u3002<\/p>\n<pre><code class=\"javascript\">\/\/ Make an instance of two and place it on the page.\nvar elem = document.getElementById('draw-shapes').children[0];\nvar params = { width: 285, height: 200 };\nvar two = new Two(params).appendTo(elem);\n\n\/\/ two has convenience methods to create shapes.\nvar circle = two.makeCircle(72, 100, 50);\nvar rect = two.makeRectangle(213, 100, 100, 100);\n\n\/\/ The object returned has many stylable properties:\ncircle.fill = '#FF8000';\ncircle.stroke = 'orangered'; \/\/ Accepts all valid css color\ncircle.linewidth = 5;\n\nrect.fill = 'rgb(0, 200, 255)';\nrect.opacity = 0.75;\nrect.noStroke();\n\n\/\/ Don't forget to tell two to render everything\n\/\/ to the screen\ntwo.update();\n<\/code><\/pre>\n<p>\u3071\u3063\u3068\u898b\u308f\u304b\u308a\u3084\u3059\u3044\u30b3\u30fc\u30c9\u3067\u3059\u306d\u3002<\/p>\n<h3>\u4e38\u3068\u56db\u89d2\u3068\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/softantenna.com\/blog\/wp-content\/uploads\/2013\/05\/blogTwo.js-2.png\" alt=\"Two js 2\" title=\"Two.js-2.png\" border=\"0\" width=\"283\" height=\"193\" \/><br \/>\n\u4e38\u3068\u56db\u89d2\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u56de\u8ee2\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3055\u305b\u308b\u30b5\u30f3\u30d7\u30eb\u3067\u3059\u3002<\/p>\n<pre><code class=\"javascript\">var elem = document.getElementById('draw-animation').children[0];\nvar two = new Two({ width: 285, height: 200 }).appendTo(elem);\n\nvar circle = two.makeCircle(-70, 0, 50);\nvar rect = two.makeRectangle(70, 0, 100, 100);\ncircle.fill = '#FF8000';\nrect.fill = 'rgba(0, 200, 255, 0.75)';\n\nvar group = two.makeGroup(circle, rect);\ngroup.translation.set(two.width \/ 2, two.height \/ 2);\ngroup.scale = 0;\ngroup.noStroke();\n\n\/\/ Bind a function to scale and rotate the group\n\/\/ to the animation loop.\ntwo.bind('update', function(frameCount) {\n  \/\/ This code is called everytime two.update() is called.\n  \/\/ Effectively 60 times per second.\n  if (group.scale > 0.9999) {\n    group.scale = group.rotation = 0;\n  }\n  var t = (1 - group.scale) * 0.125;\n  group.scale += t;\n  group.rotation += t * 4 * Math.PI;\n}).play();  \/\/ Finally, start the animation loop\n<\/code><\/pre>\n<p>\u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u3063\u3066\u3001\u305d\u308c\u3092\u56de\u8ee2\u3055\u305b\u3066\u3044\u308b\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<h3>\u306a\u3093\u3068\u306a\u304f\u308f\u304b\u308a\u3084\u3059\u305d\u3046<\/h3>\n<p>JavaScript\u306e\u7d4c\u9a13\u304c\u5c11\u306a\u304f\u3066\u3082\u3001\u4ed6\u306e\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u540c\u7a2e\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u3063\u305f\u3053\u3068\u304c\u3042\u308b\u306a\u3089\u3001\u7c21\u5358\u306b\u7406\u89e3\u3067\u304d\u305d\u3046\u306a\u611f\u3058\u3067\u3057\u305f\u3002SVG\u3001Canvas\u3001WebGL\u5bfe\u5fdc\u3068\u3044\u3046\u3068\u3053\u308d\u3082\u826f\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Two.js\u306f\u3001\u30e2\u30c0\u30f3\u30d6\u30e9\u30a6\u30b6\u5411\u3051\u306e2\u6b21\u5143\u63cf\u753b\u30e9\u30a4\u30d6\u30e9\u30ea\u3002SVG\u3001Canvas\u3001WebGL\u306e\u74b0\u5883\u306b\u5bfe\u3057\u3066\u3001\u540c\u3058API\u3092\u4f7f\u3063\u3066\u63cf\u753b\u3067\u304d\u308b\u3053\u3068\u304c\u58f2\u308a\u306e\u3088\u3046\u3067\u3059\u3002 \u958b\u767a\u7248\u3068\u3001\u5b89\u5b9a\u7248\u304c\u3042\u308a\u3001\u52d5\u4f5c\u3055\u305b\u308b\u305f\u3081\u306bUnderscore. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":9717,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[75],"tags":[655,901],"class_list":["post-9720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-javascript","tag-two-js"],"_links":{"self":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/9720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/comments?post=9720"}],"version-history":[{"count":0,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/posts\/9720\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media\/9717"}],"wp:attachment":[{"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/media?parent=9720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/categories?post=9720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softantenna.com\/blog\/wp-json\/wp\/v2\/tags?post=9720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}