{"id":341,"date":"2014-10-21T09:16:03","date_gmt":"2014-10-21T00:16:03","guid":{"rendered":"http:\/\/nantoka.filmm.info\/blog\/?p=341"},"modified":"2014-10-21T09:31:53","modified_gmt":"2014-10-21T00:31:53","slug":"html5%e5%85%a5%e9%96%80%e3%81%9d%e3%81%ae13-%e3%81%8a%e7%b5%b5%e3%81%8b%e3%81%8d%e3%83%84%e3%83%bc%e3%83%ab2","status":"publish","type":"post","link":"https:\/\/nantoka.filmm.info\/blog\/?p=341","title":{"rendered":"HTML5\u5165\u9580\u305d\u306e14-\u304a\u7d75\u304b\u304d\u30c4\u30fc\u30eb2"},"content":{"rendered":"<p>\u304a\u7d75\u304b\u304d\u30c4\u30fc\u30eb\uff08PC\u7248\uff09\u3067\u3059<\/p>\n<pre class=\"lang:xhtml decode:true \" title=\"peint\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;title&gt;touch paint&lt;\/title&gt;\r\n&lt;meta charset=\"UTF-8\"&gt;\r\n&lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no\"&gt;\r\n&lt;!-- meta\u30bf\u30b0\u3067\u3000\u30b9\u30de\u30db\u306e\u6319\u52d5\u3092\u5236\u9650\u3057\u3066\u3044\u308b --&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;h1&gt;Key2&lt;\/h1&gt;\r\n&lt;canvas id=\"myCanvas\" width=\"300\" height=\"300\" style=\"border:1px solid #000000;\"&gt;&lt;\/canvas&gt;\r\n\r\n&lt;script type=\"text\/javascript\"&gt;\r\nvar canvas;\r\nvar paintSwitch = false;\/\/pantSwitch\u3068\u3044\u3046\u30b9\u30a4\u30c3\u30c1\u3092\u4f5c\u3063\u3066\u3068\u308a\u3042\u3048\u305a\u6700\u521d\u306f\u30aa\u30d5\u306d\r\nvar oldX = 0;\/\/\u30af\u30ea\u30c3\u30af\u59cb\u3081\u305f\u4f4d\u7f6e\u306eX\u5ea7\u6a19\u3092\u5165\u308c\u308b\r\nvar oldY = 0;\/\/\u30af\u30ea\u30c3\u30af\u59cb\u3081\u305f\u4f4d\u7f6e\u306eY\u5ea7\u6a19\u3092\u5165\u308c\u308b\r\n\r\n\/\/---\u30b9\u30de\u30db\u306eOS\u53d6\u5f97\uff08PC\u7528\u3067\u306f\u4f7f\u308f\u306a\u3044\uff09\r\nvar ua = navigator.userAgent;\/\/User Agent\uff08\u307e\u3041\u6a5f\u7a2e\u540d\u307f\u305f\u3044\u306a\u306e\uff09\u3092\u53d6\u5f97\u3057\u3066\u5909\u6570ua\u306b\u4ee3\u5165\u3057\u306a\u3055\u3044\r\n\/\/---\r\n\r\n\r\n\/\/\u4ee5\u4e0biPhone\u306e\u6642\u306e\u6319\u52d5\uff08PC\u7528\u3067\u306f\u4f7f\u308f\u306a\u3044\uff09\r\nif (ua.indexOf(\"iPad\") &gt;= 0 || ua.indexOf(\"iPhone\") &gt;= 0 || ua.indexOf(\"iPod\") &gt;= 0){\r\n\/\/\u7279\u306b\u6319\u52d5\u306f\u307e\u3060\u6c7a\u3081\u3066\u3044\u306a\u3044\r\n}\r\n\r\n\/\/\u4ee5\u4e0bAndroid\u306e\u6642\u306e\u6319\u52d5\uff08PC\u7528\u3067\u306f\u4f7f\u308f\u306a\u3044\uff09\r\nif (ua.indexOf(\"Android\") &gt;= 0){\r\n\/\/\u7279\u306b\u6319\u52d5\u306f\u307e\u3060\u6c7a\u3081\u3066\u3044\u306a\u3044\r\n}\r\n\r\n\r\n\/\/---------\r\nwindow.onload = function() {\/\/\u3053\u308c\u3092\u8aad\u307f\u8fbc\u3093\u3060\u3089\r\n syokika();\/\/\u521d\u671f\u5316\u3068\u3044\u3046function\u3092\u5b9f\u884c\u3057\u3066\u306d\r\n};\r\n\r\nfunction syokika(){\/\/\u3067\uff0c\u3053\u308c\u304c\u521d\u671f\u5316\u306efunction\r\ncanvas = document.getElementById(\"myCanvas\");\r\nvar context = canvas.getContext(\"2d\");\r\ncanvas.addEventListener(\"mousemove\", draw, true);\/\/\u30de\u30a6\u30b9\u304c\u52d5\u3044\u305f\u3068\u304d\u6ce2draw\u3092\u3084\u308a\u306a\r\ncanvas.addEventListener(\"mousedown\", myMove, false);\/\/\u30de\u30a6\u30b9\u304c\u62bc\u3055\u308c\u305f\u6642\u306fmyMove\u3092\u3084\u308a\u306a\r\ncanvas.addEventListener(\"mouseup\", myMouseUp, false);\/\/\u30de\u30a6\u30b9\u304c\u4e0a\u304c\u3063\u305f\u3068\u304d\u306fmtMouseUp\u3092\u3084\u3063\u3068\u304b\u3081\r\n\r\n\r\n}\r\n\r\nfunction myMove(atai){\/\/\u30af\u30ea\u30c3\u30af\u958b\u59cb\u6642\u306b\u5b9f\u884c\u3055\u305b\u3066\u7dda\u306e\u63cf\u304d\u59cb\u3081\u306e\u5834\u6240\u3092oldX,oldY\u306b\u5165\u308c\u3061\u3083\u3046\u3088function\r\n        paintSwitch = true;\r\n        oldX = atai.clientX - canvas.offsetLeft;\/\/\u30aa\u30d5\u30bb\u30c3\u30c8\uff08\u305a\u308c\uff09\u306e\u4fee\u6b63\uff1d\u3088\u3053 clientX\u306e\u4ee3\u308f\u308a\u306bpageX\u3092\u4f7f\u3046\u3068\u304d\u3082\u3042\u308b\u3089\u3057\u3044\r\n        oldY = atai.clientY - canvas.offsetTop;\/\/\u30aa\u30d5\u30bb\u30c3\u30c8\uff08\u305a\u308c\uff09\u306e\u4fee\u6b63\uff1d\u305f\u3066\u3000clientY\u306e\u4ee3\u308f\u308a\u306bpageY\u3092\u4f7f\u3046\u3068\u304d\u3082\u3042\u308b\u3089\u3057\u3044\r\n}\r\n\r\nfunction myMouseUp(){\r\n\t\tpaintSwitch = false;\/\/pantSwitch\u306f\u30aa\u30d5\u306d\r\n}\r\n\r\n\/\/setInterval(draw, 10);\/\/10msec\u8d77\u304d\u306b\u63cf\u3044\u3066\u306d\u3000\u4eca\u56de\u306f\u4f7f\u3044\u307e\u305b\u3093\r\n\r\nfunction draw(atai) {\r\nif (!paintSwitch) return;\r\n\tvar x = atai.clientX - canvas.offsetLeft;\r\n    var y = atai.clientY - canvas.offsetTop;\r\n    \/\/var can = document.getElementById(\"myCanvas\");\r\n    var context = canvas.getContext(\"2d\");\r\n    context.strokeStyle = \"rgba(255,0,0,1)\";\r\n    context.lineWidth = 1;\r\n    context.beginPath();\r\n    context.moveTo(oldX, oldY);\r\n    context.lineTo(x, y);\r\n    context.stroke();\r\n    context.closePath();\r\n    oldX = x;\r\n    oldY = y;\r\n}\r\n\r\n\r\n\r\n\/\/---\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304d\u51fa\u3059\u3088\u3046\r\n\r\nfunction screenshot(){\r\n  var png = canvas.toDataURL();\r\n  document.getElementById(\"newImg\").src = png;\r\n}\r\n\/\/---\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;form&gt;\r\n&lt;input type=\"button\" value=\"\u753b\u50cf\u306b\u5909\u63db\" onclick=\"screenshot()\"&gt;\r\n&lt;\/form&gt;\r\n&lt;div&gt;&lt;img id=\"newImg\"&gt;&lt;\/div&gt;\r\n&lt;!-- \u3053\u306eDIV\u306eID\u3092\u63a2\u3057\u3066\u3053\u3053\u306b\u753b\u50cf\u3092\u5165\u308c\u308b --&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre>\n<p>\u6b21\u306b\uff0c\u3053\u308c\u3092\u30b9\u30de\u30fc\u30c8\u30db\u30f3\u7248\u3067\u4f5c\u3063\u3066\u307f\u307e\u3059<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u304a\u7d75\u304b\u304d\u30c4\u30fc\u30eb\uff08PC\u7248\uff09\u3067\u3059 &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;touch paint&lt;\/title&gt; &lt;meta &hellip; <a href=\"https:\/\/nantoka.filmm.info\/blog\/?p=341\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">HTML5\u5165\u9580\u305d\u306e14-\u304a\u7d75\u304b\u304d\u30c4\u30fc\u30eb2<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,11,7,1],"tags":[],"class_list":["post-341","post","type-post","status-publish","format-standard","hentry","category-html5","category-javascript","category-7","category-1"],"_links":{"self":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341"}],"version-history":[{"count":3,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions"}],"predecessor-version":[{"id":344,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/341\/revisions\/344"}],"wp:attachment":[{"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nantoka.filmm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}