{"id":1,"date":"2025-03-04T01:40:21","date_gmt":"2025-03-04T01:40:21","guid":{"rendered":"http:\/\/sogetsu-tech.online\/?p=1"},"modified":"2025-05-25T15:43:59","modified_gmt":"2025-05-25T06:43:59","slug":"hello-world","status":"publish","type":"post","link":"https:\/\/sogetsu-tech.online\/?p=1","title":{"rendered":"Hello world!"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Welcome to WordPress. This is your first post. Edit or delete it, then start writing!<\/p>\n\n\n\n<!DOCTYPE html>\n<html lang=\"ja\">\n<head>\n  <meta charset=\"UTF-8\">\n  <title>\u753b\u50cf\u304b\u3089STL\uff08\u7acb\u4f53\u751f\u6210\uff09<\/title>\n  <style>\n    body { font-family: sans-serif; padding: 20px; }\n    input, button { margin: 5px 0; display: block; }\n  <\/style>\n<\/head>\n<body>\n<div class=\"calc-box\">\n  <h4>\u753b\u50cf \u2192 \u5b8c\u5168\u7acb\u4f53STL\u5909\u63db\u30c4\u30fc\u30eb<\/h4>\n  \n  <div class=\"calc-row\">\n    <label>\u753b\u50cf\u3092\u9078\u629e\uff08JPEG\/PNG\uff09:<\/label>\n  <input type=\"file\" id=\"imageInput\" accept=\"image\/png, image\/jpeg\">\n  <\/div>\n  <div class=\"calc-row\">\n    <label>\u6a2a\u5e45 [mm]:<\/label>\n  <input type=\"number\" id=\"widthInput\" value=\"50\">\n  <\/div>\n  <div class=\"calc-row\">\n    <label>\u7e26\u5e45 [mm]:<\/label>\n  <input type=\"number\" id=\"heightInput\" value=\"50\">\n  <\/div>\n  <div class=\"calc-row\">\n    <label>\u767d(\u30d9\u30fc\u30b9)\u306e\u9ad8\u3055 [mm]:<\/label>\n  <input type=\"number\" id=\"whiteHeightInput\" value=\"1\">\n  <\/div>\n  <div class=\"calc-row\">\n    <label>\u9ed2(\u30e1\u30a4\u30f3)\u306e\u9ad8\u3055 [mm]:<\/label>\n  <input type=\"number\" id=\"blackHeightInput\" value=\"5\">\n  <\/div>\n\n  <div class=\"calc-buttons\">\n  <button type=\"button\" onclick=\"generateSTL()\">STL\u3092\u751f\u6210\u3057\u3066\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/button>\n  <\/div>\n\n  <canvas id=\"canvas\" style=\"display: none;\"><\/canvas>\n\n<style>\n.calc-box {\n  background: #ffffff;\n  border: 2px solid #ccc;\n  padding: 20px;\n  border-radius: 8px;\n  max-width: 400px;\n  margin: 30px auto;\n  font-size: 0.95rem;\n}\n\n.calc-box h4 {\n  margin-bottom: 15px;\n  text-align: center;\n  font-size: 1.2rem;\n  color: #12124d;\n}\n\n.calc-row {\n  margin-bottom: 15px;\n}\n.calc-buttons {\n  display: flex;\n  justify-content: center;\n  margin-top: 20px;\n}\n\n.calc-buttons button {\n  padding: 10px 30px;\n  font-size: 1rem;\n  background: #12124d;\n  color: #ffffff;\n  border: none;\n  border-radius: 5px;\n  cursor: pointer;\n  transition: background 0.3s;\n}\n\n.calc-buttons button:hover {\n  background: #0d0d3b;\n}\n<\/style>\n\n\n  <script>\n    function generateSTL() {\n      const file = document.getElementById('imageInput').files[0];\n      if (!file) return alert(\"\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002\");\n\n      const reader = new FileReader();\n      reader.onload = function (e) {\n        const img = new Image();\n        img.onload = function () {\n          const canvas = document.getElementById('canvas');\n          const ctx = canvas.getContext('2d');\n          const w = 200, h = 200;\n          canvas.width = w;\n          canvas.height = h;\n          ctx.drawImage(img, 0, 0, w, h);\n          const imgData = ctx.getImageData(0, 0, w, h).data;\n\n          const widthMM = parseFloat(document.getElementById(\"widthInput\").value);\n          const heightMM = parseFloat(document.getElementById(\"heightInput\").value);\n          const baseHeight = parseFloat(document.getElementById(\"whiteHeightInput\").value);\n          const topHeight = parseFloat(document.getElementById(\"blackHeightInput\").value);\n\n          const dx = widthMM \/ w;\n          const dy = heightMM \/ h;\n\n          let stl = \"solid image\\n\";\n\n          for (let y = 0; y < h; y++) {\n            const yFlipped = h - y - 1;\n            for (let x = 0; x < w; x++) {\n              const i = (yFlipped * w + x) * 4;\n              const brightness = imgData[i];\n              const z = brightness < 128 ? topHeight : baseHeight;\n\n              const x0 = x * dx;\n              const y0 = y * dy;\n              const x1 = (x + 1) * dx;\n              const y1 = (y + 1) * dy;\n              const z0 = 0;\n              const z1 = z;\n\n              stl += quad(x0, y0, z1, x1, y0, z1, x1, y1, z1, x0, y1, z1); \/\/ \u4e0a\u9762\n              stl += quad(x0, y0, z0, x0, y1, z0, x1, y1, z0, x1, y0, z0); \/\/ \u5e95\u9762\n              stl += quad(x0, y1, z0, x1, y1, z0, x1, y1, z1, x0, y1, z1); \/\/ \u524d\u9762\n              stl += quad(x0, y0, z0, x0, y0, z1, x1, y0, z1, x1, y0, z0); \/\/ \u80cc\u9762\n              stl += quad(x0, y0, z0, x0, y1, z0, x0, y1, z1, x0, y0, z1); \/\/ \u5de6\u9762\n              stl += quad(x1, y0, z0, x1, y0, z1, x1, y1, z1, x1, y1, z0); \/\/ \u53f3\u9762\n            }\n          }\n\n          stl += \"endsolid image\\n\";\n          downloadSTL(stl);\n        };\n        img.src = e.target.result;\n      };\n      reader.readAsDataURL(file);\n    }\n\n    function triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3) {\n      return `\nfacet normal 0 0 0\nouter loop\nvertex ${x1} ${y1} ${z1}\nvertex ${x2} ${y2} ${z2}\nvertex ${x3} ${y3} ${z3}\nendloop\nendfacet\\n`;\n    }\n\n    function quad(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4) {\n      return triangle(x1, y1, z1, x2, y2, z2, x3, y3, z3) +\n             triangle(x1, y1, z1, x3, y3, z3, x4, y4, z4);\n    }\n\n    function downloadSTL(stl) {\n      const blob = new Blob([stl], { type: \"application\/sla\" });\n      const url = URL.createObjectURL(blob);\n      const a = document.createElement(\"a\");\n      a.href = url;\n      a.download = \"converted.stl\";\n      a.click();\n      URL.revokeObjectURL(url);\n    }\n  <\/script>\n<\/body>\n<\/html>\n\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing! \u753b\u50cf\u304b\u3089STL\uff08\u7acb\u4f53\u751f\u6210\uff09 \u753b\u50cf \u2192 \u5b8c\u5168\u7acb\u4f53S [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","footnotes":""},"categories":[3,1,4],"tags":[],"class_list":["post-1","post","type-post","status-publish","format-standard","hentry","category-3d-printer","category-uncategorized","category-blog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/posts\/1","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1"}],"version-history":[{"count":13,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions"}],"predecessor-version":[{"id":1459,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=\/wp\/v2\/posts\/1\/revisions\/1459"}],"wp:attachment":[{"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sogetsu-tech.online\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}