On Wed, 4 Nov 2009, batela wrote:
Another incompatibility between metapost and mkiv.
I try to run this code but i found a error with some garbage.
Please try to run the file in attach. The error coming from the curvelabel
function.
* Change # to \#.
* Don't redefine pt!
See the attached file.
Aditya
\starttext
\startMPcode
path Cb[];
vardef courbe[](expr a,b,nb)(text texte)=
path $;
for i:=0 upto nb :
x...@[i]:=(a+i*(b-a)/nb);
x:=...@[i];
y...@[i]:=texte;
endfor ;
Cb@:=(x...@.0*x.u,y...@.0*y.u)
for i:=1 upto nb :
..(x...@[i]*x.u,y...@[i]*y.u)
endfor;
Cb@:=Cb@ shifted (z.origine*cm);
$=Cb@;
$
enddef;
vardef cadre(expr q,r)=
z.so=q;
z.ne=r;
path limite;
limite:=z.so*cm--(x.ne*cm,y.so*cm)--z.ne*cm--(x.so*cm,y.ne*cm)--cycle;
extra_endfig := "clip currentpicture to limite;" & extra_endfig;
enddef;
vardef origine(expr p)=
x.origine=xpart(p);
y.origine=ypart(p);
enddef;
vardef unites(expr q,r)=
x.u:=q*cm;
y.u:=r*cm;
enddef;
vardef depart(expr q,r,p,s,t)=
cadre(q,r);
origine(p);
unites(s,t);
enddef;
vardef origine(expr p)=
x.origine=xpart(p);
y.origine=ypart(p);
enddef;
vardef unites(expr q,r)=
x.u:=q*cm;
y.u:=r*cm;
enddef;
vardef curvela...@\#(expr a)(suffix pos)=
save se;
picture se;
numeric t;
%show a;
pair pp,tangent;
if str pos ="" :
t:=0.5*length c...@\#
else :
t:=pos*length c...@\#;
%show t;
fi;
pp:=point t of c...@\#;
tangent:=unitvector(direction t of c...@\#);
se=image(
label(a rotated angle(tangent), pp+2mm*(tangent rotated 90));
);
se
enddef;
depart((-3,-3.5),(2.5,3.5),(0,0),2,2);
draw courbe1(-1,1,100,x*x) withcolor blue;
draw curvelabel1(btex $x^2$ etex, 0.9);
\stopMPcode
\stoptext
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________