Asymptote FAQ - Section 7
Questions about programming
Asymptote compiles Asymptote commands into its own virtual machine
code. It then runs this pseudocode on a virtual machine to produce PostScript
code.
Frames are canvases for drawing in PostScript coordinates. While
working with frames directly is occasionally necessary for constructing
deferred drawing routines, pictures are usually more convenient to work with.
See Q8.8 `In MetaPost, it is possible to have a drawing remain the same size in
different pictures by defining a unit u
and explicitly multiply all the coordinates by
u
. Is there a better way to do this in Asymptote?'.
A path is a cubic spline with fixed endpoint conditions.
A guide is an unresolved cubic spline (list of cubic-spline nodes and
control points). A guide is like a path except that the computation of
the cubic spline is deferred until drawing time (when it is resolved into a
path); this allows two guides with free endpoint conditions to be joined
together smoothly.
You could write yourself a routine such as:
picture[] picture(int n) {
picture[] pic;
for(int i=0; i < n; ++i) {
pic[i]=new picture;
size(pic[i],19cm,0);
}
return pic;
}
picture[] pic=picture(6);
Generic types aren't yet implemented.
But for now you can at least say
typedef string T;
include F;
typedef real T;
include F;
where F.asy
contains some type-dependent code like
T[] operator $(T A, T B) {return new T[] {A,B};}
Asymptote does not support forward declaration of types. You can,
however, nest structures, so that both types are visible for parts of the
bodies of both structure definitions. For example:
struct B {
typedef void someroutine(B b);
static struct A {
someroutine routine;
void init(someroutine routine) {
this.routine=routine;
}
}
A a=new A;
string test="Testing";
}
typedef B.A A;
A operator init() {return new A;}
B operator init() {return new B;}
A a;
a.init(new void(B b){write(b.test);});
B b;
a.routine(b);
Yes, Asymptote includes a line-based debugger:
http://asymptote.sourceforge.net/doc/Debugger
Yes, in fact we would prefer that users submit patches for customized
features, instead of relying on us to do all of the coding. Development will
proceed faster that way.
Next: Questions about differences between Asymptote and MetaPost.
Back: Questions about 2D graphs.
Return to contents.
Asymptote
- 01 November 2006
Extracted from Asymptote Frequently Asked Questions,
Copyright © 2006 .