From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/27423 Path: news.gmane.org!not-for-mail From: Hans Hagen Newsgroups: gmane.comp.tex.context Subject: Re: Putting things over a figure Date: Sun, 23 Apr 2006 20:32:06 +0200 Message-ID: <444BC826.5050206@wxs.nl> References: 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 1145817146 26682 80.91.229.2 (23 Apr 2006 18:32:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 23 Apr 2006 18:32:26 +0000 (UTC) Original-X-From: ntg-context-bounces@ntg.nl Sun Apr 23 20:32:23 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 1FXjNY-0001cW-EC for gctc-ntg-context-518@m.gmane.org; Sun, 23 Apr 2006 20:32:16 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 39A00127B5; Sun, 23 Apr 2006 20:32:16 +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 23858-02-5; Sun, 23 Apr 2006 20:32:12 +0200 (CEST) Original-Received: from ronja.vet.uu.nl (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id E6FD31279F; Sun, 23 Apr 2006 20:32:11 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by ronja.ntg.nl (Postfix) with ESMTP id 63B131279F for ; Sun, 23 Apr 2006 20:32:10 +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 23858-02-4 for ; Sun, 23 Apr 2006 20:32:09 +0200 (CEST) Original-Received: from mail.pragma-ade.net (dsl-212-84-128-085.solcon.nl [212.84.128.85]) by ronja.ntg.nl (Postfix) with SMTP id 9BD231279E for ; Sun, 23 Apr 2006 20:32:09 +0200 (CEST) Original-Received: from [10.100.1.102] (unverified [10.100.1.102]) by controller-1 (SurgeMail 3.5b3) with ESMTP id 13765 for ; Sun, 23 Apr 2006 22:32:09 +0400 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) Original-To: mailing list for ConTeXt users In-Reply-To: X-Server: High Performance Mail Server - http://surgemail.com r=-274017400 X-Authenticated-User: hagen@controller-1 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:27423 Archived-At: 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 -----------------------------------------------------------------