* Putting things over a figure
@ 2006-04-23 18:23 nico
2006-04-23 18:32 ` Hans Hagen
0 siblings, 1 reply; 2+ messages in thread
From: nico @ 2006-04-23 18:23 UTC (permalink / raw)
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
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Putting things over a figure
2006-04-23 18:23 Putting things over a figure nico
@ 2006-04-23 18:32 ` Hans Hagen
0 siblings, 0 replies; 2+ messages in thread
From: Hans Hagen @ 2006-04-23 18:32 UTC (permalink / raw)
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
-----------------------------------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-04-23 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-23 18:23 Putting things over a figure nico
2006-04-23 18:32 ` Hans Hagen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).