diff options
author | Karl Berry <karl@freefriends.org> | 2010-07-11 22:39:53 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-07-11 22:39:53 +0000 |
commit | 4e8485b0ddecb55f72929dd6233f254a1e7bf5b0 (patch) | |
tree | 354324ee6f54d46053b3ce88fe9dc4acf8e2ed81 /Build/source/utils/asymptote/base | |
parent | 713bb91ad0467fb3b12acad03cae2fa105ed2caa (diff) |
asy 2.02
git-svn-id: svn://tug.org/texlive/trunk@19378 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/utils/asymptote/base')
-rw-r--r-- | Build/source/utils/asymptote/base/animation.asy | 9 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/plain.asy | 24 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/plain_Label.asy | 1 | ||||
-rw-r--r-- | Build/source/utils/asymptote/base/plain_picture.asy | 43 |
4 files changed, 41 insertions, 36 deletions
diff --git a/Build/source/utils/asymptote/base/animation.asy b/Build/source/utils/asymptote/base/animation.asy index 582b32bced4..57e13ab6e03 100644 --- a/Build/source/utils/asymptote/base/animation.asy +++ b/Build/source/utils/asymptote/base/animation.asy @@ -132,12 +132,17 @@ struct animation { return s; } + bool pdflatex() + { + return latex() && pdf(); + } + string pdf(enclosure enclosure=NoBox, real delay=animationdelay, string options="", bool keep=settings.keep, bool multipage=true) { if(settings.inlinetex) multipage=true; if(!global) multipage=false; - if(settings.tex != "pdflatex") - abort("inline pdf animations require -tex pdflatex"); + if(!pdflatex()) + abort("inline pdf animations require -tex pdflatex or -tex xelatex"); if(settings.outformat != "") settings.outformat="pdf"; string filename=basename(); diff --git a/Build/source/utils/asymptote/base/plain.asy b/Build/source/utils/asymptote/base/plain.asy index 76f77aaf52c..e06bc66543c 100644 --- a/Build/source/utils/asymptote/base/plain.asy +++ b/Build/source/utils/asymptote/base/plain.asy @@ -187,22 +187,31 @@ void usersetting() eval(settings.user,true); } +string stripsuffix(string f, string suffix=".asy") +{ + int n=rfind(f,suffix); + if(n != -1) f=erase(f,n,-1); + return f; +} + // Conditionally process each file name in array s in a new environment. void asy(string format, bool overwrite=false ... string[] s) { for(string f : s) { - int n=rfind(f,".asy"); - if(n != -1) f=erase(f,n,-1); - if(overwrite || error(input(f+"."+format,check=false))) { + f=stripsuffix(f); + string suffix="."+format; + string fsuffix=f+suffix; + if(overwrite || error(input(fsuffix,check=false))) { string outformat=settings.outformat; bool interactiveView=settings.interactiveView; bool batchView=settings.batchView; settings.outformat=format; settings.interactiveView=false; settings.batchView=false; - delete(outname()+"_"+".aux"); - eval("defaultfilename=\""+f+"\"; import \""+f+ - "\" as dummy; exitfunction()"); + string outname=outname(); + delete(outname+"_"+".aux"); + eval("import \""+f+"\" as dummy"); + rename(stripsuffix(outname)+suffix,fsuffix); settings.outformat=outformat; settings.interactiveView=interactiveView; settings.batchView=batchView; @@ -210,7 +219,8 @@ void asy(string format, bool overwrite=false ... string[] s) } } -void beep() { +void beep() +{ write('\7',flush); } diff --git a/Build/source/utils/asymptote/base/plain_Label.asy b/Build/source/utils/asymptote/base/plain_Label.asy index 86d11f8acc0..623619f4a0c 100644 --- a/Build/source/utils/asymptote/base/plain_Label.asy +++ b/Build/source/utils/asymptote/base/plain_Label.asy @@ -625,6 +625,7 @@ path[] texpath(Label L, bool tex=settings.tex != "none", bool bbox=false) } path[] transform(path[] g, Label L) { + if(g.length == 0) return g; pair m=min(g); pair M=max(g); pair dir=rectify(inverse(L.T)*-L.align.dir); diff --git a/Build/source/utils/asymptote/base/plain_picture.asy b/Build/source/utils/asymptote/base/plain_picture.asy index 2ec467727d2..6764d885380 100644 --- a/Build/source/utils/asymptote/base/plain_picture.asy +++ b/Build/source/utils/asymptote/base/plain_picture.asy @@ -36,7 +36,6 @@ transform3 shiftless(transform3 t) // coordinates. struct coord { real user,truesize; - bool finite=true; // Build a coord. static coord build(real user, real truesize) { @@ -88,14 +87,13 @@ struct coords2 { void push(transform t, coords2 c1, coords2 c2) { for(int i=0; i < c1.x.length; ++i) { coord cx=c1.x[i], cy=c2.y[i]; - pair tinf=shiftless(t)*((finite(cx.user) ? 0 : 1), - (finite(cy.user) ? 0 : 1)); + pair tinf=shiftless(t)*(0,0); pair z=t*(cx.user,cy.user); pair w=(cx.truesize,cy.truesize); w=length(w)*unit(shiftless(t)*w); coord Cx,Cy; - Cx.user=(tinf.x == 0 ? z.x : infinity); - Cy.user=(tinf.y == 0 ? z.y : infinity); + Cx.user=z.x; + Cy.user=z.y; Cx.truesize=w.x; Cy.truesize=w.y; push(Cx,Cy); @@ -145,16 +143,14 @@ struct coords3 { void push(transform3 t, coords3 c1, coords3 c2, coords3 c3) { for(int i=0; i < c1.x.length; ++i) { coord cx=c1.x[i], cy=c2.y[i], cz=c3.z[i]; - triple tinf=shiftless(t)*((finite(cx.user) ? 0 : 1), - (finite(cy.user) ? 0 : 1), - (finite(cz.user) ? 0 : 1)); + triple tinf=shiftless(t)*(0,0,0); triple z=t*(cx.user,cy.user,cz.user); triple w=(cx.truesize,cy.truesize,cz.truesize); w=length(w)*unit(shiftless(t)*w); coord Cx,Cy,Cz; - Cx.user=(tinf.x == 0 ? z.x : infinity); - Cy.user=(tinf.y == 0 ? z.y : infinity); - Cz.user=(tinf.z == 0 ? z.z : infinity); + Cx.user=z.x; + Cy.user=z.y; + Cz.user=z.z; Cx.truesize=w.x; Cy.truesize=w.y; Cz.truesize=w.z; @@ -185,18 +181,13 @@ coord[] maxcoords(coord[] in, bool operator <= (coord,coord)) int n=in.length; - // Find the first finite restriction. - int first=0; - for(first=0; first < n; ++first) - if(finite(in[first].user)) break; - - if(first == n) + if(n == 0) return c; - else { - // Add the first coord without checking restrictions (as there are none). - best=in[first]; - c.push(best); - } + + int first=0; + // Add the first coord without checking restrictions (as there are none). + best=in[first]; + c.push(best); static int NONE=-1; @@ -234,7 +225,7 @@ coord[] maxcoords(coord[] in, bool operator <= (coord,coord)) void add(coord x) { - if(x <= best || !finite(x.user)) + if(x <= best) return; else { int i=dominator(x); @@ -957,7 +948,7 @@ struct picture { // Calculate the minimum point in scaling the coords. real min(real m, scaling s, coord[] c) { for(int i=0; i < c.length; ++i) - if(finite(c[i].user) && s.scale(c[i]) < m) + if(s.scale(c[i]) < m) m=s.scale(c[i]); return m; } @@ -965,7 +956,7 @@ struct picture { // Calculate the maximum point in scaling the coords. real max(real M, scaling s, coord[] c) { for(int i=0; i < c.length; ++i) - if(finite(c[i].user) && s.scale(c[i]) > M) + if(s.scale(c[i]) > M) M=s.scale(c[i]); return M; } @@ -1062,8 +1053,6 @@ struct picture { bool userzero=true; for(int i=0; i < coords.length; ++i) { if(coords[i].user != 0) userzero=false; - if(!finite(coords[i].user) || !finite(coords[i].truesize)) - abort("unbounded picture"); } if(userzero) return 1; warning("cannotfit","cannot fit picture to "+dir+"size "+(string) size |