[dev-context] new mp feature
Hans Hagen
pragma at wxs.nl
Mon Jun 19 14:18:51 CEST 2006
Mojca Miklavec wrote:
> Not that I would really need to type in the following example, but if
> I didn't find something interesting, Hans would accuse me of not
> taking a look at it at all ;)
>
> \startMPpage
> draw (0,0)--(5cm,0);
> draw (0,0)--(5cm,5cm);
>
> picture p;
> p := \sometxt{\bTABLE
> \bTR\bTD abc\eTD\bTD xyz\eTD\eTR
> \bTR\bTD abc\eTD\bTD xyz\eTD\eTR
> \bTR\bTD abc\eTD\bTD xyz\eTD\eTR
> \eTABLE}; % or withcolor here
>
> draw p withcolor transparent(1,.5,red);
> \stopMPpage
>
> (To be honest I wanted to send the following example, but I didn't
> want to torture:
> %\startMPpage
> %draw \sometxt{
> % \startCSV
> % a b c
> % \stopCSV
> % } ;
> %\stopMPpage
> )
>
>
> General opinion: AMAZING speed, amazing feature! I love the fact that
> the labels are typest in the flow of the current document, so now
> macros defined earlier in the document may be used for labels as well.
> That's simply great! Also because of the fact that \def's refused to
> work inside of metafun graphics and no additional runs are needed.
>
> That's far more elegant and way more efficient that the way I would
> have to go for separating labels from \MPfigs
>
> Hans, that's marvellous! Thanks a lot!
>
> Mojca
>
>
> Just a side note: I noticed the new database module already in the
> beta, but the first Hans's fix (before Taco has touched it) introduced
> a new "tab-bug" which hasn't been quite resolved yet. If
> "separator=tab", it should trigger catcode change of tab to a "normal
> letter" and use that one for separating columns. Well, indeed it seems
> that the catcode is changed, but then I get the letter number 9 in EC
> font (macron) instead of going to new column.
so what patc is needed
>
> I'm now asking for impossible again, but: any simple/reasonable way to
> control the baseline/general positioning of the labels? (textext
> included text with baseline at y=0 by default, the new mechanism
> simply puts the lower corner to the baseline)
sign, the never satisfied mojca ... added:
[n] == nodepth
or shift over txtdepth
example:
\setupcolors[state=start]
\starttext
\startMPpage
draw (0,0)--(5cm,0);
draw (0,0)--(5cm,5cm);
picture p;
p := \sometxt{\bTABLE
\bTR\bTD abc\eTD\bTD xyz\eTD\eTR
\bTR\bTD abc\eTD\bTD xyz\eTD\eTR
\bTR\bTD abc\eTD\bTD xyz\eTD\eTR
\eTABLE} ;
draw p ;
draw \sometxt[n]{nodepth} ;
draw \sometxt{depth} ;
draw \sometxt{more and more depth} shifted (0,txtdepth) ;
\stopMPpage
\foundbox\currentTeXtext{1}
\stoptext
-----------------------------------------------------------------
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
-----------------------------------------------------------------
-------------- next part --------------
%D \module
%D [ file=mp-txts.mp,
%D version=2006.06.08,
%D title=\CONTEXT\ \METAPOST\ graphics,
%D subtitle=more text support,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
if unknown context_tool : input mp-tool ; fi ;
if known context_txts : endinput ; fi ;
boolean context_txts ; context_txts := true ;
%D The real code:
string txtfile ; txtfile := "" ;
string txtfont ; txtfont := defaultfont ;
string txtpref ; txtpref := "00001::::" ;
numeric txtnext ; txtnext := 0 ;
numeric txtdepth ; txtdepth := 0 ;
vardef nexttxt =
txtnext := txtnext + 1 ;
txtnext
enddef ;
picture savedtxts[] ;
numeric depthtxts[] ;
vardef zerofilled(expr fd) =
if fd<10: "0000" else :
if fd<100: "000" else :
if fd<1000: "00" else :
if fd<10000: "0" else :
fi fi fi fi & decimal fd
enddef;
vardef savetxt(expr n,w,h,d) text t =
depthtxts[n] := d ;
savedtxts[n] := ((txtpref & zerofilled(n)) infont txtfont) xysized(w,h+d) t
enddef ;
vardef sometxt(expr n) =
if known savedtxts[n] :
txtdepth := depthtxts[n] ; savedtxts[n]
else :
txtdepth := 0 ; nullpicture
fi
enddef ;
def loadtxts =
if txtfile <> "" :
readfile(txtfile) ;
fi ;
enddef ;
def StartTexts =
loadtxts ;
enddef ;
def StopTexts =
enddef ;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: meta-tex.tex
Type: application/x-tex
Size: 6075 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/dev-context/attachments/20060619/81502606/attachment.tex>
More information about the dev-context
mailing list