I want to use MetaObj to arrange some diagrams. I have some nice, color MetaPost drawings of components for my diagrams.
I create the picture objects like this:
input metaobj;
def picphone =
begingroup;
save pic;
picture pic;
pic := image(
% lots of drawing commands generated by pstoedit
drawoptions(); % <-- I added this
);
pic
endgroup
enddef
beginfig(1);
begingroup;
picture phone;
phone := picphone scaled 0.1;
newBox.alfa(phone);
newBox.bravo(phone);
%
% equations for positioning
%
drawObj(alfa);
drawObj(bravo);
endgroup;
endfig;
I expected to see my beautiful phones, but instead saw black rectangles. A little log reading made me realize that pictures inside MetaObj Box objects are drawn with this vardef:
vardef drawPicture@#(suffix p) text options=
draw @#p transformed @#ctransform_ shifted @#p.off options
withcolor OptionValue.@#("picturecolor");
enddef;
which basically turns into draw ... withcolor black
.
So, I changed metaobj.mp (a copy in a local subdirectory) to be this:
vardef drawPicture@#(suffix p) text options=
draw @#p transformed @#ctransform_ shifted @#p.off options
if boolean OptionValue.@#("picturecolor") :
;
else:
withcolor OptionValue.@#("picturecolor");
fi;
enddef;
and I added this:
setObjectDefaultOption("Box")("picturecolor")(false);
to my file.
Is there a way I could have done this without modifying metaobj.mp? Am I misusing (abusing?) MetaObj? Should I use something different to lay out my objects?
[Aside: I'm even more of a MetaPost novice than I am a TeX one, so please forgive any foolishness I've exhibited.]