11 lines
3.0 KiB
JavaScript
11 lines
3.0 KiB
JavaScript
|
System.register([],(function(e,t){"use strict";return{execute:function(){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
|
||
|
*
|
||
|
*/
|
||
|
e("default",{name:"grid",init:function init(e){var n=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 r,a,o,i,c,s,u,d,l,g,p,h,v,m,f,w,b,y,_,S,G,x;return regeneratorRuntime.wrap((function _callee$(k){for(;;)switch(k.prev=k.next){case 0:return G=function _gridUpdate(){m&&S(u.getZoom()),r("#canvasGrid").toggle(m),r("#view_grid").toggleClass("push_button_pressed tool_button")},S=function _updateGrid(e){var t=h[i.curConfig.baseUnit]*e,n=100/t,r=1;v.some((function(e){return r=e,n<=e}));var a=r*t;g.width=a,g.height=a;var o=g.getContext("2d"),c=.5,s=a/10;o.globalAlpha=.2,o.strokeStyle=i.curConfig.gridColor;for(var d=1;d<10;d++){var l=Math.round(s*d)+.5;o.moveTo(l,a),o.lineTo(l,0),o.moveTo(a,l),o.lineTo(0,l)}o.stroke(),o.beginPath(),o.globalAlpha=.5,o.moveTo(c,a),o.lineTo(c,0),o.moveTo(a,c),o.lineTo(0,c),o.stroke();var p=g.toDataURL("image/png");y.setAttribute("width",a),y.setAttribute("height",a),y.parentNode.setAttribute("width",a),y.parentNode.setAttribute("height",a),u.setHref(y,p)},r=e.$,a=e.NS,o=e.getTypeMap,i=n,k.next=6,t.import("./locale/".concat(i.curPrefs.lang,".js"));case 6:return c=k.sent,s=c.default,u=i.canvas,d=document.getElementById("svgcanvas").ownerDocument,l=u.assignAttributes,g=document.createElement("canvas"),p=r("#canvasBackground"),h=o(),v=[.01,.1,1,10,100,1e3],m=i.curConfig.showGrid||!1,r(g).hide().appendTo("body"),f=d.createElementNS(a.SVG,"svg"),l(f,{id:"canvasGrid",width:"100%",height:"100%",x:0,y:0,overflow:"visible",display:"none"}),p.append(f),w=d.createElementNS(a.SVG,"defs"),b=d.createElementNS(a.SVG,"pattern"),l(b,{id:"gridpattern",patternUnits:"userSpaceOnUse",x:0,y:0,width:100,height:100}),y=d.createElementNS(a.SVG,"image"),l(y,{x:0,y:0,width:100,height:100}),b.append(y),w.append(b),r("#canvasGrid").append(w),_=d.createElementNS(a.SVG,"rect"),l(_,{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(_),x=[{id:"view_grid",icon:"grid.png",type:"context",panel:"editor_panel",events:{click:function click(){i.curConfig.showGrid=m=!m,G()}}}],k.abrupt("return",{name:s.name,svgicons:"grid-icon.xml",zoomChanged:function zoomChanged(e){m&&S(e)},callback:function callback(){m&&G()},buttons:s.buttons.map((function(e,t){return Object.assign(x[t],e)}))});case 28:case"end":return k.stop()}}),_callee)})))()}})}}}));
|