12 lines
2.9 KiB
JavaScript
12 lines
2.9 KiB
JavaScript
|
function asyncGeneratorStep(e,t,n,r,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void n(e)}c.done?t(s):Promise.resolve(s).then(r,a)}
|
||
|
/**
|
||
|
* @file ext-grid.js
|
||
|
*
|
||
|
* @license Apache-2.0
|
||
|
*
|
||
|
* @copyright 2010 Redou Mine, 2010 Alexis Deveria
|
||
|
*
|
||
|
*/
|
||
|
var e={name:"grid",init:function init(e){var t=this;return function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function _next(e){asyncGeneratorStep(o,r,a,_next,_throw,"next",e)}function _throw(e){asyncGeneratorStep(o,r,a,_next,_throw,"throw",e)}_next(void 0)}))}}(regeneratorRuntime.mark((function _callee(){var n,r,a,o,i,c,s,d,u,l,p,g,h,v,m,f,w,b,_,y,G,S;return regeneratorRuntime.wrap((function _callee$(x){for(;;)switch(x.prev=x.next){case 0:return G=function _gridUpdate(){v&&y(s.getZoom()),n("#canvasGrid").toggle(v),n("#view_grid").toggleClass("push_button_pressed tool_button")},y=function _updateGrid(e){var t=g[o.curConfig.baseUnit]*e,n=100/t,r=1;h.some((function(e){return r=e,n<=e}));var a=r*t;l.width=a,l.height=a;var i=l.getContext("2d"),c=.5,d=a/10;i.globalAlpha=.2,i.strokeStyle=o.curConfig.gridColor;for(var u=1;u<10;u++){var p=Math.round(d*u)+.5;i.moveTo(p,a),i.lineTo(p,0),i.moveTo(a,p),i.lineTo(0,p)}i.stroke(),i.beginPath(),i.globalAlpha=.5,i.moveTo(c,a),i.lineTo(c,0),i.moveTo(a,c),i.lineTo(0,c),i.stroke();var v=l.toDataURL("image/png");b.setAttribute("width",a),b.setAttribute("height",a),b.parentNode.setAttribute("width",a),b.parentNode.setAttribute("height",a),s.setHref(b,v)},n=e.$,r=e.NS,a=e.getTypeMap,o=t,x.next=6,import("./locale/".concat(o.curPrefs.lang,".js"));case 6:return i=x.sent,c=i.default,s=o.canvas,d=document.getElementById("svgcanvas").ownerDocument,u=s.assignAttributes,l=document.createElement("canvas"),p=n("#canvasBackground"),g=a(),h=[.01,.1,1,10,100,1e3],v=o.curConfig.showGrid||!1,n(l).hide().appendTo("body"),m=d.createElementNS(r.SVG,"svg"),u(m,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"}),p.append(m),f=d.createElementNS(r.SVG,"defs"),w=d.createElementNS(r.SVG,"pattern"),u(w,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100}),b=d.createElementNS(r.SVG,"image"),u(b,{x:0,y:0,width:100,height:100}),w.append(b),f.append(w),n("#canvasGrid").append(f),_=d.createElementNS(r.SVG,"rect"),u(_,{width:"100%",height:"100%",x:0,y:0,"stroke-width":0,stroke:"none",fill:"url(#gridpattern)",style:"pointer-events: none; display:visible;"}),n("#canvasGrid").append(_),S=[{id:"view_grid",icon:"grid.png",type:"context",panel:"editor_panel",events:{click:function click(){o.curConfig.showGrid=v=!v,G()}}}],x.abrupt("return",{name:c.name,svgicons:"grid-icon.xml",zoomChanged:function zoomChanged(e){v&&y(e)},callback:function callback(){v&&G()},buttons:c.buttons.map((function(e,t){return Object.assign(S[t],e)}))});case 28:case"end":return x.stop()}}),_callee)})))()}};export default e;
|
||
|
//# sourceMappingURL=ext-grid.js.map
|