mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Math
synced 2024-12-03 11:46:29 +00:00
17 lines
4.5 KiB
JavaScript
17 lines
4.5 KiB
JavaScript
/*
|
|
* /MathJax/jax/output/SVG/autoload/menclose.js
|
|
*
|
|
* Copyright (c) 2012 Design Science, Inc.
|
|
*
|
|
* 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 c="2.0";var a=MathJax.ElementJax.mml,d=MathJax.OutputJax.SVG,b=d.BBOX;b.ELLIPSE=b.Subclass({type:"ellipse",removeable:false,Init:function(i,k,e,g,f,j){if(j==null){j={}}j.fill="none";if(f){j.stroke=f}j["stroke-width"]=g.toFixed(2).replace(/\.?0+$/,"");j.cx=Math.floor(e/2);j.cy=Math.floor((i+k)/2-k);j.rx=Math.floor((e-g)/2);j.ry=Math.floor((i+k-g)/2);this.SUPER(arguments).Init.call(this,j);this.w=this.r=e;this.h=this.H=i;this.d=this.D=k;this.l=0}});b.DLINE=b.Subclass({type:"line",removeable:false,Init:function(i,l,e,g,f,j,k){if(k==null){k={}}k.fill="none";if(f){k.stroke=f}k["stroke-width"]=g.toFixed(2).replace(/\.?0+$/,"");if(j=="up"){k.x1=Math.floor(g/2);k.y1=Math.floor(g/2-l);k.x2=Math.floor(e-g/2);k.y2=Math.floor(i-g/2)}else{k.x1=Math.floor(g/2);k.y1=Math.floor(i-g/2);k.x2=Math.floor(e-g/2);k.y2=Math.floor(g/2-l)}this.SUPER(arguments).Init.call(this,k);this.w=this.r=e;this.h=this.H=i;this.d=this.D=l;this.l=0}});b.FPOLY=b.Subclass({type:"polygon",removeable:false,Init:function(p,g,e){if(e==null){e={}}if(g){e.fill=g}var j=[],o=100000000,n=o,r=-o,q=r;for(var h=0,f=p.length;h<f;h++){var l=p[h][0],k=p[h][1];if(l>r){r=l}if(l<o){o=l}if(k>q){q=k}if(k<n){n=k}j.push(Math.floor(l)+","+Math.floor(k))}e.points=j.join(" ");this.SUPER(arguments).Init.call(this,e);this.w=this.r=r;this.h=this.H=q;this.d=this.D=-n;this.l=-o}});b.PPATH=b.Subclass({type:"path",removeable:false,Init:function(i,l,e,k,g,f,j){if(j==null){j={}}j.fill="none";if(f){j.stroke=f}j["stroke-width"]=g.toFixed(2).replace(/\.?0+$/,"");j.d=k;this.SUPER(arguments).Init.call(this,j);this.w=this.r=e;this.h=this.H=i+l;this.d=this.D=this.l=0;this.y=-l}});a.menclose.Augment({toSVG:function(C,G){this.SVGgetStyles();var z=this.SVG();this.SVGhandleSpace(z);var o=this.SVGdataStretched(0,C,G);var g=this.getValues("notation","thickness","padding","mathcolor","color");if(g.color&&!this.mathcolor){g.mathcolor=g.color}if(g.thickness==null){g.thickness=".075em"}if(g.padding==null){g.padding=".2em"}var A=this.SVGgetMu(z),M=this.SVGgetScale();var B=d.length2em(g.padding,A,1/d.em)*M;var v=d.length2em(g.thickness,A,1/d.em)*M;var r=o.h+B+v,y=o.d+B+v,j=o.w+2*(B+v);var k=g.notation.split(/ /);var u=0,s,J,I,E,n=[false,false,false,false];if(!g.mathcolor){g.mathcolor="black"}for(I=0,E=k.length;I<E;I++){switch(k[I]){case a.NOTATION.BOX:n=[true,true,true,true];break;case a.NOTATION.ROUNDEDBOX:z.Add(b.FRAME(r,y,j,v,"solid",g.mathcolor,{rx:Math.floor(Math.min(r+y-v,j-v)/4)}));break;case a.NOTATION.CIRCLE:z.Add(b.ELLIPSE(r,y,j,v,g.mathcolor));break;case a.NOTATION.ACTUARIAL:n[0]=true;case a.NOTATION.RIGHT:n[1]=true;break;case a.NOTATION.LEFT:n[3]=true;break;case a.NOTATION.TOP:n[0]=true;break;case a.NOTATION.BOTTOM:n[2]=true;break;case a.NOTATION.VERTICALSTRIKE:z.Add(b.VLINE(r+y,v,"solid",g.mathcolor),(j-v)/2,-y);break;case a.NOTATION.HORIZONTALSTRIKE:z.Add(b.HLINE(j,v,"solid",g.mathcolor),0,(r+y-v)/2-y);break;case a.NOTATION.UPDIAGONALSTRIKE:if(this.arrow){var F=Math.sqrt(j*j+(r+y)*(r+y)),K=1/F*10/d.em*v/0.075;s=j*K;J=(r+y)*K;var q=0.4*J;z.Add(b.DLINE(r-0.5*J,y,j-0.5*s,v,g.mathcolor,"up"));z.Add(b.FPOLY([[q+s,J],[q-0.4*J,0.4*s],[q+0.3*s,0.3*J],[q+0.4*J,-0.4*s],[q+s,J]],g.mathcolor),j-s-q,r-J)}else{z.Add(b.DLINE(r,y,j,v,g.mathcolor,"up"))}break;case a.NOTATION.DOWNDIAGONALSTRIKE:z.Add(b.DLINE(r,y,j,v,g.mathcolor,"down"));break;case a.NOTATION.MADRUWB:n[1]=n[2]=true;break;case a.NOTATION.RADICAL:z.Add(b.PPATH(r,y,j,"M "+this.SVGxy(v/2,0.4*(r+y))+" L "+this.SVGxy(B,v/2)+" L "+this.SVGxy(2*B,r+y-v/2)+" L "+this.SVGxy(j,r+y-v/2),v,g.mathcolor),0,v);u=B;break;case a.NOTATION.LONGDIV:z.Add(b.PPATH(r,y,j,"M "+this.SVGxy(v/2,v/2)+" a "+this.SVGxy(B,(r+y)/2-2*v)+" 0 0,1 "+this.SVGxy(v/2,r+y-v)+" L "+this.SVGxy(j,r+y-v/2),v,g.mathcolor),0,v/2);u=B;break}}var L=[["H",j,0,r-v],["V",r+y,j-v,-y],["H",j,0,-y],["V",r+y,0,-y]];for(I=0;I<4;I++){if(n[I]){var e=L[I];z.Add(b[e[0]+"LINE"](e[1],v,"solid",g.mathcolor),e[2],e[3])}}z.Add(o,u+B+v,0,false,true);z.Clean();this.SVGhandleSpace(z);this.SVGhandleColor(z);this.SVGsaveData(z);return z},SVGxy:function(e,f){return Math.floor(e)+","+Math.floor(f)}});MathJax.Hub.Startup.signal.Post("SVG menclose Ready");MathJax.Ajax.loadComplete(d.autoloadDir+"/menclose.js")});
|
|
|