CuttingBoard/docs/js/app.ed26f79c.js

2 lines
16 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(function(t){function e(e){for(var r,i,s=e[0],c=e[1],l=e[2],d=0,f=[];d<s.length;d++)i=s[d],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&f.push(o[i][0]),o[i]=0;for(r in c)Object.prototype.hasOwnProperty.call(c,r)&&(t[r]=c[r]);u&&u(e);while(f.length)f.shift()();return a.push.apply(a,l||[]),n()}function n(){for(var t,e=0;e<a.length;e++){for(var n=a[e],r=!0,s=1;s<n.length;s++){var c=n[s];0!==o[c]&&(r=!1)}r&&(a.splice(e--,1),t=i(i.s=n[0]))}return t}var r={},o={app:0},a=[];function i(e){if(r[e])return r[e].exports;var n=r[e]={i:e,l:!1,exports:{}};return t[e].call(n.exports,n,n.exports,i),n.l=!0,n.exports}i.m=t,i.c=r,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"===typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)i.d(n,r,function(e){return t[e]}.bind(null,r));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t["default"]}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="";var s=window["webpackJsonp"]=window["webpackJsonp"]||[],c=s.push.bind(s);s.push=e,s=s.slice();for(var l=0;l<s.length;l++)e(s[l]);var u=c;a.push([0,"chunk-vendors"]),n()})({0:function(t,e,n){t.exports=n("56d7")},"0f21":function(t,e,n){"use strict";n("ec56")},"23b6":function(t,e,n){"use strict";n("d747")},"56d7":function(t,e,n){"use strict";n.r(e);n("e260"),n("e6cf"),n("cca6"),n("a79d");var r=n("7a23"),o={class:"app-settings"},a=Object(r["f"])("h1",null,"Settings",-1),i=Object(r["f"])("h1",null,"Layers",-1),s=Object(r["f"])("h1",null,"Wood types",-1),c=Object(r["f"])("h1",null,"Save / load",-1),l={class:"loadSave block"},u=Object(r["f"])("input",{type:"file",id:"loadFile",accept:".json"},null,-1),d=Object(r["f"])("h1",null,"About / feedback",-1),f=Object(r["f"])("div",{class:"about block"},[Object(r["f"])("p",null,[Object(r["e"])(" Created by Mark van Renswoude. Open-source and available under the Unlicense to the public domain on "),Object(r["f"])("a",{href:"https://github.com/MvRens/CuttingBoard",target:"_blank"},"Github"),Object(r["e"])(", where feedback is welcome under Issues. ")]),Object(r["f"])("p",null,[Object(r["e"])(" Heavily inspired by "),Object(r["f"])("a",{href:"http://www.lastalias.com/cbdesigner/"},"CBdesigner"),Object(r["e"])(". ")])],-1),h={class:"app-preview"},b=Object(r["f"])("h1",null,"Edge grain",-1),p=Object(r["f"])("h1",null,"End grain",-1);function O(t,e,n,O,v,j){var g=Object(r["m"])("Settings"),w=Object(r["m"])("Layers"),m=Object(r["m"])("Wood"),y=Object(r["m"])("EndGrainPreview"),k=Object(r["m"])("EdgeGrainPreview");return Object(r["h"])(),Object(r["c"])(r["a"],null,[Object(r["f"])("div",o,[a,Object(r["f"])(g,{class:"block"}),i,Object(r["f"])(w,{class:"block"}),s,Object(r["f"])(m,{class:"block"}),c,Object(r["f"])("div",l,[Object(r["f"])("p",null,[Object(r["r"])(Object(r["f"])("input",{type:"text","onUpdate:modelValue":e[1]||(e[1]=function(t){return v.saveFilename=t})},null,512),[[r["p"],v.saveFilename]]),Object(r["f"])("button",{onClick:e[2]||(e[2]=function(t){return j.save()})},"Save")]),Object(r["f"])("p",null,[u,Object(r["f"])("button",{onClick:e[3]||(e[3]=function(t){return j.load()})},"Load")])]),d,f]),Object(r["f"])("div",h,[b,Object(r["f"])(y,{scale:1}),p,Object(r["f"])(k,{scale:1})])],64)}n("b0c0"),n("8a79");var v=Object(r["s"])("data-v-660f17f9");Object(r["j"])("data-v-660f17f9");var j={class:"settings"},g=Object(r["d"])('<h2 data-v-660f17f9>Designer</h2><label for="units" data-v-660f17f9>Units</label><select id="units" disabled data-v-660f17f9><option value="mm" data-v-660f17f9>Millimeters</option><option value="cm" data-v-660f17f9>Centimeters</option><option value="inch" data-v-660f17f9>Inches (fractional)</option></select><label for="borders" data-v-660f17f9>Show borders</label>',4),w=Object(r["f"])("h2",null,"Material",-1),m=Object(r["f"])("label",{for:"boardThickness"},"Board thickness",-1),y=Object(r["f"])("label",{for:"boardLength"},"Board length",-1),k=Object(r["f"])("label",{for:"bladeKerf"},"Blade kerf",-1),x=Object(r["f"])("h2",null,"End grain",-1),W=Object(r["f"])("label",{for:"crosscutWidth"},"Crosscut width",-1),L=Object(r["f"])("label",{for:"alternateDirection"},"Alternate direction",-1);Object(r["i"])();var P=v((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",j,[g,Object(r["f"])("input",{id:"borders",type:"checkbox",checked:i.settings.borders,onChange:e[1]||(e[1]=function(e){return t.$store.commit("updateSettings",{borders:e.target.checked})})},null,40,["checked"]),w,m,Object(r["f"])("input",{id:"boardThickness",type:"number",value:i.settings.boardThickness,onChange:e[2]||(e[2]=function(e){return t.$store.commit("updateSettings",{boardThickness:i.parseFloatDef(e.target.value)})})},null,40,["value"]),y,Object(r["f"])("input",{id:"boardLength",type:"number",value:i.settings.boardLength,onChange:e[3]||(e[3]=function(e){return t.$store.commit("updateSettings",{boardLength:i.parseFloatDef(e.target.value)})})},null,40,["value"]),k,Object(r["f"])("input",{id:"bladeKerf",type:"number",value:i.settings.bladeKerf,onChange:e[4]||(e[4]=function(e){return t.$store.commit("updateSettings",{bladeKerf:i.parseFloatDef(e.target.value)})})},null,40,["value"]),x,W,Object(r["f"])("input",{id:"crosscutWidth",type:"number",value:i.settings.crosscutWidth,onChange:e[5]||(e[5]=function(e){return t.$store.commit("updateSettings",{crosscutWidth:i.parseFloatDef(e.target.value)})})},null,40,["value"]),L,Object(r["f"])("input",{id:"alternateDirection",type:"checkbox",checked:i.settings.alternateDirection,onChange:e[6]||(e[6]=function(e){return t.$store.commit("updateSettings",{alternateDirection:e.target.checked})})},null,40,["checked"])])})),S=(n("2b19"),25.4),$=10,C=1,B={toPixels:function(t,e){return this.toMillimeters(t,e)*C},toMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t*$;case"inch":return t*S}return console.error("Invalid units type: "+e),0},fromMillimeters:function(t,e){switch(e){case"mm":return t;case"cm":return t/$;case"inch":return t/S}return console.error("Invalid units type: "+e),0}},M={computed:{settings:function(){return this.$store.state.settings}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}}};n("e334");M.render=P,M.__scopeId="data-v-660f17f9";var F=M,D=Object(r["s"])("data-v-535527d4");Object(r["j"])("data-v-535527d4");var _={class:"layers"},H={class:"add"},T=Object(r["f"])("span",{class:"header"}," ",-1),E=Object(r["f"])("span",{class:"header"},"Wood type",-1),N=Object(r["f"])("span",{class:"header"},"Width",-1),I=Object(r["f"])("span",{class:"header"}," ",-1),U={class:"index"},A={class:"remove"};Object(r["i"])();var K=D((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",_,[Object(r["f"])("div",H,[Object(r["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addLayer()})},"Add layer")]),T,E,N,I,(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])(r["a"],null,[Object(r["f"])("div",U,Object(r["n"])(e+1),1),Object(r["r"])(Object(r["f"])("select",{"onUpdate:modelValue":function(e){return t.wood=e},class:"wood"},[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.wood,(function(t,e){return Object(r["h"])(),Object(r["c"])("option",{value:e},Object(r["n"])(t.name),9,["value"])})),256))],8,["onUpdate:modelValue"]),[[r["o"],t.wood]]),Object(r["f"])("input",{type:"number",class:"width",value:t.width,onInput:function(e){return t.width=i.parseFloatDef(e.target.value)}},null,40,["value","onInput"]),Object(r["f"])("div",A,[Object(r["f"])("button",{onClick:function(t){return i.removeLayer(e)}},"X",8,["onClick"])])],64)})),256))])})),V={computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers}},methods:{parseFloatDef:function(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e},addLayer:function(){this.$store.commit("addLayer",0)},removeLayer:function(t){this.$store.commit("removeLayer",{board:0,layer:t})}}};n("23b6");V.render=K,V.__scopeId="data-v-535527d4";var G=V,J=Object(r["s"])("data-v-55181d8c");Object(r["j"])("data-v-55181d8c");var R={class:"wood"},X={class:"add"},Y=Object(r["f"])("span",{class:"header"}," ",-1),q=Object(r["f"])("span",{class:"header"},"Name",-1),z=Object(r["f"])("span",{class:"header"},"Colour",-1),Q=Object(r["f"])("span",{class:"header"}," ",-1),Z=Object(r["f"])("span",null," ",-1),tt={class:"remove"};Object(r["i"])();var et=J((function(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",R,[Object(r["f"])("div",X,[Object(r["f"])("button",{onClick:e[1]||(e[1]=function(t){return i.addWood()})},"Add wood type")]),Y,q,z,Q,(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.wood,(function(t,e){return Object(r["h"])(),Object(r["c"])(r["a"],null,[Z,Object(r["r"])(Object(r["f"])("input",{type:"text",class:"name","onUpdate:modelValue":function(e){return t.name=e}},null,8,["onUpdate:modelValue"]),[[r["p"],t.name]]),Object(r["r"])(Object(r["f"])("input",{type:"color",class:"color","onUpdate:modelValue":function(e){return t.color=e}},null,8,["onUpdate:modelValue"]),[[r["p"],t.color]]),Object(r["f"])("div",tt,[Object(r["f"])("button",{onClick:function(t){return i.removeWood(e)}},"X",8,["onClick"])])],64)})),256))])})),nt={computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood}},methods:{addWood:function(){this.$store.commit("addWood")},removeWood:function(t){this.$store.commit("removeWood",t)}}};n("667a");nt.render=et,nt.__scopeId="data-v-55181d8c";var rt=nt,ot={class:"preview"};function at(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",ot,[(Object(r["h"])(),Object(r["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])("rect",{width:i.toPixels(i.settings.boardLength),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))],8,["width","height","viewBox"]))])}n("d81d"),n("13d5"),n("a9e3");var it={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},boardWidth:function(){return this.toPixels(this.settings.boardLength)},boardHeight:function(){return this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},viewportWidth:function(){return Math.floor(this.boardWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardWidth+" "+this.boardHeight}},methods:{toPixels:function(t){return B.toPixels(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,n=0;n<t;n++)e+=this.layers[n].width;return e},getLayerStyle:function(t){if(t<0||t>=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var n=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+n}}};it.render=at;var st=it,ct={class:"preview"},lt={id:"strip"};function ut(t,e,n,o,a,i){return Object(r["h"])(),Object(r["c"])("div",ct,[(Object(r["h"])(),Object(r["c"])("svg",{width:i.viewportWidth,height:i.viewportHeight,viewBox:i.viewBox},[Object(r["f"])("defs",null,[Object(r["f"])("g",lt,[(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.layers,(function(t,e){return Object(r["h"])(),Object(r["c"])("rect",{width:i.toPixels(i.settings.boardThickness),height:i.toPixels(t.width),x:"0",y:i.getLayerOffset(e),style:i.getLayerStyle(e)},null,12,["width","height","y"])})),256))])]),(Object(r["h"])(!0),Object(r["c"])(r["a"],null,Object(r["l"])(i.stripsPerBoard,(function(t,e){return Object(r["h"])(),Object(r["c"])("use",{"xlink:href":"#strip",x:e*i.settings.boardThickness,y:"0",transform:i.getLayerTransform(e)},null,8,["x","transform"])})),256))],8,["width","height","viewBox"]))])}var dt={props:{scale:Number},computed:{settings:function(){return this.$store.state.settings},wood:function(){return this.$store.state.wood},layers:function(){return this.$store.state.boards[0].layers},stripsPerBoard:function(){var t=this.settings.crosscutWidth+this.settings.bladeKerf;return 0===t?0:Math.floor((this.settings.boardLength+this.settings.bladeKerf)/t)},boardWidth:function(){var t=this.stripsPerBoard*this.settings.boardThickness;return this.toPixels(t)},boardHeight:function(){return this.layers.map((function(t){return t.width})).reduce((function(t,e){return t+e}))},viewportWidth:function(){return Math.floor(this.boardWidth*this.scale)},viewportHeight:function(){return Math.floor(this.boardHeight*this.scale)},viewBox:function(){return"0 0 "+this.boardWidth+" "+this.boardHeight}},methods:{toPixels:function(t){return B.toPixels(t,this.settings.units)},getLayerOffset:function(t){if(t<0||t>=this.layers.length)return 0;for(var e=0,n=0;n<t;n++)e+=this.layers[n].width;return e},getLayerStyle:function(t){if(t<0||t>=this.layers.length)return"fill: fuchsia";var e=this.layers[t].wood;if(null===e)return"";var n=this.settings.borders?"; stroke-width: 1; stroke: black":"";return"fill: "+this.wood[e].color+n},getLayerTransform:function(t){return this.settings.alternateDirection&&t%2!=0?"scale(1, -1) translate(0, -"+this.boardHeight+")":""}}};dt.render=ut;var ft=dt,ht=n("21a6"),bt={name:"App",components:{EndGrainPreview:st,EdgeGrainPreview:ft,Settings:F,Layers:G,Wood:rt},data:function(){return{saveFilename:"My cutting board"}},methods:{save:function(){var t=this.$store.getters.save,e=new Blob([t],{type:"text/plain; charset=utf-8"});Object(ht["saveAs"])(e,this.saveFilename+".json")},load:function(){var t=this,e=document.getElementById("loadFile").files[0];if(e){this.saveFilename=e.name.toLowerCase().endsWith(".json")?e.name.substring(0,e.name.length-5):e.name;var n=new FileReader;n.addEventListener("load",(function(e){t.$store.commit("load",e.target.result)})),n.readAsBinaryString(e)}}}};n("0f21");bt.render=O;var pt=bt,Ot=(n("4160"),n("a434"),n("159b"),n("5502"));function vt(t,e){for(var n in t)t.hasOwnProperty(n)&&e.hasOwnProperty(n)&&(e[n]=t[n])}function jt(t){var e=parseFloat(t);return Object.is(e,NaN)?0:e}var gt=Object(Ot["a"])({state:{settings:{units:"mm",borders:!1,boardThickness:20,boardLength:700,bladeKerf:3.5,crosscutWidth:30,alternateDirection:!0},wood:[{name:"Walnut",color:"#58443f"},{name:"Maple",color:"#f2e0aa"},{name:"Cherry",color:"#bb8359"},{name:"Mahogany",color:"#98473f"},{name:"Yellowheart",color:"#ffff84"},{name:"White oak",color:"#fdf4b9"},{name:"Bubinga",color:"#7e3c34"},{name:"Jatoba",color:"#9b281c"},{name:"Padouk",color:"#933350"}],boards:[{layers:[{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20},{wood:0,width:20},{wood:1,width:20}]}]},mutations:{addLayer:function(t,e){e<0||e>=t.boards.length||t.boards[e].layers.push({wood:0,width:B.fromMillimeters(20,t.settings.units)})},removeLayer:function(t,e){e.board<0||e.board>=t.boards.length||e.layer<0||e.layer>=t.boards[e.board].length||t.boards[e.board].layers.splice(e.layer,1)},addWood:function(t){t.wood.push({name:"Wood #"+(t.wood.length+1),color:"#f2e0aa"})},removeWood:function(t,e){e<0||e>=t.wood.length||(t.boards.forEach((function(t){t.layers.forEach((function(t){t.wood===e?t.wood=null:t.wood>e&&t.wood--}))})),t.wood.splice(e,1))},updateSettings:function(t,e){vt(e,t.settings)},load:function(t,e){var n=JSON.parse(e);if(n.hasOwnProperty("settings")&&vt(n.settings,t.settings),n.hasOwnProperty("boards")){var r=n.boards.map((function(t){return t.hasOwnProperty("layers")?{layers:t.layers.map((function(t){return{wood:jt(t.wood),width:jt(t.width)}}))}:{layers:[]}}));0===r.length&&r.push({layers:[]}),t.boards=r}if(n.hasOwnProperty("wood")){var o=n.wood.map((function(t){return{name:t.name,color:t.color}}));t.wood=o}}},getters:{save:function(t){return JSON.stringify(t)}}});Object(r["b"])(pt).use(gt).mount("#app")},"667a":function(t,e,n){"use strict";n("6ac4")},"6ac4":function(t,e,n){},"9e5f":function(t,e,n){},d747:function(t,e,n){},e334:function(t,e,n){"use strict";n("9e5f")},ec56:function(t,e,n){}});
//# sourceMappingURL=app.ed26f79c.js.map