@zklogic/draw.io
Version:
Draw.IO - Graph Editor integration in Angular-cli
1 lines • 4.36 kB
JavaScript
MathJax.Hub.Register.StartupHook("SVG Jax Ready",(function(){var t=MathJax.ElementJax.mml,a=MathJax.OutputJax.SVG,o=a.BBOX;o.ELLIPSE=o.Subclass({type:"ellipse",removeable:!1,Init:function(t,a,o,h,e,s){null==s&&(s={}),s.fill="none",e&&(s.stroke=e),s["stroke-width"]=h.toFixed(2).replace(/\.?0+$/,""),s.cx=Math.floor(o/2),s.cy=Math.floor((t+a)/2-a),s.rx=Math.floor((o-h)/2),s.ry=Math.floor((t+a-h)/2),this.SUPER(arguments).Init.call(this,s),this.w=this.r=o,this.h=this.H=t,this.d=this.D=a,this.l=0}}),o.DLINE=o.Subclass({type:"line",removeable:!1,Init:function(t,a,o,h,e,s,i){null==i&&(i={}),i.fill="none",e&&(i.stroke=e),i["stroke-width"]=h.toFixed(2).replace(/\.?0+$/,""),"up"==s?(i.x1=Math.floor(h/2),i.y1=Math.floor(h/2-a),i.x2=Math.floor(o-h/2),i.y2=Math.floor(t-h/2)):(i.x1=Math.floor(h/2),i.y1=Math.floor(t-h/2),i.x2=Math.floor(o-h/2),i.y2=Math.floor(h/2-a)),this.SUPER(arguments).Init.call(this,i),this.w=this.r=o,this.h=this.H=t,this.d=this.D=a,this.l=0}}),o.FPOLY=o.Subclass({type:"polygon",removeable:!1,Init:function(t,a,o){null==o&&(o={}),a&&(o.fill=a);for(var h=[],e=1e8,s=e,i=-e,l=i,r=0,n=t.length;r<n;r++){var c=t[r][0],O=t[r][1];c>i&&(i=c),c<e&&(e=c),O>l&&(l=O),O<s&&(s=O),h.push(Math.floor(c)+","+Math.floor(O))}o.points=h.join(" "),this.SUPER(arguments).Init.call(this,o),this.w=this.r=i,this.h=this.H=l,this.d=this.D=-s,this.l=-e}}),o.PPATH=o.Subclass({type:"path",removeable:!1,Init:function(t,a,o,h,e,s,i){null==i&&(i={}),i.fill="none",s&&(i.stroke=s),i["stroke-width"]=e.toFixed(2).replace(/\.?0+$/,""),i.d=h,this.SUPER(arguments).Init.call(this,i),this.w=this.r=o,this.h=this.H=t+a,this.d=this.D=this.l=0,this.y=-a}}),t.menclose.Augment({toSVG:function(h,e){this.SVGgetStyles();var s=this.SVG(),i=this.SVGgetScale(s);this.SVGhandleSpace(s);var l=this.SVGdataStretched(0,h,e),r=this.getValues("notation","thickness","padding","mathcolor","color");r.color&&!this.mathcolor&&(r.mathcolor=r.color),null==r.thickness&&(r.thickness=".075em"),null==r.padding&&(r.padding=".2em");var n=this.SVGgetMu(s),c=a.length2em(r.padding,n,1/a.em)*i,O=a.length2em(r.thickness,n,1/a.em);O=Math.max(1/a.em,O);var d,A,N,I,T=l.h+c+O,S=l.d+c+O,m=l.w+2*(c+O),u=0,f=[!1,!1,!1,!1],L=MathJax.Hub.SplitList(r.notation),M={};for(N=0,I=L.length;N<I;N++)M[L[N]]=!0;for(var x in M[t.NOTATION.UPDIAGONALARROW]&&(M[t.NOTATION.UPDIAGONALSTRIKE]=!1),M)if(M.hasOwnProperty(x)&&M[x])switch(x){case t.NOTATION.BOX:f=[!0,!0,!0,!0];break;case t.NOTATION.ROUNDEDBOX:s.Add(o.FRAME(T,S,m,O,"solid",r.mathcolor,{rx:Math.floor(Math.min(T+S-O,m-O)/4)}));break;case t.NOTATION.CIRCLE:s.Add(o.ELLIPSE(T,S,m,O,r.mathcolor));break;case t.NOTATION.ACTUARIAL:f[0]=!0;case t.NOTATION.RIGHT:f[1]=!0;break;case t.NOTATION.LEFT:f[3]=!0;break;case t.NOTATION.TOP:f[0]=!0;break;case t.NOTATION.BOTTOM:f[2]=!0;break;case t.NOTATION.VERTICALSTRIKE:s.Add(o.VLINE(T+S,O,"solid",r.mathcolor),(m-O)/2,-S);break;case t.NOTATION.HORIZONTALSTRIKE:s.Add(o.HLINE(m,O,"solid",r.mathcolor),0,(T+S-O)/2-S);break;case t.NOTATION.UPDIAGONALSTRIKE:s.Add(o.DLINE(T,S,m,O,r.mathcolor,"up"));break;case t.NOTATION.UPDIAGONALARROW:var G=1/Math.sqrt(m*m+(T+S)*(T+S))*10/a.em*O/.075;d=m*G;var p=.4*(A=(T+S)*G);s.Add(o.DLINE(T-.5*A,S,m-.5*d,O,r.mathcolor,"up")),s.Add(o.FPOLY([[p+d,A],[p-.4*A,.4*d],[p+.3*d,.3*A],[p+.4*A,-.4*d],[p+d,A]],r.mathcolor),m-d-p,T-A);break;case t.NOTATION.DOWNDIAGONALSTRIKE:s.Add(o.DLINE(T,S,m,O,r.mathcolor,"down"));break;case t.NOTATION.PHASORANGLE:f[2]=!0,m-=2*c,m+=c=(T+S)/2,s.Add(o.DLINE(T,S,c,O,r.mathcolor,"up"));break;case t.NOTATION.MADRUWB:f[1]=f[2]=!0;break;case t.NOTATION.RADICAL:s.Add(o.PPATH(T,S,m,"M "+this.SVGxy(O/2,.4*(T+S))+" L "+this.SVGxy(c,O/2)+" L "+this.SVGxy(2*c,T+S-O/2)+" L "+this.SVGxy(m,T+S-O/2),O,r.mathcolor),0,O),u=c;break;case t.NOTATION.LONGDIV:s.Add(o.PPATH(T,S,m,"M "+this.SVGxy(O/2,O/2)+" a "+this.SVGxy(c,(T+S)/2-2*O)+" 0 0,1 "+this.SVGxy(O/2,T+S-O)+" L "+this.SVGxy(m,T+S-O/2),O,r.mathcolor),0,O/2),u=c}var E=[["H",m,0,T-O],["V",T+S,m-O,-S],["H",m,0,-S],["V",T+S,0,-S]];for(N=0;N<4;N++)if(f[N]){var V=E[N];s.Add(o[V[0]+"LINE"](V[1],O,"solid",r.mathcolor),V[2],V[3])}return s.Add(l,u+c+O,0,!1,!0),s.Clean(),this.SVGhandleSpace(s),this.SVGhandleColor(s),this.SVGsaveData(s),s},SVGxy:function(t,a){return Math.floor(t)+","+Math.floor(a)}}),MathJax.Hub.Startup.signal.Post("SVG menclose Ready"),MathJax.Ajax.loadComplete(a.autoloadDir+"/menclose.js")}));