From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/27420 Path: news.gmane.org!not-for-mail From: nico Newsgroups: gmane.comp.tex.context Subject: Putting things over a figure Date: Sun, 23 Apr 2006 20:23:46 +0200 Message-ID: Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1145816487 24823 80.91.229.2 (23 Apr 2006 18:21:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 23 Apr 2006 18:21:27 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 23 20:21:24 2006 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from ronja.vet.uu.nl ([131.211.172.88] helo=ronja.ntg.nl) by ciao.gmane.org with esmtp (Exim 4.43) id 1FXjCt-0008Pv-Gk for gctc-ntg-context-518@m.gmane.org; Sun, 23 Apr 2006 20:21:15 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id A2691127A1; Sun, 23 Apr 2006 20:21:14 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22810-06-3; Sun, 23 Apr 2006 20:21:09 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 421951279B; Sun, 23 Apr 2006 20:21:09 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 513781279B for ; Sun, 23 Apr 2006 20:21:08 +0200 (CEST) Original-Received: from ronja.ntg.nl ([127.0.0.1]) by localhost (smtp.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 22810-06-2 for ; Sun, 23 Apr 2006 20:21:07 +0200 (CEST) Original-Received: from swip.net (mailfe05.tele2.fr [212.247.154.140]) by ronja.ntg.nl (Postfix) with SMTP id 7A9DD12791 for ; Sun, 23 Apr 2006 20:21:07 +0200 (CEST) X-T2-Posting-ID: 3brHPWvyEzVNt0QNlxQWsxGJRDYe7rueGgqwO1zxZAg= X-Cloudmark-Score: 0.000000 [] Original-Received: from [83.179.197.37] (HELO localhost) by mailfe05.swip.net (CommuniGate Pro SMTP 5.0.8) with ESMTP id 83111253 for ntg-context@ntg.nl; Sun, 23 Apr 2006 20:21:06 +0200 Original-To: "mailing list for ConTeXt users" User-Agent: Opera M2/7.54 (FreeBSD, build 955) X-Virus-Scanned: amavisd-new at ntg.nl X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.7 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: ntg-context-bounces@ntg.nl Errors-To: ntg-context-bounces@ntg.nl X-Virus-Scanned: amavisd-new at ntg.nl Xref: news.gmane.org gmane.comp.tex.context:27420 Archived-At: 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