From: nico <nicolas.marsgui@libertysurf.fr>
Subject: Putting things over a figure
Date: Sun, 23 Apr 2006 20:23:46 +0200 [thread overview]
Message-ID: <ops8g31wy99niby6@localhost> (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
next reply other threads:[~2006-04-23 18:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-23 18:23 nico [this message]
2006-04-23 18:32 ` Hans Hagen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ops8g31wy99niby6@localhost \
--to=nicolas.marsgui@libertysurf.fr \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).