summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/runtime.in
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/runtime.in')
-rw-r--r--Build/source/utils/asymptote/runtime.in96
1 files changed, 56 insertions, 40 deletions
diff --git a/Build/source/utils/asymptote/runtime.in b/Build/source/utils/asymptote/runtime.in
index b921b6217e2..ecaf3d61d31 100644
--- a/Build/source/utils/asymptote/runtime.in
+++ b/Build/source/utils/asymptote/runtime.in
@@ -962,9 +962,25 @@ inline triple perp(triple v, triple u)
return v-dot(v,u)*u;
}
-string ASYo="/ASYo {( ) print 12 string cvs print} bind def";
-string pathforall="{(M) print ASYo ASYo} {(L) print ASYo ASYo} {(C) print ASYo ASYo ASYo ASYo ASYo ASYo} {(c) print} pathforall";
-string currentpoint="print currentpoint ASYo ASYo ";
+string ASYx="/ASYx {( ) print ASYX sub 12 string cvs print} bind def";
+string ASYy="/ASYy {( ) print ASYY sub 12 string cvs print} bind def";
+string pathforall="{(M) print ASYy ASYx} {(L) print ASYy ASYx} {(C) print ASYy ASYx ASYy ASYx ASYy ASYx} {(c) print} pathforall";
+string currentpoint="print currentpoint ASYy ASYx ";
+string ASYinit="/ASYX currentpoint pop def /ASYY currentpoint exch pop def ";
+string ASY1="ASY1 {"+ASYinit+"/ASY1 false def} if ";
+
+void showpath(std::ofstream& ps)
+{
+ ps << ASYx << newl
+ << ASYy << newl
+ << "/ASY1 true def" << newl
+ << "/fill {" << ASY1
+ << pathforall << " (M) " << currentpoint
+ << "currentpoint newpath moveto } bind def" << newl
+ << "/stroke {" << ASY1 << "strokepath "
+ << pathforall << " (M) " << currentpoint
+ << "currentpoint newpath moveto } bind def" << endl;
+}
array *readpath(const string& psname, bool keep,
double hscale=1.0, double vscale=1.0)
@@ -995,7 +1011,6 @@ array *readpath(const string& psname, bool keep,
bool cyclic=false;
bool active=false;
- pair offset;
while(!buf.eof()) {
char c;
buf >> c;
@@ -1023,13 +1038,13 @@ array *readpath(const string& psname, bool keep,
}
active=false;
cyclic=false;
- node.pre=node.point=readpair(buf,hscale,vscale)-offset;
+ node.pre=node.point=readpair(buf,hscale,vscale);
node.straight=false;
break;
}
case 'L':
{
- pair point=readpair(buf,hscale,vscale)-offset;
+ pair point=readpair(buf,hscale,vscale);
pair delta=(point-node.point)*third;
node.post=node.point+delta;
node.straight=true;
@@ -1041,9 +1056,9 @@ array *readpath(const string& psname, bool keep,
}
case 'C':
{
- pair point=readpair(buf,hscale,vscale)-offset;
- pair pre=readpair(buf,hscale,vscale)-offset;
- node.post=readpair(buf,hscale,vscale)-offset;
+ pair point=readpair(buf,hscale,vscale);
+ pair pre=readpair(buf,hscale,vscale);
+ node.post=readpair(buf,hscale,vscale);
node.straight=false;
nodes.push_back(node);
active=true;
@@ -1056,11 +1071,6 @@ array *readpath(const string& psname, bool keep,
cyclic=true;
break;
}
- case 'Z':
- {
- offset=readpair(buf,hscale,vscale);
- break;
- }
}
}
@@ -1272,6 +1282,26 @@ bool labels(picture *f)
return f->havelabels();
}
+realarray *texsize(string *s, pen p=CURRENTPEN)
+{
+ texinit();
+ processDataStruct &pd=processData();
+
+ string texengine=getSetting<string>("tex");
+ const char **abort=texabort(texengine);
+ setpen(pd.tex,texengine,p);
+
+ double width,height,depth;
+ if(!texbounds(width,height,depth,pd.tex,*s,abort,false,true))
+ return new array(0);
+
+ array *t=new array(3);
+ (*t)[0]=width;
+ (*t)[1]=height;
+ (*t)[2]=depth;
+ return t;
+}
+
patharray *_texpath(string *s, pen p=CURRENTPEN)
{
array *P=new array(0);
@@ -1290,18 +1320,19 @@ patharray *_texpath(string *s, pen p=CURRENTPEN)
if(!pdf) {
tex.verbatimline("\\special{ps:");
- tex.verbatimline(ASYo);
+ tex.verbatimline(ASYx);
+ tex.verbatimline(ASYy);
tex.verbatimline("/ASY1 true def");
- tex.verbatimline("/v {neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYo ASYo (L) print ASYo add ASYo (L) print add ASYo add ASYo (L) print add ASYo ASYo (c) print} bind def");
- tex.verbatimline("/show {ASY1 {(Z) "+currentpoint+
- "/ASY1 false def} if currentpoint newpath moveto false charpath "+
+ tex.verbatimline("/v {neg exch 4 copy 4 2 roll 2 copy 6 2 roll 2 copy (M) print ASYy ASYx (L) print ASYy add ASYx (L) print add ASYy add ASYx (L) print add ASYy ASYx (c) print} bind def");
+ tex.verbatimline("/show {"+ASY1+
+ "currentpoint newpath moveto false charpath "+
pathforall+"} bind def}");
}
tex.verbatimline(*s+"%");
tex.epilogue(true);
tex.close();
- // TODO: Put in common subproutine (cf. teprocess).
+ // TODO: Put in common subproutine (cf. texprocess).
string aux=auxname(prefix,"aux");
unlink(aux.c_str());
string program=texprogram();
@@ -1329,16 +1360,8 @@ patharray *_texpath(string *s, pen p=CURRENTPEN)
std::ofstream ps(psname.c_str());
if(!ps) cannotwrite(psname);
- ps << ASYo << newl
- << "/ASY1 true def" << newl
- << "/fill {ASY1 {(Z) " << currentpoint << "/ASY1 false def} if "
- << pathforall << " (M) " << currentpoint
- << "currentpoint newpath moveto } bind def" << newl
- << "/stroke {ASY1 {(Z) " << currentpoint
- << "/ASY1 false def} if strokepath "
- << pathforall << " (M) " << currentpoint
- << "currentpoint newpath moveto } bind def" << newl;
-
+ showpath(ps);
+
ostringstream cmd;
cmd << "'" << getSetting<string>("gs")
<< "' -q -dNOCACHE -dNOPAUSE -dBATCH";
@@ -1411,15 +1434,7 @@ patharray *textpath(string *s, pen p=CURRENTPEN)
std::ofstream ps(psname.c_str());
if(!ps) cannotwrite(psname);
- ps << ASYo << newl
- << "/ASY1 true def" << newl
- << "/fill {ASY1 {(Z) " << currentpoint << "/ASY1 false def} if "
- << pathforall << " (M) " << currentpoint
- << "currentpoint newpath moveto } bind def" << newl
- << "/stroke {ASY1 {(Z) " << currentpoint
- << "/ASY1 false def} if strokepath "
- << pathforall << " (M) " << currentpoint
- << "currentpoint newpath moveto } bind def" << endl;
+ showpath(ps);
ostringstream pipe;
pipe << getSetting<string>("textcommand") << " '" << textname << "'";
@@ -1470,8 +1485,9 @@ patharray *_strokepath(path g, pen p=CURRENTPEN)
bbox b;
psfile ps(psname,false);
ps.prologue(b);
- ps.verbatimline(ASYo);
- ps.verbatimline("/stroke {(Z) "+currentpoint+pathforall+"} bind def");
+ ps.verbatimline(ASYx);
+ ps.verbatimline(ASYy);
+ ps.verbatimline("/stroke {"+ASYinit+pathforall+"} bind def");
ps.resetpen();
ps.setpen(p);
ps.write(g);