ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: Putting things over a figure
Date: Sun, 23 Apr 2006 20:32:06 +0200	[thread overview]
Message-ID: <444BC826.5050206@wxs.nl> (raw)
In-Reply-To: <ops8g31wy99niby6@localhost>

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
-----------------------------------------------------------------

      reply	other threads:[~2006-04-23 18:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-23 18:23 nico
2006-04-23 18:32 ` Hans Hagen [this message]

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=444BC826.5050206@wxs.nl \
    --to=pragma@wxs.nl \
    --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).