{"id":2613,"date":"2017-01-30T15:06:15","date_gmt":"2017-01-30T06:06:15","guid":{"rendered":"http:\/\/www.otwo.jp\/blog\/?p=2613"},"modified":"2019-06-19T16:55:55","modified_gmt":"2019-06-19T07:55:55","slug":"canvas_sakura","status":"publish","type":"post","link":"https:\/\/www.otwo.jp\/blog\/canvas_sakura\/","title":{"rendered":"Canvas\u3067\u685c\u3092\u964d\u3089\u305b\u3066\u307f\u307e\u3057\u305f"},"content":{"rendered":"<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2017\/01\/canvas_sakura_mb.jpg\" alt=\"canvas_sakura_mb\" width=\"700\" height=\"400\" class=\"alignnone size-full wp-image-2619\" srcset=\"https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2017\/01\/canvas_sakura_mb.jpg 700w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2017\/01\/canvas_sakura_mb-150x86.jpg 150w, https:\/\/www.otwo.jp\/blog\/wp-content\/uploads\/2017\/01\/canvas_sakura_mb-300x171.jpg 300w\" sizes=\"(max-width: 700px) 100vw, 700px\" \/><\/p>\n<p>\u306f\u3058\u3081\u307e\u3057\u3066\u3001WEB\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u4f50\u91ce\u3068\u7533\u3057\u307e\u3059\u3002<\/p>\n<p>\u5c11\u3057\u524d\u3067\u3059\u304c\u3001NTT\u30bd\u30eb\u30de\u30fc\u30ec\u682a\u5f0f\u4f1a\u793e\u69d8\u306e\u6d77\u5916\u5411\u3051\u30b2\u30fc\u30e0\u30a2\u30d7\u30ea\u300cMoe! Ninja Girls\u300d\u306e\u516c\u5f0f\u30b5\u30a4\u30c8\u5236\u4f5c\u3092\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\uff01<\/p>\n<div class=\"externalLink\" style=\"margin:0;\"><a href=\"http:\/\/ninjagirls.moe\/\" target=\"_blank\" rel=\"noopener noreferrer\">\u300cMoe! Ninja Girls\u300d<\/a><\/div>\n<p style=\"color:#999;line-height:150%;margin:10px 0 50px;font-size:80%;\">\n\u203b\u30b5\u30fc\u30d0\u30fc\u304c\u6d77\u5916\u306b\u3042\u308b\u305f\u3081\u3001\u8aad\u307f\u8fbc\u307f\u306b\u6642\u9593\u304c\u304b\u304b\u308a\u307e\u3059\u3002<br \/>\n\u203b\u65e5\u672c\u3067\u306e\u914d\u4fe1\u306f\u3057\u3066\u304a\u308a\u307e\u305b\u3093\u3002\n<\/p>\n<p>\u305d\u306e\u4e2d\u3067\u3001HTML5\u306eCanvas\u3092\u4f7f\u3063\u3066\u685c\u3092\u964d\u3089\u305b\u308b\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u306e\u3067\u3001<br \/>\n\u5b8c\u6210\u307e\u3067\u306e\u624b\u9806\u3092STEP\u306b\u5206\u3051\u3066\u5171\u6709\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u3061\u3089\u304c\u4eca\u56de\u4f5c\u6210\u3057\u305f\u30b5\u30f3\u30d7\u30eb\u306e\u5b8c\u6210\u5f62\u3067\u3059\u3002<\/p>\n<div class=\"pageContents\">\n<span style=\"font-weight:bold;\">\u30102017\/02\/13\u8ffd\u8a18\u3011<\/span><br \/>\n<span style=\"color:#f00;\"><br \/>\n\u30d6\u30ed\u30b0\u306e\u6700\u5f8c\u306b\u3001\u4eca\u56de\u306e\u30b5\u30f3\u30d7\u30eb\u4f7f\u3063\u3066WEB\u30c1\u30fc\u30e0\u3067\uff11\u3064\u4f5c\u54c1\u3092\u4f5c\u3063\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n\u30b5\u30f3\u30d7\u30eb\u3068\u9055\u3044\u3001\u304b\u306a\u308a\u8c6a\u83ef\u306a\u3082\u306e\u306b\u306a\u3063\u3066\u307e\u3059\u306e\u3067\u3001\u305c\u3072\u6700\u5f8c\u307e\u3067\u898b\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<\/span>\n<\/div>\n<p data-height=\"587\" data-theme-id=\"0\" data-slug-hash=\"egdMjW\" data-default-tab=\"result\" data-user=\"otwo\" data-embed-version=\"2\" data-pen-title=\"egdMjW\" class=\"codepen\">See the Pen <a href=\"http:\/\/codepen.io\/otwo\/pen\/egdMjW\/\">egdMjW<\/a> by otwo (<a href=\"http:\/\/codepen.io\/otwo\">@otwo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<div class=\"pageContents\">\n<p class=\"title\">\u3082\u304f\u3058<\/p>\n<ol>\n<li><a href=\"#step1\">Step1:\u753b\u50cf\u3092\u8868\u793a\u3057\u3066\u4e0a\u304b\u3089\u4e0b\u306b\u52d5\u304b\u3059<\/a><\/li>\n<li><a href=\"#step2\">Step2:\u753b\u50cf\u6bce\u306b\u5927\u304d\u3055\u3001\u52d5\u304f\u901f\u5ea6\u3092\u5909\u3048\u308b<\/a><\/li>\n<li><a href=\"#step3\">Step3:\u753b\u50cf\u306e\u89d2\u5ea6\u3092\u5909\u3048\u308b<\/a><\/li>\n<\/ol>\n<\/div>\n<h1 id=\"step1\">Step1:\u753b\u50cf\u3092\u8868\u793a\u3057\u3066\u4e0a\u304b\u3089\u4e0b\u306b\u52d5\u304b\u3059<\/h1>\n<p>\u307e\u305a\u306f\u753b\u50cf\u306e\u8868\u793a\u3068\u753b\u50cf\u3092\u4e0a\u304b\u3089\u4e0b\u306b\u52d5\u304b\u3059\u3068\u3053\u308d\u307e\u3067\u3084\u3063\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<p data-height=\"587\" data-theme-id=\"dark\" data-slug-hash=\"NdNwEp\" data-default-tab=\"result\" data-user=\"otwo\" data-embed-version=\"2\" data-pen-title=\"NdNwEp\" class=\"codepen\">See the Pen <a href=\"https:\/\/codepen.io\/otwo\/pen\/NdNwEp\/\">NdNwEp<\/a> by otwo (<a href=\"http:\/\/codepen.io\/otwo\">@otwo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><br \/>\n\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u306f\u3053\u3061\u3089\uff01<\/p>\n<pre class=\"brush: python\r; notranslate\">&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\n&lt;body&gt;\r\n<canvas id=\"cvs\" width=\"800px\" height=\"500px\" style=\"background-color:#000;\"><\/canvas>\r\n&lt;script&gt;\r\nvar canvas = document.getElementById(\"cvs\");\r\nvar ctx = canvas.getContext(\"2d\");\r\nvar imgCnt = 25;  \/\/ \u63cf\u753b\u3059\u308b\u753b\u50cf\u306e\u6570\r\nvar aryImg = [];  \/\/ \u753b\u50cf\u306e\u60c5\u5831\u3092\u683c\u7d0d\r\nvar cvsw = 800;   \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fwidth\r\nvar cvsh = 500;   \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fheight\r\nvar imgBaseSizeW = 15;    \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u6a2a\u5e45\r\nvar imgBaseSizeH = 18.5;  \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u7acb\u5e45\r\n\r\n\/\/ \u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\r\nvar img = new Image();\r\nimg.src = \".\/images\/sakura.png\";\r\nimg.onload = flow_start;\r\n\r\n\/\/ \u753b\u50cf\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u8a2d\u5b9a\r\nfunction setImagas(){\r\n  for(var i = 0;i < imgCnt;i++){\r\n    aryImg.push({\r\n      \"posx\": Math.random()*cvsw,     \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ex\r\n      \"posy\": Math.random()*cvsh,     \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ey\r\n      \"sizew\": imgBaseSizeW,          \/\/ \u753b\u50cf\u306e\u6a2a\u5e45\r\n      \"sizeh\": imgBaseSizeH,          \/\/ \u753b\u50cf\u306e\u7e26\u5e45\r\n    });\r\n  }\r\n}\r\n\r\n\/\/ \u63cf\u753b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u66f4\u65b0\r\nvar idx = 0;\r\nfunction flow(){\r\n  ctx.clearRect(0,0,cvsw,cvsh);\r\n  for(idx = 0;idx < imgCnt;idx++){\r\n    aryImg[idx].posy += 1;\r\n    ctx.drawImage(img, aryImg[idx].posx, aryImg[idx].posy, aryImg[idx].sizew , aryImg[idx].sizeh);\r\n    \/\/ \u7bc4\u56f2\u5916\u306b\u63cf\u753b\u3055\u308c\u305f\u753b\u50cf\u3092\u4e0a\u306b\u623b\u3059\r\n    if(aryImg[idx].posy >= cvsh){\r\n      aryImg[idx].posy = -aryImg[idx].sizeh;\r\n    }\r\n  }\r\n}\r\n\r\nfunction flow_start(){\r\n  setImagas();\r\n  setInterval(flow,10);\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u3059\u3054\u3044\u6a5f\u68b0\u7684\u306b\u685c\u304c\u6d41\u308c\u3066\u3044\u307e\u3059\u306d\u3002<br \/>\n\u3057\u304b\u3057Step1\u306f\u3053\u308c\u3067\u30af\u30ea\u30a2\u3067\u3059\uff01<\/p>\n<h2>\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e<\/h2>\n<p>\u6b21\u306b\u9032\u3080\u524d\u306bCanvas\u3067\u4f7f\u7528\u3057\u305f\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e\u3092\u3055\u305b\u3066\u3082\u3089\u3044\u307e\u3059\u3002<\/p>\n<h3>clearRect()\u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>clearRect\u306f\u6307\u5b9a\u3057\u305f\u7bc4\u56f2\u306e\u63cf\u753b\u9762\u306e\u5185\u5bb9\u3092\u30af\u30ea\u30a2\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u5f15\u6570\u306f<br \/>\nclearRect(\u57fa\u6e96x\u5ea7\u6a19 , \u57fa\u6e96y\u5ea7\u6a19 , \u6a2a\u5e45 , \u7acb\u5e45)<br \/>\n\u3092\u6e21\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Canvas\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3092\u8868\u73fe\u3059\u308b\u5834\u5408\u3001jQuery\u306a\u3069\u306eDOM\u64cd\u4f5c\u3068\u9055\u3044\u3001<br \/>\n\u63cf\u753b \u2192 \u30af\u30ea\u30a2 \u2192 \u63cf\u753b \u2192 \u30af\u30ea\u30a2 \u2192 \u63cf\u753b \u30fb\u30fb\u30fb<br \/>\n\u3092\u9023\u7d9a\u3067\u7e70\u308a\u8fd4\u3059\u3053\u3068\u3067\u30a2\u30cb\u30e1\u30fc\u30b7\u30e7\u30f3\u3057\u3066\u3044\u308b\u69d8\u306b\u898b\u305b\u3066\u3044\u307e\u3059\u3002<br \/>\n\u306a\u306e\u3067\u3001\u63cf\u753b\u3092\u59cb\u3081\u308b\u524d\u306b\u5fc5\u305a\u76f4\u524d\u306e\u63cf\u753b\u3092\u30af\u30ea\u30a2\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3001<br \/>\n\u8a18\u61b6\u306e\u7247\u9685\u306b\u3067\u3082\u899a\u3048\u3066\u304a\u304f\u3068\u826f\u3044\u304b\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n<h3>drawImage()\u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>drawImage\u306f\u753b\u50cf\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u63cf\u753b\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u3053\u3061\u3089\u306e\u30e1\u30bd\u30c3\u30c9\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u5f15\u6570\u306e\u30d1\u30bf\u30fc\u30f3\u304c\u3042\u308a\u307e\u3059\u304c\u4eca\u56de\u306f<br \/>\ndrawImage(\u753b\u50cf\u30aa\u30d6\u30b8\u30a7\u30af\u30c8 , \u8868\u793ax\u5ea7\u6a19 , \u8868\u793ay\u5ea7\u6a19)<br \/>\n\u306e\u5f62\u5f0f\u3067\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n<\/p>\n<h1 id=\"step2\">Step2:\u753b\u50cf\u6bce\u306b\u30b5\u30a4\u30ba\u3001\u52d5\u304f\u901f\u5ea6\u3092\u5909\u3048\u308b<\/h1>\n<p>\u6b21\u306b\u81ea\u7136\u306a\u611f\u3058\u3092\u51fa\u3059\u305f\u3081\u306b\u3001\u753b\u50cf\uff11\u3064\uff11\u3064\u306b\u9055\u3046\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u8a2d\u5b9a\u3057\u3066\u307f\u307e\u3057\u305f\uff01<br \/>\n\u4eca\u56de\u306f\u4ee5\u4e0b\u306e\uff12\u3064\u3092\u5909\u3048\u3066\u307f\u307e\u3059\u3002<br \/>\n\u30fb\u753b\u50cf\u306e\u30b5\u30a4\u30ba<br \/>\n\u30fb\u52d5\u304f\u901f\u5ea6<\/p>\n<p data-height=\"587\" data-theme-id=\"0\" data-slug-hash=\"Grjxyz\" data-default-tab=\"result\" data-user=\"otwo\" data-embed-version=\"2\" data-pen-title=\"Grjxyz\" class=\"codepen\">See the Pen <a href=\"http:\/\/codepen.io\/otwo\/pen\/Grjxyz\/\">Grjxyz<\/a> by otwo (<a href=\"http:\/\/codepen.io\/otwo\">@otwo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n<pre class=\"brush: python\r; notranslate\">&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\n&lt;body&gt;\r\n<canvas id=\"cvs\" width=\"800px\" height=\"500px\" style=\"background-color:#000;\"><\/canvas>\r\n&lt;script&gt;\r\nvar canvas = document.getElementById(\"cvs\");\r\nvar ctx = canvas.getContext(\"2d\");\r\nvar imgCnt = 25;          \/\/ \u63cf\u753b\u3059\u308b\u753b\u50cf\u306e\u6570\r\nvar aryImg = [];          \/\/ \u753b\u50cf\u306e\u60c5\u5831\u3092\u683c\u7d0d\r\nvar cvsw = 800;           \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fwidth\r\nvar cvsh = 500;           \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fheight\r\nvar imgBaseSizeW = 15;    \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u6a2a\u5e45\r\nvar imgBaseSizeH = 18.5;  \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u7acb\u5e45\r\nvar aspectMax = 1.5;      \/\/ \u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u8a08\u7b97\u6642\u306e\u6700\u5927\u5024\r\nvar aspectMin = 0.5;      \/\/ \u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u8a08\u7b97\u6642\u306e\u6700\u5c0f\u5024\r\nvar speedMax = 2;         \/\/ \u843d\u4e0b\u901f\u5ea6\u306e\u6700\u5927\u5024\r\nvar speedMin = 0.5;       \/\/ \u843d\u4e0b\u901f\u5ea6\u306e\u6700\u5c0f\u5024\r\n\r\n\/\/ \u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\r\nvar img = new Image();\r\nimg.src = \".\/images\/sakura.png\";\r\nimg.onload = flow_start;\r\n\r\n\/\/ \u753b\u50cf\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u8a2d\u5b9a\r\nfunction setImagas(){\r\n  var aspect = 0;\r\n  for(var i = 0;i < imgCnt;i++){\r\n    \/\/ \u753b\u50cf\u30b5\u30a4\u30ba\u306b\u639b\u3051\u308b\u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u30920.5~1.5\u500d\u3067\u30e9\u30f3\u30c0\u30e0\u3067\u751f\u6210\r\n    aspect = Math.random()*(aspectMax-aspectMin)+aspectMin;\r\n    aryImg.push({\r\n      \"posx\": Math.random()*cvsw,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ex\r\n      \"posy\": Math.random()*cvsh,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ey\r\n      \"sizew\": imgBaseSizeW*aspect, \/\/ \u753b\u50cf\u306e\u6a2a\u5e45\r\n      \"sizeh\": imgBaseSizeH*aspect, \/\/ \u753b\u50cf\u306e\u7e26\u5e45\r\n      \"speedy\": Math.random()*(speedMax-speedMin)+speedMin,\u3000\/\/ \u753b\u50cf\u304c\u843d\u3061\u3066\u3044\u304f\u901f\u5ea6\r\n    });\r\n  }\r\n}\r\n\r\n\/\/ \u63cf\u753b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u66f4\u65b0\r\nvar idx = 0;\r\nfunction flow(){\r\n  ctx.clearRect(0,0,cvsw,cvsh);\r\n  for(idx = 0;idx < imgCnt;idx++){\r\n    aryImg[idx].posy += aryImg[idx].speedy;\r\n    ctx.drawImage(img, aryImg[idx].posx, aryImg[idx].posy, aryImg[idx].sizew , aryImg[idx].sizeh);\r\n    \/\/ \u7bc4\u56f2\u5916\u306b\u63cf\u753b\u3055\u308c\u305f\u753b\u50cf\u3092\u4e0a\u306b\u623b\u3059\r\n    if(aryImg[idx].posy >= cvsh){\r\n      aryImg[idx].posy = -aryImg[idx].sizeh;\r\n    }\r\n  }\r\n}\r\n\r\nfunction flow_start(){\r\n  setImagas();\r\n  setInterval(flow,10);\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Step1\u304b\u3089\u3042\u307e\u308a\u624b\u3092\u5165\u308c\u3066\u3044\u307e\u305b\u3093\u304c\u3001\u500b\u3005\u306b\u30d0\u30e9\u3064\u304d\u3092\u3064\u3051\u308b\u3053\u3068\u3067\u5370\u8c61\u304c\u3060\u3044\u3076\u5909\u308f\u3063\u3066\u898b\u3048\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u56de\u306f\u685c\u3067\u3059\u304c\u3001\u96ea\u306a\u3069\u5c0f\u3055\u3044\u3082\u306e\u3092\u964d\u3089\u305b\u308b\u5834\u5408\u306b\u306f\u3001\u3053\u308c\u3060\u3051\u3067\u3082\u305d\u308c\u3089\u3057\u304f\u898b\u3048\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u3002<\/p>\n<p>\u4eca\u56de\u306e\u4e3b\u306a\u5909\u66f4\u70b9\u306f\u3053\u3061\u3089\u306b\u306a\u308a\u307e\u3059\u3002(26\uff5e34\u884c)<\/p>\n<pre class=\"brush: python\r; notranslate\">\/\/ \u753b\u50cf\u30b5\u30a4\u30ba\u306b\u639b\u3051\u308b\u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u30920.5~1.5\u500d\u3067\u30e9\u30f3\u30c0\u30e0\u3067\u751f\u6210\r\naspect = Math.random()*(aspectMax-aspectMin)+aspectMin;\r\naryImg.push({\r\n  \"posx\": Math.random()*cvsw,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ex\r\n  \"posy\": Math.random()*cvsh,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ey\r\n  \"sizew\": imgBaseSizeW*aspect, \/\/ \u753b\u50cf\u306e\u7e26\u5e45\r\n  \"sizeh\": imgBaseSizeH*aspect, \/\/ \u753b\u50cf\u306e\u6a2a\u5e45\r\n  \"speedy\": Math.random()*(speedMax-speedMin)+speedMin,\u3000\/\/ \u753b\u50cf\u304c\u843d\u3061\u3066\u3044\u304f\u901f\u5ea6\r\n});\r\n<\/pre>\n<p>\u7279\u306b\u8aac\u660e\u306f\u8981\u3089\u306a\u3044\u304b\u3068\u3082\u601d\u3044\u307e\u3059\u304c\u30fb\u30fb\u30fb\u3055\u3089\u3063\u3068\u3060\u3051\u3002<br \/>\n\u753b\u50cf\u30b5\u30a4\u30ba[sizew , sizeh]\u306b\u639b\u3051\u308b\u500d\u7387\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u751f\u6210\u3057\u3066\u4e57\u7b97\u3057\u3066\u3044\u308b\u4e8b\u3068\u3001<br \/>\nspeedy\u3092\u65b0\u3057\u304f\u8ffd\u52a0\u3057\u3066\u3001flow\u95a2\u6570\u5185\u3067posy\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3078\u306e\u52a0\u7b97\u306b\u4f7f\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001\u6700\u5f8c\u306b\u3082\u3046\uff11\u5de5\u592b\u3057\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\uff01<\/p>\n<h1 id=\"step3\">Step3:\u753b\u50cf\u306e\u89d2\u5ea6\u3092\u5909\u3048\u308b<\/h1>\n<p>\u3084\u306f\u308a\u82b1\u3073\u3089\u3092\u964d\u3089\u305b\u308b\u308f\u3051\u306a\u306e\u3067\u3001\u3072\u3089\u3072\u3089\u3055\u305b\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3088\u306d\uff01<br \/>\n\u3068\u8a00\u3046\u4e8b\u3067\u6700\u7d42\u30b9\u30c6\u30c3\u30d7\u306f\u753b\u50cf\u306e\u89d2\u5ea6\u3092\u5909\u3048\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p data-height=\"587\" data-theme-id=\"0\" data-slug-hash=\"egdMjW\" data-default-tab=\"result\" data-user=\"otwo\" data-embed-version=\"2\" data-pen-title=\"egdMjW\" class=\"codepen\">See the Pen <a href=\"http:\/\/codepen.io\/otwo\/pen\/egdMjW\/\">egdMjW<\/a> by otwo (<a href=\"http:\/\/codepen.io\/otwo\">@otwo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><br \/>\n\u6700\u7d42\u306e\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3067\u3059\uff01<\/p>\n<pre class=\"brush: python\r; notranslate\">&lt;!DOCTYPE HTML&gt;\r\n&lt;html&gt;\r\n&lt;body&gt;\r\n<canvas id=\"cvs\" width=\"800px\" height=\"500px\" style=\"background-color:#000;\"><\/canvas>\r\n&lt;script&gt;\r\nvar canvas = document.getElementById(\"cvs\");\r\nvar ctx = canvas.getContext(\"2d\");\r\nvar imgCnt = 25;          \/\/ \u63cf\u753b\u3059\u308b\u753b\u50cf\u306e\u6570\r\nvar aryImg = [];          \/\/ \u753b\u50cf\u306e\u60c5\u5831\u3092\u683c\u7d0d\r\nvar cvsw = 800;           \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fwidth\r\nvar cvsh = 500;           \/\/ canvas\u30bf\u30b0\u306b\u6307\u5b9a\u3057\u305fheight\r\nvar imgBaseSizeW = 15;    \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u6a2a\u5e45\r\nvar imgBaseSizeH = 18.5;  \/\/ \u753b\u50cf\u306e\u57fa\u672c\u30b5\u30a4\u30ba\u7acb\u5e45\r\nvar aspectMax = 1.5;      \/\/ \u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u8a08\u7b97\u6642\u306e\u6700\u5927\u5024\r\nvar aspectMin = 0.5;      \/\/ \u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u8a08\u7b97\u6642\u306e\u6700\u5c0f\u5024\r\nvar speedMax = 2;         \/\/ \u843d\u4e0b\u901f\u5ea6\u306e\u6700\u5927\u5024\r\nvar speedMin = 0.5;       \/\/ \u843d\u4e0b\u901f\u5ea6\u306e\u6700\u5c0f\u5024\r\nvar angleAdd = 4;         \/\/ \u753b\u50cf\u89d2\u5ea6\u3078\u306e\u52a0\u7b97\u5024\r\n\r\n\/\/ \u753b\u50cf\u306e\u8aad\u307f\u8fbc\u307f\r\nvar img = new Image();\r\nimg.src = \".\/images\/sakura.png\";\r\nimg.onload = flow_start;\r\n\r\n\/\/ \u753b\u50cf\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u8a2d\u5b9a\r\nfunction setImagas(){\r\n  var aspect = 0;\r\n  for(var i = 0;i < imgCnt;i++){\r\n    \/\/ \u753b\u50cf\u30b5\u30a4\u30ba\u306b\u639b\u3051\u308b\u30a2\u30b9\u30da\u30af\u30c8\u6bd4\u30920.5~1.5\u500d\u3067\u30e9\u30f3\u30c0\u30e0\u3067\u751f\u6210\r\n    aspect = Math.random()*(aspectMax-aspectMin)+aspectMin;\r\n    aryImg.push({\r\n      \"posx\": Math.random()*cvsw,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ex\r\n      \"posy\": Math.random()*cvsh,   \/\/ \u521d\u671f\u8868\u793a\u4f4d\u7f6ey\r\n      \"sizew\": imgBaseSizeW*aspect, \/\/ \u753b\u50cf\u306e\u6a2a\u5e45\r\n      \"sizeh\": imgBaseSizeH*aspect, \/\/ \u753b\u50cf\u306e\u7e26\u5e45\r\n      \"speedy\": Math.random()*(speedMax-speedMin)+speedMin,\u3000\/\/ \u753b\u50cf\u304c\u843d\u3061\u3066\u3044\u304f\u901f\u5ea6\r\n      \"angle\": Math.random()*360,   \/\/ \u89d2\u5ea6\r\n    });\r\n  }\r\n}\r\n\r\n\/\/ \u63cf\u753b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u306e\u66f4\u65b0\r\nvar idx = 0;\r\nvar cos = 0;\r\nvar sin = 0;\r\nvar rad = Math.PI \/ 180;\r\nfunction flow(){\r\n  ctx.clearRect(0,0,cvsw,cvsh);\r\n  for(idx = 0;idx < imgCnt;idx++){\r\n    aryImg[idx].posy += aryImg[idx].speedy;\r\n    aryImg[idx].angle += Math.random()*angleAdd;\r\n    cos = Math.cos(aryImg[idx].angle * rad);\r\n    sin = Math.sin(aryImg[idx].angle * rad);\r\n    ctx.setTransform(cos, sin, sin, cos, aryImg[idx].posx, aryImg[idx].posy);\r\n    ctx.drawImage(img, 0, 0 , aryImg[idx].sizew , aryImg[idx].sizeh);\r\n    ctx.setTransform(1, 0, 0, 1, 0, 0);\r\n    \/\/ \u7bc4\u56f2\u5916\u306b\u63cf\u753b\u3055\u308c\u305f\u753b\u50cf\u3092\u4e0a\u306b\u623b\u3059\r\n    if(aryImg[idx].posy >= cvsh){\r\n      aryImg[idx].posy = -aryImg[idx].sizeh;\r\n    }\r\n  }\r\n}\r\n\r\nfunction flow_start(){\r\n  setImagas();\r\n  setInterval(flow,10);\r\n}\r\n&lt;\/script&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>\u3069\u3046\u3067\u3057\u3087\u3046\uff01\u4e00\u6c17\u306b\u305d\u308c\u3089\u3057\u3082\u306e\u304c\u3067\u304d\u305f\u3093\u3058\u3083\u306a\u3044\u3067\u3057\u3087\u3046\u304b\uff01\uff01<\/p>\n<h2>\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e<\/h2>\n<p>\u5909\u66f4\u70b9\u306e\u8aac\u660e\u524d\u306b\u3001\u65b0\u3057\u304f\u51fa\u3066\u304d\u305f\u30e1\u30bd\u30c3\u30c9\u306e\u8aac\u660e\u3067\u3059\u3002<\/p>\n<h3>setTransform()\u30e1\u30bd\u30c3\u30c9<\/h3>\n<p>setTransform\u306f\u63cf\u753b\u9762\u3092\u5909\u5f62\u3059\u308b\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002<br \/>\n\u3056\u3063\u304f\u308a\u3068\u3057\u305f\u30a4\u30e1\u30fc\u30b8\u306f<br \/>\n\u63cf\u753b\u9762\u306e\u4f38\u7e2e\u3001\u89d2\u5ea6\u3001\u5ea7\u6a19\u3092\u5909\u66f4\u3057\u3066\u3044\u308b\u30a4\u30e1\u30fc\u30b8\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u8a73\u3057\u304f\u306f\u4e0b\u8a18\u306e\u69d8\u306b\u7d30\u304b\u304f\u89e3\u8aac\u3055\u308c\u3066\u3044\u308b\u30b5\u30a4\u30c8\u304c\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u8208\u5473\u304c\u3042\u308b\u65b9\u306f\u691c\u7d22\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<div class=\"externalLink\"><a href=\"http:\/\/www.htmq.com\/canvas\/setTransform.shtml\" target=\"_blank\" rel=\"noopener noreferrer\">setTransform(a, b, c, d, e, f)\uff0dCanvas\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a><\/div>\n<h2>\u4e3b\u306a\u5909\u66f4\u70b9\u3068\u8aac\u660e<\/h2>\n<p>\u4eca\u56de\u306e\u4e3b\u306a\u5909\u66f4\u70b9\u306f\u63cf\u753b\u51e6\u7406\u5468\u8fba\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\nStep2\u307e\u3067\u306f\u753b\u50cf\u306e\u8868\u793a\u4f4d\u7f6e\u3092drawImage\u30e1\u30bd\u30c3\u30c9\u3067\u6307\u5b9a\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001<br \/>\n\u4ee5\u4e0b\u306e\u69d8\u306b\u3001setTransform\u30e1\u30bd\u30c3\u30c9\u3067\u306e\u6307\u5b9a\u306b\u5909\u66f4\u3092\u3057\u3066\u3044\u307e\u3059\u3002(52\uff5e56\u884c\u76ee)<\/p>\n<pre class=\"brush: python\r; notranslate\">cos = Math.cos(aryImg[idx].angle * rad);\r\nsin = Math.sin(aryImg[idx].angle * rad);\r\nctx.setTransform(cos, sin, sin, cos, aryImg[idx].posx, aryImg[idx].posy);\r\nctx.drawImage(img, 0, 0 , aryImg[idx].sizew , aryImg[idx].sizeh);\r\nctx.setTransform(1, 0, 0, 1, 0, 0);\r\n<\/pre>\n<p>\u7c21\u5358\u306b\u3067\u3059\u304c\u51e6\u7406\u306e\u6d41\u308c\u306f\u3001\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n1:cos\u3068sin\u306b\u306f\u50be\u659c\u7387\u3092\u5165\u308c\u3066\u3044\u307e\u3059\u3002<br \/>\n2:setTransform\u3067\u6307\u5b9a\u3057\u305f\u65b9\u306b\u63cf\u753b\u9762\u3092\u5909\u5f62\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n3:drawImage\u3067\u753b\u50cf\u3092\u63cf\u753b\u3057\u307e\u3059\u3002<br \/>\n4:\u6b21\u306e\u63cf\u753b\u306b\u5f71\u97ff\u304c\u51fa\u306a\u3044\u69d8\u306b\u3001\u63cf\u753b\u9762\u306e\u5909\u5f62\u3092\u30ea\u30bb\u30c3\u30c8\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h1>\u6700\u5f8c\u306b<\/h1>\n<p>\u4eca\u56de\u306f\u3042\u307e\u308a\u8907\u96d1\u306a\u51e6\u7406\u306f\u5165\u308c\u305a\u306b\u3001\u6975\u529b\u7c21\u6f54\u306b\u7d44\u3093\u3067\u307f\u307e\u3057\u305f\u3002<br \/>\n\u5404\u30d1\u30e9\u30e1\u30fc\u30bf\u30fc\u3092\u5909\u66f4\u3057\u305f\u308a\u52a0\u3048\u305f\u308a\u3057\u3066\u3001\u52d5\u304d\u306b\u3082\u3063\u3068\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u3092\u5897\u3084\u3059\u306a\u3069\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u3068\u3001\u3082\u3063\u3068\u3082\u3063\u3068\u305d\u308c\u3089\u3057\u304f\u306a\u308b\u304b\u3068\u601d\u3044\u307e\u3059\uff01<br \/>\n\u4eca\u56de\u306e\u69d8\u306a\u52d5\u304d\u306e\u53c2\u8003\u30b5\u30a4\u30c8\u306f\u305f\u304f\u3055\u3093\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u4e2d\u3067\u3053\u306e\u8a18\u4e8b\u304c\u4f55\u304b\u306e\u304a\u5f79\u306b\u7acb\u3066\u305f\u306a\u3089\u5e78\u3044\u306b\u601d\u3044\u307e\u3059\uff01<br \/>\n\u305d\u308c\u3067\u306f\u3001\u307e\u305f\u306e\u6a5f\u4f1a\u306b\uff01\uff01<\/p>\n<h1>\u8ffd\u8a18<\/h1>\n<p>WEB\u30c1\u30fc\u30e0\u3067\u300c\u591c\u306e\u82b1\u898b\u300d\u3092\u30c6\u30fc\u30de\u306b\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u305f\u306e\u3067\u8f09\u305b\u3066\u304a\u304d\u307e\u3059\uff01<br \/>\n\u753b\u50cf\u306f\u30c6\u30fc\u30de\u306b\u6cbf\u3063\u305f\u3082\u306e\u3092\u4f5c\u6210\u3057\u3066\u3082\u3089\u3044\u307e\u3057\u305f\u304c\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u4eca\u56de\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u30d9\u30fc\u30b9\u306b\u3001\u98a8\u306b\u5439\u304b\u308c\u3066\u3044\u308b\u69d8\u306a\u52d5\u304d\u7b49\u3092\u8ffd\u52a0\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u3084\u306f\u308a\u30c7\u30b6\u30a4\u30f3\u304c\u5165\u308b\u3068\u4e00\u6c17\u306b\u5370\u8c61\u304c\u5909\u308f\u308a\u307e\u3059\u306d\uff01<\/p>\n<p data-height=\"600\" data-theme-id=\"0\" data-slug-hash=\"WpPmxx\" data-default-tab=\"result\" data-user=\"otwo\" data-embed-version=\"2\" data-pen-title=\"WpPmxx\" class=\"codepen\">See the Pen <a href=\"http:\/\/codepen.io\/otwo\/pen\/WpPmxx\/\">WpPmxx<\/a> by otwo (<a href=\"http:\/\/codepen.io\/otwo\">@otwo<\/a>) on <a href=\"http:\/\/codepen.io\">CodePen<\/a>.<\/p>\n<p><script async src=\"https:\/\/production-assets.codepen.io\/assets\/embed\/ei.js\"><\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u307e\u3057\u3066\u3001WEB\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u306e\u4f50\u91ce\u3068\u7533\u3057\u307e\u3059\u3002 \u5c11\u3057\u524d\u3067\u3059\u304c\u3001NTT\u30bd\u30eb\u30de\u30fc\u30ec\u682a\u5f0f\u4f1a\u793e\u69d8\u306e\u6d77\u5916\u5411\u3051\u30b2\u30fc\u30e0\u30a2\u30d7\u30ea\u300cMoe! Ninja Girls\u300d\u306e\u516c\u5f0f\u30b5\u30a4\u30c8\u5236\u4f5c\u3092\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\uff01 \u300cMoe! Ninja Gi [&hellip;]<\/p>\n","protected":false},"author":25,"featured_media":2711,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[82,83,94],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/2613"}],"collection":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/comments?post=2613"}],"version-history":[{"count":44,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/2613\/revisions"}],"predecessor-version":[{"id":4787,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/posts\/2613\/revisions\/4787"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media\/2711"}],"wp:attachment":[{"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/media?parent=2613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/categories?post=2613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.otwo.jp\/blog\/wp-json\/wp\/v2\/tags?post=2613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}