12345678910111213 |
- /*
- * /MathJax/jax/output/SVG/autoload/menclose.js
- *
- * Copyright (c) 2009-2013 The MathJax Consortium
- *
- * Part of the MathJax library.
- * See http://www.mathjax.org for details.
- *
- * Licensed under the Apache License, Version 2.0;
- * you may not use this file except in compliance with the License.
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- */MathJax.Hub.Register.StartupHook("SVG Jax Ready",function(){var h=MathJax.ElementJax.mml,u=MathJax.OutputJax.SVG,e=u.BBOX;e.ELLIPSE=e.Subclass({type:"ellipse",removeable:!1,Init:function(e,m,f,k,c,a){null==a&&(a={});a.fill="none";c&&(a.stroke=c);a["stroke-width"]=k.toFixed(2).replace(/\.?0+$/,"");a.cx=Math.floor(f/2);a.cy=Math.floor((e+m)/2-m);a.rx=Math.floor((f-k)/2);a.ry=Math.floor((e+m-k)/2);this.SUPER(arguments).Init.call(this,a);this.w=this.r=f;this.h=this.H=e;this.d=this.D=m;this.l=0}});e.DLINE=e.Subclass({type:"line",removeable:!1,Init:function(e,m,f,k,c,a,b){null==b&&(b={});b.fill="none";c&&(b.stroke=c);b["stroke-width"]=k.toFixed(2).replace(/\.?0+$/,"");"up"==a?(b.x1=Math.floor(k/2),b.y1=Math.floor(k/2-m),b.x2=Math.floor(f-k/2),b.y2=Math.floor(e-k/2)):(b.x1=Math.floor(k/2),b.y1=Math.floor(e-k/2),b.x2=Math.floor(f-k/2),b.y2=Math.floor(k/2-m));this.SUPER(arguments).Init.call(this,b);this.w=this.r=f;this.h=this.H=e;this.d=this.D=m;this.l=0}});e.FPOLY=e.Subclass({type:"polygon",removeable:!1,Init:function(e,m,f){null==f&&(f={});m&&(f.fill=m);for(var k=[],c=1E8,a=c,b=-c,g=b,d=0,l=e.length;d<l;d++){var h=e[d][0],p=e[d][1];h>b&&(b=h);h<c&&(c=h);p>g&&(g=p);p<a&&(a=p);k.push(Math.floor(h)+","+Math.floor(p))}f.points=k.join(" ");this.SUPER(arguments).Init.call(this,f);this.w=this.r=b;this.h=this.H=g;this.d=this.D=-a;this.l=-c}});e.PPATH=e.Subclass({type:"path",removeable:!1,Init:function(e,h,f,k,c,a,b){null==b&&(b={});b.fill="none";a&&(b.stroke=a);b["stroke-width"]=c.toFixed(2).replace(/\.?0+$/,"");b.d=k;this.SUPER(arguments).Init.call(this,b);this.w=this.r=f;this.h=this.H=e+h;this.d=this.D=this.l=0;this.y=-h}});h.menclose.Augment({toSVG:function(y,m){this.SVGgetStyles();var f=this.SVG();this.SVGhandleSpace(f);var k=this.SVGdataStretched(0,y,m),c=this.getValues("notation","thickness","padding","mathcolor","color");c.color&&!this.mathcolor&&(c.mathcolor=c.color);null==c.thickness&&(c.thickness=".075em");null==c.padding&&(c.padding=".2em");var a=this.SVGgetMu(f),b=this.SVGgetScale(),b=u.length2em(c.padding,a,1/u.em)*b,a=u.length2em(c.thickness,a,1/u.em),g=k.h+b+a,d=k.d+b+a,l=k.w+2*(b+a),w=MathJax.Hub.SplitList(c.notation),p=0,t,n,q,x,r=[!1,!1,!1,!1];c.mathcolor||(c.mathcolor="black");q=0;for(x=w.length;q<x;q++)switch(w[q]){case h.NOTATION.BOX:r=[!0,!0,!0,!0];break;case h.NOTATION.ROUNDEDBOX:f.Add(e.FRAME(g,d,l,a,"solid",c.mathcolor,{rx:Math.floor(Math.min(g+d-a,l-a)/4)}));break;case h.NOTATION.CIRCLE:f.Add(e.ELLIPSE(g,d,l,a,c.mathcolor));break;case h.NOTATION.ACTUARIAL:r[0]=!0;case h.NOTATION.RIGHT:r[1]=!0;break;case h.NOTATION.LEFT:r[3]=!0;break;case h.NOTATION.TOP:r[0]=!0;break;case h.NOTATION.BOTTOM:r[2]=!0;break;case h.NOTATION.VERTICALSTRIKE:f.Add(e.VLINE(g+d,a,"solid",c.mathcolor),(l-a)/2,-d);break;case h.NOTATION.HORIZONTALSTRIKE:f.Add(e.HLINE(l,a,"solid",c.mathcolor),0,(g+d-a)/2-d);break;case h.NOTATION.UPDIAGONALSTRIKE:if(this.arrow){n=1/Math.sqrt(l*l+(g+d)*(g+d))*10/u.em*a/.075;t=l*n;n*=g+d;var v=.4*n;f.Add(e.DLINE(g-.5*n,d,l-.5*t,a,c.mathcolor,"up"));f.Add(e.FPOLY([[v+t,n],[v-.4*n,.4*t],[v+.3*t,.3*n],[v+.4*n,-.4*t],[v+t,n]],c.mathcolor),l-t-v,g-n)}else f.Add(e.DLINE(g,d,l,a,c.mathcolor,"up"));break;case h.NOTATION.DOWNDIAGONALSTRIKE:f.Add(e.DLINE(g,d,l,a,c.mathcolor,"down"));break;case h.NOTATION.MADRUWB:r[1]=r[2]=!0;break;case h.NOTATION.RADICAL:f.Add(e.PPATH(g,d,l,"M "+this.SVGxy(a/2,.4*(g+d))+" L "+this.SVGxy(b,a/2)+" L "+this.SVGxy(2*b,g+d-a/2)+" L "+this.SVGxy(l,g+d-a/2),a,c.mathcolor),0,a);p=b;break;case h.NOTATION.LONGDIV:f.Add(e.PPATH(g,d,l,"M "+this.SVGxy(a/2,a/2)+" a "+this.SVGxy(b,(g+d)/2-2*a)+" 0 0,1 "+this.SVGxy(a/2,g+d-a)+" L "+this.SVGxy(l,g+d-a/2),a,c.mathcolor),0,a/2),p=b}g=[["H",l,0,g-a],["V",g+d,l-a,-d],["H",l,0,-d],["V",g+d,0,-d]];for(q=0;4>q;q++)r[q]&&(d=g[q],f.Add(e[d[0]+"LINE"](d[1],a,"solid",c.mathcolor),d[2],d[3]));f.Add(k,p+b+a,0,!1,!0);f.Clean();this.SVGhandleSpace(f);this.SVGhandleColor(f);this.SVGsaveData(f);return f},SVGxy:function(e,h){return Math.floor(e)+","+Math.floor(h)}});MathJax.Hub.Startup.signal.Post("SVG menclose Ready");MathJax.Ajax.loadComplete(u.autoloadDir+"/menclose.js")});
|