text: parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"mIWh":[function(require,module,exports) {
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=7;exports.tileSize=e;var t=16;exports.editorRatio=t;
  },{}],"UnXq":[function(require,module,exports) {
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("./state");function e(){return new Array(r.tileSize).fill(0).map(function(e,t){return new Array(r.tileSize).fill(0)})}function t(){return new Array(3).fill(0).map(function(r,t){return new Array(3).fill(0).map(function(r,t){return e()})})}function n(r,e){var t=r,n=e;return 1==arguments.length&&(t=0,n=r),t=Math.ceil(t),n=Math.floor(n),Math.floor(Math.random()*(n-t))+t}function i(){return[n(3),n(3),n(r.tileSize),n(r.tileSize)]}function o(e){var t=e[0],n=e[1];return[3*r.tileSize-n,t]}function u(e,t){var n=e[0],i=e[1];void 0===t&&(t=1);var o=3*r.tileSize-1;return[[n,i],[o-i,n],[o-n,o-i],[i,o-n]]}function a(r,e){var t=e.reduce(function(r,e){return r[e]},r);return"number"!=typeof t?0:t}function c(r,e,t){void 0===t&&(t=1);var n=e.slice(0,-1),i=e[e.length-1];n.reduce(function(r,e){return r[e]},r)[i]=t}exports.newGrid=t,exports.randomInt=n,exports.randomLoc=i,exports.rotatePair=o,exports.rotationSet=u,exports.getLoc=a,exports.setLoc=c;
  },{"./state":"mIWh"}],"vPWx":[function(require,module,exports) {
  "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./state"),t=require("./utils"),i=document.getElementById("editor"),o=document.getElementById("guide"),r=document.getElementById("render"),l=i.getContext("2d"),n=o.getContext("2d"),d=r.getContext("2d");function a(){l.clearRect(0,0,i.width,i.height)}function c(i,o){d.fill();for(var r=0;r<3;r++)for(var n=0;n<3;n++)for(var a=0;a<e.tileSize;a++)for(var c=0;c<e.tileSize;c++){var s=t.getLoc(i,[r,n,a,c]);l.fillStyle=1==s?"#000":"#fff0",d.fillStyle=1==s?"#000":"#fff0";var f=(r*e.tileSize+a)*o,g=(n*e.tileSize+c)*o;1==r&&1==n||(d.clearRect(f,g,o,o),d.fillRect(f,g,o,o),f*=e.editorRatio/o,g*=e.editorRatio/o,l.fillRect(f+1,g+1,e.editorRatio-1,e.editorRatio-1))}}function s(){for(var t=1;t<3;t++){n.strokeStyle="#33f",n.lineWidth=.5;var o=t*i.width/3;n.beginPath(),n.moveTo(o,0),n.lineTo(o,i.height),n.stroke(),n.beginPath(),n.moveTo(0,o),n.lineTo(i.height,o),n.stroke()}for(t=0;t<3*e.tileSize;t++){n.strokeStyle="#ccc";o=t*i.width/(3*e.tileSize);n.beginPath(),n.moveTo(o,0),n.lineTo(o,i.height),n.stroke(),n.beginPath(),n.moveTo(0,o),n.lineTo(i.height,o),n.stroke()}var r=i.width/3;n.clearRect(r+1,r+1,r-2,r-2),n.beginPath(),n.moveTo(1*r,2*r),n.lineTo(2*r,1*r),n.stroke(),n.beginPath(),n.moveTo(1*r,1*r),n.lineTo(2*r,2*r),n.stroke()}function f(t){var i=r.toDataURL(),o=document.getElementById("target"),l=document.getElementById("border-style");l&&l.remove(),(l=document.createElement("style")).id="border-style",document.head.appendChild(l);var n='.broider {\n    border-image:  url("'+i+'") '+e.tileSize*t+" /  "+e.tileSize*t+"px / 0 round;\n    border-width:  "+e.tileSize*t+"px;\n    border-style:  solid;\n}";l.sheet.insertRule(n),o.textContent=n}function g(i,o){var r=o[0]*e.tileSize+o[2],n=o[1]*e.tileSize+o[3];l.fillStyle=(t.getLoc(i,o),"#dde"),1==o[0]&&1==o[1]||l.fillRect(r*e.editorRatio+0,n*e.editorRatio+0,e.editorRatio-0,e.editorRatio-0)}d.imageSmoothingEnabled=!1,exports.cleanMap=a,exports.renderMap=c,exports.drawGuide=s,exports.setBorder=f,exports.renderHover=g;
  },{"./state":"mIWh","./utils":"UnXq"}],"Skeg":[function(require,module,exports) {
  module.exports="/broider/1.215f8ecf.png";
  },{}],"yB7T":[function(require,module,exports) {
  module.exports="/broider/2.07e2c5fb.png";
  },{}],"Cd2M":[function(require,module,exports) {
  module.exports="/broider/4.ed708439.png";
  },{}],"QCba":[function(require,module,exports) {
  "use strict";var e=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./render"),i=e(require("./1.png")),n=e(require("./2.png")),d=e(require("./4.png")),r=require("./state"),o=require("./utils"),c=document.getElementById("pen"),a=document.getElementById("eraser"),l=document.getElementById("symmetry"),u=document.getElementById("scale"),s=document.getElementById("editor-frame"),h=document.getElementById("editor"),f=document.getElementById("guide"),v=document.getElementById("render");h.width=r.tileSize*r.editorRatio*3,h.height=r.tileSize*r.editorRatio*3,f.width=r.tileSize*r.editorRatio*3,f.height=r.tileSize*r.editorRatio*3;var g=2,m=[1,2,4],E=[i.default,n.default,d.default],L=m[g];v.width=r.tileSize*L*3,v.height=r.tileSize*L*3,u.addEventListener("click",function(){g=(g+1)%m.length,u.src=E[g],L=m[g],v.width=r.tileSize*L*3,v.height=r.tileSize*L*3,t.renderMap(B,L),t.setBorder(L)}),document.addEventListener("DOMContentLoaded",function(){s.style.height=h.getBoundingClientRect().width+"px"}),window.addEventListener("resize",function(){s.style.height=h.getBoundingClientRect().width+"px"});var p=!1,w=!1,S=!0;l.addEventListener("click",function(e){S=!S,l.classList.toggle("selected")}),a.addEventListener("click",function(e){w=!0,a.classList.add("selected"),c.classList.remove("selected")}),c.addEventListener("click",function(e){w=!1,c.classList.add("selected"),a.classList.remove("selected")});var B=o.newGrid();function y(e,t){p&&o.setLoc(B,e,1-t)}t.drawGuide(),t.renderMap(B,L),t.setBorder(L);var z=function(e,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var d=h.getBoundingClientRect(),c=d.left,a=d.top,l=d.width,u=d.height,s=e.clientX-c,f=e.clientY-a,v=s/l*h.width,g=f/u*h.height,m=Math.floor(v/r.editorRatio),E=Math.floor(g/r.editorRatio),p=S?o.rotationSet([m,E]):[[m,E]];t.cleanMap(),p.forEach(function(e){var d=e[0],c=e[1],a=Math.floor(d/r.tileSize),l=Math.floor(c/r.tileSize),u=[a,l,d%r.tileSize,c%r.tileSize];if(n&&t.renderHover(B,u),!(a<0||a>2||l<0||l>2)){var s=o.getLoc(B,u);i||(s=0),w&&(s=1),y(u,s)}}),t.renderMap(B,L),window.setTimeout(function(){return t.setBorder(L)},0)};h.addEventListener("mousedown",function(e){p=!0,z(e,!0)}),h.addEventListener("mousemove",function(e){z(e,!1,!0)}),h.addEventListener("mouseout",function(e){t.cleanMap(),t.renderMap(B,L)}),window.addEventListener("mousedown",function(){p=!0}),window.addEventListener("mouseup",function(){p=!1}),h.addEventListener("touchend",function(e){p=!1}),h.addEventListener("touchstart",function(e){p=!0,e.preventDefault();for(var t=e.targetTouches,i=0;i<t.length;i++)e.clientX=t[i].clientX,e.clientY=t[i].clientY,z(e)}),h.addEventListener("touchmove",function(e){e.preventDefault(),p=!0;for(var t=e.targetTouches,i=0;i<t.length;i++)e.clientX=t[i].clientX,e.clientY=t[i].clientY,z(e)});var M=0;window.addEventListener("touchend",function(e){e.timeStamp-M<=500&&(e.preventDefault(),e.target.click()),p=!1,M=e.timeStamp});
  },{"./render":"vPWx","./1.png":"Skeg","./2.png":"yB7T","./4.png":"Cd2M","./state":"mIWh","./utils":"UnXq"}]},{},["QCba"], null)
  //# sourceMappingURL=/broider/border.cd623856.js.map