{"id":4320,"date":"2012-02-06T19:09:58","date_gmt":"2012-02-06T10:09:58","guid":{"rendered":"http:\/\/clockmaker.jp\/blog\/?p=4320"},"modified":"2014-01-26T13:26:35","modified_gmt":"2014-01-26T04:26:35","slug":"html5_canvas_forcemap","status":"publish","type":"post","link":"https:\/\/clockmaker.jp\/blog\/2012\/02\/html5_canvas_forcemap\/","title":{"rendered":"HTML5 Canvas\u3092\u59cb\u3081\u3088\u3046\uff1aEaselJS\u3092\u4f7f\u3063\u305f\u6d41\u4f53\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u5165\u9580"},"content":{"rendered":"<p class=\"photo\"><a href=\"http:\/\/clockmaker.jp\/labs\/120201_easeljs_forcemap\/index.html\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-4321\" alt=\"\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_arrows.png\" width=\"460\" height=\"200\" \/><\/a><\/p>\n<p>HTML5\u306eCanvas\u3092Flash\u30e9\u30a4\u30af\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308bJavaScript\u30e9\u30a4\u30d6\u30e9\u30ea\u300c<a href=\"http:\/\/easeljs.com\/\" target=\"_blank\">EaselJS<\/a>\u300d\u3067\u6d41\u4f53\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30c7\u30e2\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li><a href=\"http:\/\/clockmaker.jp\/labs\/120201_easeljs_forcemap\/index.html\" target=\"_blank\">demo<\/a><\/li>\n<li><a href=\"http:\/\/jsdo.it\/clockmaker\/arrows\" target=\"_blank\">source<\/a><\/li>\n<\/ul>\n<p>EaselJS\u3092\u4f7f\u3048\u3070Flash\u306e\u3088\u3046\u306bHTML5 Canvas\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001ActionScript\u304b\u3089\u6982\u5ff5\u3060\u3051\u3067\u306f\u306a\u304f\u30b3\u30fc\u30c9\u306e\u518d\u5229\u7528\u6027\u304c\u9ad8\u307e\u308a\u307e\u3059\u3002\u4eca\u56de\u306f\u6d41\u4f53\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u8868\u73fe\u3092\u901a\u3057\u3066\u3001EaselJS\u3068Canvas\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d39\u4ecb\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><!--more--><\/p>\n<h3>\u30c7\u30e2\u306e\u4f5c\u308a\u65b9<\/h3>\n<p>\u5192\u982d\u306e\u30c7\u30e2\u3067\u3059\u304c\u3001\u79c1\u304c\u4ee5\u524d\u4f5c\u6210\u3057\u305fFlash\u306e\u4f5c\u54c1\u300c<a title=\"[Flash\u306e\u9ad8\u901f\u5316\u3092\u8a66\u3059]BitmapData\u3092\u914d\u5217\u306b\u683c\u7d0d\u3059\u308b\u3053\u3068\u30672\u301c3\u500d\u306e\u9ad8\u901f\u5316 | ClockMaker Blog\" href=\"..\/2009\/04\/bitmapdata\/\">Flash\u306e\u9ad8\u901f\u5316\u3092\u8a66\u3059\u3001BitmapData\u3092\u914d\u5217\u306b\u683c\u7d0d\u3059\u308b\u3053\u3068\u30672\u301c3\u500d\u306e\u9ad8\u901f\u5316<\/a>\u300d\u304b\u3089\u79fb\u690d\u3057\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<p>\u3055\u3066\u3001\u3053\u306e\u30c7\u30e2\u3092HTML5 Canvas\u306b\u5c55\u958b\u3059\u308b\u306b\u3042\u305f\u308a\u3001\u7279\u306b\u6291\u3048\u3066\u304a\u304d\u305f\u3044\u306e\u306f\u6b21\u306e\u70b9\u3060\u3068\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<ul>\n<li>\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u4f5c\u6210<\/li>\n<li>\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u60c5\u5831\u3092\u4ed8\u4e0e\u3057\u305f\u8868\u793a\u30af\u30e9\u30b9\u306e\u4f5c\u6210<\/li>\n<li>\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u9069\u7528\u3068\u8a08\u7b97<\/li>\n<\/ul>\n<h3>\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u4f5c\u6210<\/h3>\n<p>\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u3068\u3044\u3046\u306e\u306f\u6d41\u4f53\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u3092\u5b9f\u88c5\u3059\u308b\u969b\u306b\u3088\u304f\u4f7f\u308f\u308c\u308b\u624b\u6cd5\u3067\u3001\u96f2\u6a21\u69d8\u306e\u753b\u50cf\u304b\u3089\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u79fb\u52d5\u65b9\u6cd5\u3092\u6c7a\u5b9a\u3059\u308b\u306e\u306b\u4f7f\u3046\u3082\u306e\u3067\u3059\u3002\u4eca\u56de\u306f\u6b21\u306e\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"http:\/\/clockmaker.jp\/labs\/120201_easeljs_forcemap\/forcemap.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"http:\/\/clockmaker.jp\/labs\/120201_easeljs_forcemap\/forcemap.png\" width=\"576\" height=\"324\" \/><\/a><\/p>\n<p>\u25b2\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3002\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306fPhotoshop\u306e\u30d5\u30a3\u30eb\u30bf\u30fc\u306e\u96f2\u6a21\u69d8\u3092\u4f7f\u3063\u3066\u4f5c\u6210\u53ef\u80fd\u3002<\/p>\n<p>\u753b\u50cf\u306b\u306f\u8d64\u30fb\u7dd1\u30fb\u9752\u306e3\u30c1\u30e3\u30f3\u30cd\u30eb\u306e\u60c5\u5831\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u30023\u3064\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306f\u305d\u308c\u305e\u308c\u5fae\u5999\u306b\u96f2\u6a21\u69d8\u306e\u5f62\u72b6\u304c\u9055\u3046\u3053\u3068\u306b\u6ce8\u76ee\u304f\u3060\u3055\u3044\u3002\u3053\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u3092\u901f\u5ea6\u306b\u5909\u63db\u3059\u308b\u306e\u3067\u3059\u304c\u3001X\u65b9\u5411\u306f\u8d64\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u3001Y\u5ea7\u6a19\u306b\u306f\u7dd1\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u3092\u3001\u3068\u3044\u3046\u611f\u3058\u3067\u4f7f\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u3067\u6a21\u69d8\u304c\u9055\u3046\u306e\u3067\u3001X\u65b9\u5411\u3068Y\u5ea7\u6a19\u3067\u30d0\u30e9\u30d0\u30e9\u306e\u52d5\u304d\u3092\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p><a href=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_red.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_red-460x258.png\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u8d64\u306e\u30c1\u30e3\u30f3\u30cd\u30eb<\/p>\n<p><a href=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_green.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_green-460x258.png\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u7dd1\u306e\u30c1\u30e3\u30f3\u30cd\u30eb<\/p>\n<p><a href=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_blue.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_blue-460x258.png\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u9752\u306e\u30c1\u30e3\u30f3\u30cd\u30eb<\/p>\n<p>\u30ab\u30e9\u30fc\u60c5\u5831\u3092\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u901f\u5ea6\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u306f\u5f8c\u307b\u3069\u89e3\u8aac\u3057\u307e\u3059\u306e\u3067\u3001\u307e\u305a\u306f\u3053\u306e\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u3092JavaScript\u306b\u5c55\u958b\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>JavaScirpt\u306eImage\u30af\u30e9\u30b9(img\u30bf\u30b0\u306eJavaScript\u7528\u30af\u30e9\u30b9)\u3092\u4f7f\u3063\u3066\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">forceMapImage = new Image();\r\nforceMapImage.onload = initForceMap;\r\nforceMapImage.src = &quot;http:\/\/clockmaker.jp\/labs\/120201_easeljs_forcemap\/forcemap.png&quot;;\r\n\r\nfunction initForceMap() {\r\n \/\/ \u8aad\u307f\u8fbc\u307f\u5b8c\u4e86\r\n}\r\n<\/pre>\n<p>onload\u30a4\u30d9\u30f3\u30c8\u4f7f\u3063\u3066\u3001\u753b\u50cf\u8aad\u307f\u8fbc\u307f\u7d42\u4e86\u6642\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u4f7f\u3044\u307e\u3059\u3002\u6b21\u306b\u3053\u306e\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u753b\u50cf\u304b\u3089\u3001\u8272\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u3001Canvas\u8981\u7d20\u306b\u8ee2\u5199\u3057\u307e\u3059\u3002ActionScript\u3067\u306fBitmapData\u30af\u30e9\u30b9\u3092\u4f7f\u3063\u3066\u753b\u50cf\u306e\u8272\u60c5\u5831\u3092\u89e3\u6790\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002JavaScript\u3067\u306fCanvas\u8981\u7d20\u306b\u305d\u308c\u306b\u76f8\u5f53\u3059\u308b\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002\u524d\u56de\u3082\u7d39\u4ecb\u3057\u305f\u3068\u304a\u308a\u3001Canvas\u8981\u7d20\u306fbody\u30bf\u30b0\u306b\u8ffd\u52a0 (appendChild)\u3057\u306a\u304f\u3066\u3082\u6a5f\u80fd\u3059\u308b\u306e\u3067\u3001\u30b9\u30af\u30ea\u30d7\u30c8\u4e0a\u3067\u30c0\u30df\u30fc\u306eCanvas\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\uff08\u4e0b\u8a18\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306eforceMapCanvas\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u8a72\u5f53\uff09\u3092\u4f5c\u6210\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nfunction initForceMap() {\r\n    var forceMapElement = document.createElement(&quot;canvas&quot;);\r\n    forceMapElement.setAttribute(&quot;width&quot;, forceMapImage.width);\r\n    forceMapElement.setAttribute(&quot;height&quot;, forceMapImage.height);\r\n\r\n    forceMapCanvas = forceMapElement.getContext(&quot;2d&quot;);\r\n    forceMapCanvas.drawImage(forceMapImage, 0, 0);\r\n}\r\n<\/pre>\n<p>\u306a\u304a\u4f59\u8ac7\u3067\u3059\u304c\u3001\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306fActionScript\u3060\u3068BitmapData\u30af\u30e9\u30b9\u306eperlinNoise()\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30b9\u30af\u30ea\u30d7\u30c8\u5185\u3067\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002Canvas\u3067\u3082\u9811\u5f35\u308c\u3070\u30b3\u30fc\u30c9\u306b\u3088\u3063\u3066perlinNoise()\u3092\u81ea\u524d\u3067\u4f5c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u304c\u3001API\u306e\u8c4a\u5bcc\u3055\u3067\u3082ActionScript\u306e\u307b\u3046\u304c\u4e00\u65e5\u306e\u9577\u304c\u3042\u308b\u3068\u601d\u3044\u307e\u3057\u305f\u3002<\/p>\n<h3>\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u60c5\u5831\u3092\u4ed8\u4e0e\u3057\u305f\u8868\u793a\u30af\u30e9\u30b9\u306e\u4f5c\u6210<\/h3>\n<p>\u6b21\u306b\u77e2\u5370\u306e\u30b0\u30e9\u30d5\u30a3\u30c3\u30af\u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u8868\u793a\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002EaselJS\u306b\u306fBitmap\u30af\u30e9\u30b9\u304c\u3042\u308a\u3001\u305d\u308c\u3092\u4f7f\u3048\u3070\u753b\u50cf\u306eXY\u5ea7\u6a19\u3084\u56de\u8ee2\u3092\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4eca\u56de\u306e\u30c7\u30e2\u306e\u5834\u5408\u306f\u3001\u305d\u308c\u3089\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u306b\u52a0\u3048\u3066\u52a0\u901f\u5ea6\u3084\u901f\u5ea6\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u3092\u6271\u3044\u305f\u3044\u306e\u3067Bitmap\u30af\u30e9\u30b9\u3092\u7d99\u627f\u3057\u305fArrow\u30af\u30e9\u30b9\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>JavaScript\u306e\u30af\u30e9\u30b9\u306e\u4f5c\u6210\u65b9\u6cd5\u306f\u4eca\u56de\u306f\u5272\u611b\u3057\u307e\u3059\u304c\uff08\u5f8c\u65e5\u3001\u5225\u306e\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u307e\u3059\uff09\u3001\u6b21\u306e\u3088\u3046\u306a\u30b9\u30af\u30ea\u30d7\u30c8\u3068\u3057\u3066\u8a18\u8ff0\u3057\u307e\u3059\u3002\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3067\u8a18\u8ff0\u3057\u3066\u3044\u308bvx\u3068vy\u306f\u901f\u5ea6\u7528\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u3001ax\u3068ay\u306f\u52a0\u901f\u5ea6\u7528\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u3067\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n(function (window) {\r\n    function Arrow(imageOrUri, x, y) {\r\n        this.x = x;\r\n        this.y = y;\r\n        this.vx = 0;\r\n        this.vy = 0;\r\n        this.ax = 0;\r\n        this.ay = 0;\r\n        this.initialize(imageOrUri);\r\n        this.regX = 10;\r\n        this.regY = 10;\r\n    }\r\n\r\n    \/\/ EaselJS\u306eBitmap\u30af\u30e9\u30b9\u3092\u7d99\u627f\r\n    var p = Arrow.prototype = new Bitmap();\r\n\r\n    p.step = function (colorA, colorB) {\r\n        \/\/ \u7701\u7565\r\n    };\r\n    window.Arrow = Arrow;\r\n}(window));\r\n<\/pre>\n<p>regX\u3068regY\u306f\u753b\u50cf\u306e\u57fa\u6e96\u70b9\u3092\u8a2d\u5b9a\u3059\u308bBitmap\u30af\u30e9\u30b9\u306e\u30d7\u30ed\u30d1\u30c6\u30a3\u30fc\u3067\u3059\u3002\u4eca\u56de\u5229\u7528\u3059\u308b\u753b\u50cf\u304c20px\u56db\u65b9\u306e\u77e2\u5370\u753b\u50cf\u3067\u56de\u8ee2\u6642\u306e\u57fa\u6e96\u70b9\u3092(X, Y) = (10px, 10px)\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-4326\" alt=\"\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_size.png\" width=\"400\" height=\"400\" \/><\/p>\n<h3>\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u306e\u9069\u7528\u3068\u8a08\u7b97<\/h3>\n<p>\u6b21\u306b\u30d5\u30a9\u30fc\u30b9\u30de\u30c3\u30d7\u304b\u3089\u901f\u5ea6\u306b\u5909\u63db\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002Canvas\u8981\u7d20(Context2D\u30aa\u30d6\u30b8\u30a7\u30af\u30c8)\u306egetImageData()\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001\u6307\u5b9a\u3057\u305f\u30d4\u30af\u30bb\u30eb\u4f4d\u7f6e\u304b\u3089\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4eca\u56de\u306f\u6307\u5b9a\u3057\u305f\u30d4\u30af\u30bb\u30eb\u306e\u30c7\u30fc\u30bf\u3060\u3051\u304c\u6b32\u3057\u3044\u306e\u3067\u30011px\u56db\u65b9\u3067\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar arrow = particleList[i];\r\nvar imageData = forceMapCanvas.getImageData(\r\n    arrow.x &gt;&gt; 1,\r\n    arrow.y &gt;&gt; 1,\r\n    1,\r\n    1);\r\n<\/pre>\n<p><a href=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_rgb_1.jpg\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_rgb_1-460x258.jpg\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u4f8b\u3048\u3070\u3001(200px, 150px)\u306e\u7b87\u6240\u306e\u5ea7\u6a19\u306e1px\u56db\u65b9\u3067\u6e2c\u5b9a\u3059\u308b\u3068[200, 128, 102, 255]\u3068\u3044\u3046\u30ab\u30e9\u30fc\u60c5\u5831\u306e\u914d\u5217\u304c\u53d6\u5f97\u3067\u304d\u308b\u3002<\/p>\n<p>\u53d6\u5f97\u3057\u305fImageData\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u306f\uff11\u6b21\u5143\u914d\u5217\u3068\u3057\u3066\u3001\u8d64\u30fb\u7dd1\u30fb\u9752\u30fb\u900f\u660e\u5ea6\u306e\u9806\u756a\u3067\u30d4\u30af\u30bb\u30eb\u5206\u7e70\u308a\u8fd4\u3057\u3066\u30ab\u30e9\u30fc\u60c5\u5831(0\u301c255\u306e\u6570\u5024)\u304c\u5165\u3063\u3066\u3044\u307e\u3059\u3002\u4eca\u56de\u306f1px\u3054\u3068\u306e\u8d64\u30fb\u7dd1\u30fb\u9752\u306e\u60c5\u5831\u3060\u3051\u3092\u4f7f\u3046\u306e\u3067\u3059\u304c\u3001\u8d64\u3068\u7dd1\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u3060\u3051\u60c5\u5831\u3092\u4f7f\u3046\u5834\u5408\u306f\u6b21\u306e\u3088\u3046\u306b0\u30681\u3092\u6307\u5b9a\u3057\u3066\u3001Arrow\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u30e1\u30bd\u30c3\u30c9\u3092\u547c\u3073\u51fa\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">var colorR = imageData.data[0];\r\nvar colorG = imageData.data[1];\r\narrow.step(colorR, colorG);<\/pre>\n<p>Arrow\u30af\u30e9\u30b9\u306estep()\u30e1\u30bd\u30c3\u30c9\u3067\u306f\u3001\u3053\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u2192\u52a0\u901f\u5ea6\u2192\u901f\u5ea6\u2192\u5ea7\u6a19\/\u56de\u8ee2\u3078\u3068\u5909\u63db\u3057\u307e\u3059\u3002\u30ab\u30e9\u30fc\u60c5\u5831\u306f1\u30c1\u30e3\u30f3\u30cd\u30eb\u3042\u305f\u308a0\u301c255\u306e\u6570\u5024\u306b\u306a\u308b\u306e\u3067\u3001128\u3092\u6e1b\u7b97\u3057\u3066-128\u301c128\u307e\u3067\u306e\u6570\u5024\u3092\u6271\u3046\u3088\u3046\u306b\u3057\u307e\u3059\u3002X\u65b9\u5411\u306b\u5bfe\u3057\u3066\u9069\u7528\u3059\u308b\u5834\u5408\u306f\u3001\u8ca0\u306e\u5024\u3067\u3042\u308c\u3070\u5de6\u65b9\u5411\u306b\u79fb\u52d5\u3057\u3001\u6b63\u306e\u5024\u3067\u3042\u308c\u3070\u53f3\u65b9\u5411\u306b\u79fb\u52d5\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\np.step = function (colorA, colorB) {\r\n    this.ax += ( colorA - 128 ) * .0005;\r\n    this.ay += ( colorB - 128 ) * .0005;\r\n    this.vx += this.ax;\r\n    this.vy += this.ay;\r\n    this.x += this.vx;\r\n    this.y += this.vy;\r\n\r\n    this.rotation = Math.atan2(this.vy, this.vx) * 180 \/ Math.PI;\r\n\r\n    this.ax *= .96;\r\n    this.ay *= .96;\r\n    this.vx *= .92;\r\n    this.vy *= .92;\r\n\r\n    ( this.x &gt; 465 ) ? this.x = 0 : ( this.x &lt; 0 ) ? this.x = 465 : 0;\r\n    ( this.y &gt; 465 ) ? this.y = 0 : ( this.y &lt; 0 ) ? this.y = 465 : 0;\r\n};\r\n<\/pre>\n<p><a href=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_red_1.png\"><img decoding=\"async\" loading=\"lazy\" alt=\"\" src=\"\/blog\/wp-content\/uploads\/2012\/02\/120206_red_1-460x258.png\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u4f8b\u3048\u3070\u3001(200px, 150px)\u306e\u7b87\u6240\u306e\u5ea7\u6a19\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u306e\u8d64\u8272\u6210\u5206\u3092\u8abf\u3079\u308b\u3068200\u3068\u3044\u3046\u5024\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u5024\u306f100\u5206\u7387\u3067\u793a\u3059\u306880%\u306a\u306e\u3067\u3001X\u65b9\u5411\u306b\u5411\u304b\u3063\u3066+30% (50+30=80%)\u306e\u52a0\u901f\u91cf\u3068\u306a\u308b\u3002<\/p>\n<p><a href=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_red_2.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4328\" alt=\"\" src=\"https:\/\/clockmaker.jp\/blog\/wp-content\/uploads\/2012\/02\/120206_red_2-460x258.png\" width=\"460\" height=\"258\" \/><\/a><\/p>\n<p>\u25b2\u4f8b\u3048\u3070\u3001(100px, 350px)\u306e\u7b87\u6240\u306e\u5ea7\u6a19\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u306e\u8d64\u8272\u6210\u5206\u3092\u8abf\u3079\u308b\u306825\u3068\u3044\u3046\u5024\u304c\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\u3053\u306e\u5024\u306f100\u5206\u7387\u3067\u793a\u3059\u306810%\u306a\u306e\u3067\u3001X\u65b9\u5411\u306b\u5411\u304b\u3063\u3066-40% (50-10=40%)\u306e\u52a0\u901f\u91cf\u3068\u306a\u308b\u3002<\/p>\n<p>\u30a8\u30f3\u30bf\u30fc\u30d5\u30ec\u30fc\u30e0\u30a4\u30d9\u30f3\u30c8\u306b\u76f8\u5f53\u3059\u308btick()\u95a2\u6570\u3067\u306f\u3001\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u500b\u6570\u5206\u3060\u3051for\u6587\u3092\u56de\u3057\u3066\u4e0a\u8a18\u306e\u51e6\u7406\u3092\u884c\u3044\u3001Canvas\u3092\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\u3057\u3066\u51e6\u7406\u306f\u7d42\u4e86\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<h3>\u6700\u5f8c\u306b<\/h3>\n<p>\u4eca\u56de\u306fEaselJS\u3068\u3044\u3046\u3088\u308a\u306f\u3001Canvas\u8981\u7d20\u306e\u30ab\u30e9\u30fc\u60c5\u5831\u306e\u6271\u3044\u306e\u65b9\u6cd5\u306e\u89e3\u8aac\u3067\u3057\u305f\u3002\u524d\u56de\u3082\u7d39\u4ecb\u3057\u305f\u3068\u304a\u308a\u3001Canvas\u8981\u7d20\u306fFlash\u3067\u3044\u3046\u3068\u3053\u308d\u306eBitmap\u3068BitmapData\u3068Graphics\u3092\u3054\u3061\u3083\u307e\u305c\u306b\u3057\u305f\u3088\u3046\u306aHTML5\u306e\u65b0\u8981\u7d20\u3067\u3059\u304c\u3001EaselJS\u3092\u306f\u3058\u3081\u3068\u3057\u305f\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3067\u306f\u79fb\u690d\u3067\u304d\u3066\u3044\u306a\u3044API\u3082\u591a\u3005\u3042\u308a\u307e\u3059\u3002\u305d\u306e\u305f\u3081EaselJS\u3092\u5b66\u7fd2\u3059\u308b\u306e\u306b\u52a0\u3048\u3066Canvas\u8981\u7d20\u306e\u5404\u6a5f\u80fd\u3092\u5b66\u7fd2\u3059\u308b\u3053\u3068\u3067\u8868\u73fe\u53ef\u80fd\u306a\u3053\u3068\u304c\u5897\u3048\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3061\u306a\u307f\u306bFlash\u3060\u3068\u540c\u3058\u3088\u3046\u306a\u5b9f\u88c5\u30671000\u500b\u306e\u8868\u793a\u304c\u53ef\u80fd\u3067\u3057\u305f\u304c\u3001Canvas(+EaselJS)\u3060\u3068200\u500b\u3050\u3089\u3044\u304c\u9650\u5ea6\u3067\u3057\u305f\u3002<\/p>\n<h3>\u95a2\u9023\u8a18\u4e8b<\/h3>\n<ul>\n<li><a title=\"HTML5\u3067\u30c6\u30ad\u30b9\u30c8\u306e\u30b7\u30e3\u30c3\u30d5\u30eb\u6f14\u51fa\u304c\u3067\u304d\u308bJS\u30e9\u30a4\u30d6\u30e9\u30ea\u300cShuffleText.js\u300d | ClockMaker Blog\" href=\"https:\/\/clockmaker.jp\/blog\/2012\/02\/html5_shuffletext\/\">HTML5\u3067\u30c6\u30ad\u30b9\u30c8\u306e\u30b7\u30e3\u30c3\u30d5\u30eb\u6f14\u51fa\u304c\u3067\u304d\u308bJS\u30e9\u30a4\u30d6\u30e9\u30ea\u300cShuffleText.js\u300d<\/a><\/li>\n<li><a title=\"HTML5 Canvas\u3092\u59cb\u3081\u3088\u3046\uff1aEaselJS\u3068TweenJS\u3067\u30c6\u30ad\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8 | ClockMaker Blog\" href=\"..\/2012\/02\/html5-canvas-text-effect\/\">HTML5 Canvas\u3092\u59cb\u3081\u3088\u3046\uff1aEaselJS\u3068TweenJS\u3067\u30c6\u30ad\u30b9\u30c8\u30a8\u30d5\u30a7\u30af\u30c8<\/a><\/li>\n<li><a title=\"Canvas\u30bf\u30b0\u3068JavaScript\u30673D\u306e\u30c7\u30e2\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f | ClockMaker Blog\" href=\"..\/2010\/10\/canvas_js_demo\/\">Canvas\u30bf\u30b0\u3068JavaScript\u30673D\u306e\u30c7\u30e2\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f<\/a><\/li>\n<li><a title=\"Yahoo! Creative Award\u3067HTML5 \u8cde\u3092\u9802\u304d\u307e\u3057\u305f | ClockMaker Blog\" href=\"https:\/\/clockmaker.jp\/blog\/2011\/11\/yahoo-creative-award-2011-html5\/\">Yahoo! Creative Award 2011\u3067HTML5 \u8cde\u3092\u9802\u304d\u307e\u3057\u305f<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>HTML5\u306eCanvas\u3092Flash\u30e9\u30a4\u30af\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308bJavaScript\u30e9\u30a4\u30d6\u30e9\u30ea\u300cEaselJS\u300d\u3067\u6d41\u4f53\u30d1\u30fc\u30c6\u30a3\u30af\u30eb\u306e\u30c7\u30e2\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002 demo source EaselJS\u3092\u4f7f\u3048\u3070Flash\u306e\u3088\u3046\u306bHT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts\/4320"}],"collection":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/comments?post=4320"}],"version-history":[{"count":2,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts\/4320\/revisions"}],"predecessor-version":[{"id":5070,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/posts\/4320\/revisions\/5070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/media\/5058"}],"wp:attachment":[{"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/media?parent=4320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/categories?post=4320"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/clockmaker.jp\/blog\/wp-json\/wp\/v2\/tags?post=4320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}