i give a first look to metaobj package and i try to define a triangle (almost as in the manual). So here's the EDIT (fpast request) code :
input metaobj;
vardef newTriangle@# text options=
ExecuteOptions(@#)(options);
assignObj(@#,"Triangle");
StandardInterface;
%%
forsuffixes $ = suba,subb,subc :
save $;
string $;
$ = newobjstring_;
ObjPoint $;
SubObject($,obj($));
endfor;
%
ObjCode StandardEquations,
"obj(@#subb) - obj(@#suba) = (5cm,0)",
"obj(@#subc) - obj(@#subb) = (0,3cm)",
"obj(@#subc) = (obj(@#suba)+obj(@#subb)+obj(@#subc)) / 3",
"@#ne = obj(@#subc)";
StandardTies;
enddef;
vardef drawTriangle (suffix n) =
draw obj(n.suba)--obj(n.subb)--obj(n.subc)--cycle;
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
vardef newTrianglee@# text options =
ExecuteOptions(@#)(options);
assignObj(@#,"Trianglee");
StandardInterface;
ObjPoint c,sa,sb,sc;
ObjCode StandardEquations,
"@#sb - @#sa = (5cm,0)",
"@#sc - @#sb = (0,3cm)",
"@#c = (@#sa+@#sb+@#sc) / 3",
"@#ne = @#sc";
StandardTies;
enddef;
vardef drawTrianglee (suffix s) =
draw s.sa--s.sb--s.sc--cycle;
enddef;
%%% error ... or not
test = 0;
beginfig(1);
if test=1 :
newTriangle.u
else :
newTrianglee.u
fi;
u.c = origin;
drawObj(u)
endfig;
end
But the compilation returns :
******* metaobj 0.93 (c) D. Roegel (2006/12/03) *******
)
>> -_______a+_______b
>> (141.73225,0)
! Equation cannot be performed (numeric=pair).
<to be read again>
;
code_function_->...bb)-obj((SUFFIX2)suba)=(5cm,0);
obj((SUFFIX2)subc)-obj((SU...
<to be read again>
etc.
The code actually works if i do not use ObjPoint as subobjects so i guess this is the problem. But i can't figure out why ?
Thanks fo any help
Edit i noticed i've forgot StandardEquations
in ObjCode
command but truth is out there...
Edit 2 edit code (fpast request) : choose test=0
for successfull compilation with object Trianglee and test=1
fo failed compilation