Dear all,
First, Happy New Year!
I tried to draw a small figure using the following MetaFun code.
The problem is the last line.
If I run \processMPbuffer[sampleGraph] then it works well and draw the figure.
But, if I add another buffer name like
\processMPbuffer[sampleGraph, edgeLabel]
Or
\processMPbuffer[sampleGraph, multiGraph]
Then an error occurred. In the log file, I found that
metafun > log > error: Not implemented: (pair)*(color)
metafun > log >
metapost > trace > <error> (0.30901699437494745,0.95105651629515353)
metapost > trace > <to be read again> ;
metapost > trace > <for(1)> z [ (EXPR 0) ] = dir ( 360 * (EXPR 0) / (5)
+ (0) ) * ((0,0,0)) ; ENDFOR
As you see here, 'mySize = (0,0,0)' not ‘2cm'.
I don’t see what is the problem.
Thank you for your reading.
Best wishes,
Dalyoung
\startMPinitializations
path p,q,r;
numeric u, size; u := 1cm;
color myColor[];
picture pic[];
def setPoints(expr n,size,rot) =
z[0] = origin;
for i = 1 upto n:
z[i] = dir(360*i/n+rot)*size;
endfor;
enddef;
def labelPoints (text m)(expr ss) =
numeric kk; kk :=0;
for i = m:
freedotlabel(textext("$"& substring(kk,kk+1) of ss &"$"),z[i],origin);
kk := kk + 1;
endfor;
enddef;
\stopMPinitializations
\startbuffer[sampleGraph]
setPoints(5,\MPvar{mySize},0);
labelPoints(1,2,3,4,5)("uvwxy");
draw z1--z2--z3--z4--z5--z1--z3 withpen pencircle scaled 1.2pt;
\stopbuffer
\startbuffer[edgeLabel]
label.ulft(textext("$e_1$"),.5(z1+z2));
label.lft(textext("$e_2$"),.5(z2+z3));
label.bot(textext("$e_3$"),.5(z3+z4));
label.rt(textext("$e_4$"),.5(z4+z5));
label.rt(textext("$e_5$"),.5(z5+z1));
\stopbuffer
\startbuffer[multiGraph]
draw z2{dir(225)}..{dir(330)}z3 withcolor darkred;
draw z4{dir(210)}..(z4+.9*down*u)..{dir(210)}z4 withcolor darkred;
\stopbuffer
\starttext
\setupMPvariables[sampleGraph][mySize=3cm]
\processMPbuffer[sampleGraph,multiGraph]
\stoptext___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________