2020-09-08 23:35:47 +00:00
|
|
|
var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},e=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof t&&t)||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!n.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:n},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},a={}.toString,classofRaw=function(t){return a.call(t).slice(8,-1)},c="".split,u=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?c.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return u(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!isObject(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},s=e.document,l=isObject(s)&&isObject(s.createElement),documentCreateElement=function(t){return l?s.createElement(t):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,y={f:r?h:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),p)try{return h(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!i.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},v=Object.defineProperty,d={f:r?v:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),p)try{return v(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},g=r?function(t,e,r){return d.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,r){try{g(e,t,r)}catch(n){e[t]=r}return r},m=e["__core-js_shared__"]||setGlobal("__core-js_shared__",{}),b=Function.toString;"function"!=typeof m.inspectSource&&(m.inspectSource=function(t){return b.call(t)});var w,S,O,j=m.inspectSource,x=e.WeakMap,E="function"==typeof x&&/native code/.test(j(x)),P=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),A=0,T=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++A+T).toString(36)},_=P("keys"),sharedKey=function(t){return _[t]||(_[t]=uid(t))},k={},L=e.WeakMap;if(E){var I=new L,G=I.get,C=I.has,M=I.set;w=function(t,e){return M.call(I,t,e),e},S=function(t){return G.call(I,t)||{}},O=function(t){return C.call(I,t)}}else{var N=sharedKey("state");k[N]=!0,w=function(t,e){return g(t,N,e),e},S=function(t){return has(t,N)?t[N]:{}},O=function(t){return has(t,N)}}var R,D,V={set:w,get:S,has:O,enforce:function(t){return O(t)?S(t):w(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=S(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return r}}},W=createCommonjsModule((function(t){var r=V.get,n=V.enforc
|
2020-09-08 23:35:47 +00:00
|
|
|
*/var $n={name:"grid",init:function init(t){var e=this;return function _asyncToGenerator(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function _next(t){asyncGeneratorStep(i,n,o,_next,_throw,"next",t)}function _throw(t){asyncGeneratorStep(i,n,o,_next,_throw,"throw",t)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var r,n,o,i,a,c,u,f,s,l,p,h,y,v,d,g,m,b,w,S,O,j;return regeneratorRuntime.wrap((function _callee$(x){for(;;)switch(x.prev=x.next){case 0:return O=function _gridUpdate(){v&&S(u.getZoom()),r("#canvasGrid").toggle(v),r("#view_grid").toggleClass("push_button_pressed tool_button")},S=function _updateGrid(t){var e=h[i.curConfig.baseUnit]*t,r=100/e,n=1;y.some((function(t){return n=t,r<=t}));var o=n*e;l.width=o,l.height=o;var a=l.getContext("2d"),c=.5,f=o/10;a.globalAlpha=.2,a.strokeStyle=i.curConfig.gridColor;for(var s=1;s<10;s++){var p=Math.round(f*s)+.5;a.moveTo(p,o),a.lineTo(p,0),a.moveTo(o,p),a.lineTo(0,p)}a.stroke(),a.beginPath(),a.globalAlpha=.5,a.moveTo(c,o),a.lineTo(c,0),a.moveTo(o,c),a.lineTo(0,c),a.stroke();var v=l.toDataURL("image/png");b.setAttribute("width",o),b.setAttribute("height",o),b.parentNode.setAttribute("width",o),b.parentNode.setAttribute("height",o),u.setHref(b,v)},r=t.$,n=t.NS,o=t.getTypeMap,i=e,x.next=6,import("./locale/".concat(i.curPrefs.lang,".js"));case 6:return a=x.sent,c=a.default,u=i.canvas,f=document.getElementById("svgcanvas").ownerDocument,s=u.assignAttributes,l=document.createElement("canvas"),p=r("#canvasBackground"),h=o(),y=[.01,.1,1,10,100,1e3],v=i.curConfig.showGrid||!1,r(l).hide().appendTo("body"),d=f.createElementNS(n.SVG,"svg"),s(d,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"}),p.append(d),g=f.createElementNS(n.SVG,"defs"),m=f.createElementNS(n.SVG,"pattern"),s(m,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100}),b=f.createElementNS(n.SVG,"image"),s(b,{x:0,y:0,width:100,height:100}),m.append(b),g.append(m),r("#canvasGrid").append(g),w=f.createElementNS(n.SVG,"rect"),s(w,{width:"100%",height:"100%",x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"}),r("#canvasGrid").append(w),j=[{id:"view_grid",icon:"grid.png",type:"context",panel:"editor_panel",events:{click:function click(){i.curConfig.showGrid=v=!v,O()}}}],x.abrupt("return",{name:c.name,svgicons:"grid-icon.xml",zoomChanged:function zoomChanged(t){v&&S(t)},callback:function callback(){v&&O()},buttons:c.buttons.map((function(t,e){return Object.assign(j[e],t)}))});case 28:case"end":return x.stop()}}),_callee)})))()}};export default $n;
|