nico wrote:
Hello,
I need a mechanism with which I can put several things (text, image) at a precise position over a figure. The position is expressed in percentage (x,y) of the figure dimensions. The lower-left corner is (0,0).
I did the following that works for my own needs, but maybe a higher level interface (layer?) could do the same. Any comment or improvement is
i'd go for layers
welcome.
\newdimen\overfigwd \newdimen\overfight
% Put the figure and define the x/y percentage factor for the calspairs. \def\startoverfig {\dodoubleempty\dostartoverfig}
\def\dostartoverfig[#1][#2]% {\bgroup \setbox\scratchbox\hbox{\externalfigure[#1][#2]}% \overfigwd=\wd\scratchbox \overfight=\ht\scratchbox \setuppositioning[unit=pt, xfactor=\withoutpt\the\dimexpr(\overfigwd/100), yfactor=\withoutpt\the\dimexpr(\overfight/100)]% \startpositioning \position(0,0){\box\scratchbox}}
\def\stopoverfig {\stoppositioning\egroup}
% Put (centered) at the position (x%,y%) on the figure. % The lower-left corner is (0,0) \def\calspair(#1,#2)#3% {\setbox0\hbox{#3}% \position[xoffset=\dimexpr(-\wd0/2), yoffset=\dimexpr(-\ht0/2)](#1,{\numexpr(100-#2)}){#3}}
%%
\setupcolors[state=start]
\starttext
\startoverfig[duck-small] \calspair(0,0){A} \calspair(100,100){B} \stopoverfig
\startoverfig[duck-small][width=4cm,frame=on] \calspair(0,0){A} \calspair(100,100){B} \calspair(50,50){\framed[background=color,backgroundcolor=green]{Hello}} \stopoverfig
\startoverfig[unknown] \calspair(30,0){A} \calspair(100,100){B} \stopoverfig
\stoptext
Regards, BG _______________________________________________ ntg-context mailing list ntg-context@ntg.nl http://www.ntg.nl/mailman/listinfo/ntg-context
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------