ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Hans Hagen <pragma@wxs.nl>
Subject: Re: MetaFun questions
Date: Fri, 07 Mar 2003 11:21:33 +0100	[thread overview]
Message-ID: <5.1.0.14.1.20030307104325.028ad398@server-1> (raw)
In-Reply-To: <20030306181611.04128fd5.morawski@gmx.net>

At 06:16 PM 3/6/2003 +0100, you wrote:

> > xysized(\MyFigWid,\MyFigHei)
>
>ahh, interesting. A plain metapost way as described in my other mail
>would be possible if i could run pdftex after the mpost run and run
>afterwards mpost again.
>How this could be done?

Currently we're making a bunch of tools that deal with graphics (a part of 
the example framework). It's not that hard to provide a mechanism that will 
write a file with data which is acceptable for metapost.

anyhow, here's a solution:

In cont-new.tex, add:

\def\showexternalfigured
   {\bgroup
    \immediate\openout\scratchwrite=mpfigs.mp
    \def\presetfigure[##1][##2]%
      {\getfiguredimensionsonly[##1]% \pagefigure[##1]%
       \immediate\write\scratchwrite
          {registerfigure("##1",\figurewidth,\figureheight)}}
    \pushendofline
    \readjobfile\@@exfile\donothing\donothing
    \popendofline
    \immediate\closeout\scratchwrite
    \egroup}

in texexec.pl, patch:

   [abc] into [abcd]

now you can run (in advance!):

   texexec *.png --pdf --fig=d

and get a file mpfigs.mp

copy the following code to mp-figs.mp:

pair figuredimensions[]; string figurenames[] ; numeric noffigures ;

noffigures := 0 ;

def registerfigure(expr name,width,height) =
   noffigures := noffigures + 1 ;
   figurenames[noffigures] := name ;
   figuredimensions[noffigures] := (width,height) ;
enddef ;

vardef figuredimensions(expr name) =
   save ok, i ; boolean ok ; numeric i ; i := 0 ; ok := false ;
   forever :
     i := i + 1 ; ok := (name = figurenames[i]) ; exitif ok ;
   endfor ;
   if ok : figuredimensions[i] else : origin fi
enddef ;

vardef figurewidth(expr name) =
   xpart figuredimensions(name)
enddef ;

vardef figureheight(expr name) =
   ypart figuredimensions(name)
enddef ;

end

and now you can say:

   input mp-figs.mp ;
   input mpfigs.mp ;

and voila:

   figurewidth("yourfig")

returns the width of the graphic

so: just one run in advance is needed

[just for testing; i'll think this over before i freeze/add it to context]

Hans

Hans

-------------------------------------------------------------------------
                                   Hans Hagen | PRAGMA ADE | pragma@wxs.nl
                       Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
  tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com
-------------------------------------------------------------------------
                        information: http://www.pragma-ade.com/roadmap.pdf
                     documentation: http://www.pragma-ade.com/showcase.pdf
-------------------------------------------------------------------------

  reply	other threads:[~2003-03-07 10:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-27 13:09 Jens-Uwe Morawski
2003-02-27 14:55 ` Hans Hagen
2003-02-27 19:05   ` Nigel King
2003-02-28  7:43     ` Hans Hagen
2003-02-28  9:17       ` Nigel King
2003-03-06 13:13         ` Hans Hagen
2003-03-06 17:16           ` Jens-Uwe Morawski
2003-03-07 10:21             ` Hans Hagen [this message]
2003-02-28 14:22   ` Jens-Uwe Morawski
2003-03-03 21:10     ` Hans Hagen
2003-03-06 18:10       ` Jens-Uwe Morawski

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=5.1.0.14.1.20030307104325.028ad398@server-1 \
    --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).