Re: [NTG-context] $\sin \theta$ behave differently in metafun
On 4/16/22 4:34 AM Jeong Dal via ntg-context wrote: > I use $\sin \theta$ and $\cos \theta$ behave differently in text and in metafun. > It works well sometime before but it doesn’t in metafun now. > What is wrong in my example? > > Thank you for reading. > Best regards, > > Dalyoung > > Here is a MWE. > > \startbuffer[pointCircle] > numeric u; u:=1cm; > pair A,B,C; > draw fullcircle scaled 4u; > A := dir(25)*2u; > label.top(textext("$P=(\cos\theta, \sin\theta)$"), A); > B := dir(-25)*2u; > label.bot(textext("$Q=(\cos(-\theta), \sin(-\theta))$"), B); > C := (xpart A, 0); label.lrt(textext("$A$"), C); > label(textext("$O$"), origin); > \stopbuffer > \starttext > I'd like use $\sin$ and $\cos$ in the metafun. But it shows strange text instead > of $\sin$ and $\cos$. > > \processMPbuffer[pointCircle] > > \stoptext Hi Hans and Mikael (and others on the list), I can confirm that even with the newest LMTX [2022.04.15 20:20] the above might actually be a bug. mfunctions inside MP strings are not properly rendred. A tiny MWE: \starttext \startMPcode draw textext("\m{\max_i x_i}"); \stopMPcode \stoptext Could trace it down to '\math_function_handle_label' [math-ini] but not sure what MP is doing. Also looked into mp-mlib, mlib-pps but could not figure it out. I request you to kindly look into it. Thanks, Sreeram ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] $\sin \theta$ behave differently in metafun
Dear all, I use $\sin \theta$ and $\cos \theta$ behave differently in text and in metafun. It works well sometime before but it doesn’t in metafun now. What is wrong in my example? Thank you for reading. Best regards, Dalyoung Here is a MWE. \startbuffer[pointCircle] numeric u; u:=1cm; pair A,B,C; draw fullcircle scaled 4u; A := dir(25)*2u; label.top(textext("$P=(\cos\theta, \sin\theta)$"), A); B := dir(-25)*2u; label.bot(textext("$Q=(\cos(-\theta), \sin(-\theta))$"), B); C := (xpart A, 0); label.lrt(textext("$A$"), C); label(textext("$O$"), origin); \stopbuffer \starttext I'd like use $\sin$ and $\cos$ in the metafun. But it shows strange text instead of $\sin$ and $\cos$. \processMPbuffer[pointCircle] \stoptext > 2022. 4. 13. 오전 11:09, ntg-context-requ...@ntg.nl 작성: > > Send ntg-context mailing list submissions to > ntg-context@ntg.nl > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.ntg.nl/mailman/listinfo/ntg-context > or, via email, send a message with subject or body 'help' to > ntg-context-requ...@ntg.nl > > You can reach the person managing the list at > ntg-context-ow...@ntg.nl > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of ntg-context digest..." > > > Today's Topics: > > 1. Re: Setting up zint on a mac with macOS Montery Version > 12.3.1 (Keith McKay) > 2. Re: fatal error in LMTX (Bruce Horrocks) > 3. Re: Setting up zint on a mac with macOS Montery Version > 12.3.1 (Bruce Horrocks) > 4. Re: Proper formatting of itemized bullets in ConTeXt (śrīrāma) > 5. Re: Proper formatting of itemized bullets in ConTeXt (śrīrāma) > > > -- > > Message: 1 > Date: Tue, 12 Apr 2022 21:04:50 +0100 > From: Keith McKay > To: Bruce Horrocks , mailing list for ConTeXt users > , monty.l...@gmail.com > Subject: Re: [NTG-context] Setting up zint on a mac with macOS Montery > Version 12.3.1 > Message-ID: <475d96e6-0905-7d2d-a51d-84b06d340...@gmail.com> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > Hi All > > I created the symbolic link as suggested by Bruce and Luis and still got the > error message > > optional> unable to locate library 'libzint' > > in my text editor. I use TeXworks. However, I thought I would try running > from the Terminal app and it worked. It found libzint and output the pdf with > both barcodes and the qrcode. I have no idea why it works in the Terminal and > not TexWorks, I'm guessing I have a path issue which I need to investigate. > > Notes > 1) My machine is a mac-mini-M1 with macos Monterey and I'm running the latest > ConTeXt version > 2) Bruce noted that my Homebrew was installed in a non-standard location so I > checked on the Hombrew website and it is installed in opt/homebrew for Apple > Silicon i.e the M1 chip. Maybe Bruce's homebrew was installed on an earlier > version. > > Thanks to Luis and Bruce for their suggestions. > Best Wishes > Keith McKay > > On 10/04/2022 22:26, Bruce Horrocks wrote: >> Hi Keith, >> >>> On 10 Apr 2022, at 14:49, Keith McKay via ntg-context >>> wrote: >>> >>> Hi All >>> >>> I have been struggling today trying to setup and use the Barcode module >>> zint in ConTeXt and failed. I have followed the instructions on the wiki >>> (https://wiki.contextgarden.net/Barcodes ) but with some changes as >>> follows. Which maybe why I failed. >>> >>> 1) I downloaded Zint using Homebrew since I'm using macOS, and installed it >>> according to the instructions. >>> >>> >>> 2) Since I'm using LMTX I looked for the file libzint.dylib and found it in >>> /opt/homebrew/Cellar/zint/2.10.0/lib . This is different from the path >>> given on the wiki. The directory contained three files, two of which were >>> aliases, libzint.2.10.dylib and libzint.dylib, and an exe file >>> libzint.2.10.0.0.dylib >> You have Hombrew installed in a non-standard location. Mine is in >> /usr/local/Cellar with the executables linked into /usr/local/bin. >> >> But, assuming other Homebrew commands work when run from Terminal then you >> might still be okay. >> >>> 3) I created the path $TEXROOT/tex/texmf-osx-64/bin/lib/luametatex/zint and >>> copied libzint.2.10.0.0.dylib into but replaced dylib with 'so' as >>> suggested on the wiki instructions. So I basically added >>> lib/luametatex
Re: [NTG-context] MetaPost Examples
> Am 01.09.2021 um 14:45 schrieb Hans Hagen via ntg-context > : > > On 9/1/2021 2:19 PM, Henning Hraban Ramm via ntg-context wrote: >> Hi, I’m trying to “translate” the documentation of “fiziko”* from LaTeX to >> ConTeXt and would like to avoid the doubling of MP code like: >> \startMP >> path p; >> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); >> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); >> \stopMP >> \startMPcode >> path p; >> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); >> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); >> \stopMPcode >> I’m quite sure there’s a possibility with buffers, but how? >> \startbuffer >> path p; >> p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); >> draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); >> \stopbuffer >> \typebuffer >> ... and then how do I get the MP graphic? > \processMPbuffer “of course” Thank you! Used here: https://github.com/fiee/fiziko/blob/master/fiziko.mkiv Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaPost Examples
On 9/1/2021 2:19 PM, Henning Hraban Ramm via ntg-context wrote: Hi, I’m trying to “translate” the documentation of “fiziko”* from LaTeX to ConTeXt and would like to avoid the doubling of MP code like: \startMP path p; p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); \stopMP \startMPcode path p; p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); \stopMPcode I’m quite sure there’s a possibility with buffers, but how? \startbuffer path p; p := (0,0){dir(30)}..(5cm, 0)..{dir(30)}(10cm, 0); draw brush (p)(2minStrokeWidth*sin(offsetPathLength*pi)); \stopbuffer \typebuffer ... and then how do I get the MP graphic? \processMPbuffer - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] weekend upload
On 7/9/2021 11:33 PM, Aditya Mahajan wrote: On Fri, 9 Jul 2021, Hans Hagen wrote: Hi, This weekend upload has something new for metapost animation lovers: \starttext \startuseMPgraphic{demo} stacking := 6; fill fullcircle scaled 10cm withcolor "red" ; % stacking := 3; stacking := 9; fill fullcircle scaled 10cm shifted (3cm,0) withcolor "green" ; interim stacking := 4; fill fullcircle scaled 10cm shifted (3cm,3cm) withcolor "blue" ; for i=1 upto 10 : draw fullcircle scaled (i*cm) withstacking 8 withpen pencircle scaled 1mm withcolor"gray" ; endfor ; for i=1 upto 20 : draw fullcircle scaled (i*cm/2) withstacking (if odd(i) : i else : 5 fi) withpen pencircle scaled 2mm ; endfor ; draw boundingbox currentpicture withpen pencircle scaled 1pt withstacking 0 ; currentpicture := currentpicture xsized 15mm; \stopuseMPgraphic \setupMPvariables[demo] \startTEXpage \vskip1ex \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}} \vskip1ex \nointerlineskip \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}} \vskip1ex \stopTEXpage \stoptext I have some more ideas but want to approach it stepwise. It bpils down to the fact that one can put stuff on different 'layers' and optionally flush these (by default all are flushed but the stackling order is honored). An advantage is that one doesn't have to set up a graphic in order (read: save pictures, flush them later on) and it is actually a rather cheap extension in terms of runtime and overhead. Although I could emulate it in mkiv, it is currently an LMTX only feature. The (optional) list accepts the usual {1,2,5,7-9} kind of specification. Very interesting. What will be the syntax to use this with \processMPbuffer and \startMPcode? In order to avoid a slash I went for the 'stacking' key: \startMPcode[instance=doublefun,stacking=0] % 4 draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4; draw (fullcircle scaled 5cm shifted (0cm,0cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkred" ;) withpatternscale (1/10,1/10) ; \stopMPcode \startMPpage[offset=1cm,instance=doublefun,stacking=0] % 4 draw (fullcircle scaled 5cm shifted (0cm,0cm)) withstacking 4; draw (fullcircle scaled 5cm shifted (0cm,0cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkblue";) withpatternscale (1/10,1/10) ; \stopMPpage we also have optionals to \use.., \reuse.. and \unique.. \startTEXpage \vskip1ex \hbox{\space\dorecurse{10}{\useMPgraphic {demo}{stacking={0,#1}}\space}} \vskip1ex \nointerlineskip \hbox{\space\dorecurse{10}{\useMPgraphic {demo}{stacking={0,1-#1}}\space}} \vskip1ex \nointerlineskip \hbox{\space\dorecurse{10}{\useMPgraphic [instance=doublefun,stacking={0,1-#1}]{demo}\space}} \vskip1ex \stopTEXpage work in progress (new upload anyway, also with clipping fixed wrt stacking) (i was wondering for a moment if "undergraphic removal" makes sense but it is a somewhat costly operation) (an other feature to explore is not to rerun but use some wrapper that keeps the image for as long as we flush ... it might save some runtime but first i need to run into a case where it pays off) Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] weekend upload
On 7/9/2021 11:33 PM, Aditya Mahajan wrote: On Fri, 9 Jul 2021, Hans Hagen wrote: Hi, This weekend upload has something new for metapost animation lovers: \starttext \startuseMPgraphic{demo} stacking := 6; fill fullcircle scaled 10cm withcolor "red" ; % stacking := 3; stacking := 9; fill fullcircle scaled 10cm shifted (3cm,0) withcolor "green" ; interim stacking := 4; fill fullcircle scaled 10cm shifted (3cm,3cm) withcolor "blue" ; for i=1 upto 10 : draw fullcircle scaled (i*cm) withstacking 8 withpen pencircle scaled 1mm withcolor"gray" ; endfor ; for i=1 upto 20 : draw fullcircle scaled (i*cm/2) withstacking (if odd(i) : i else : 5 fi) withpen pencircle scaled 2mm ; endfor ; draw boundingbox currentpicture withpen pencircle scaled 1pt withstacking 0 ; currentpicture := currentpicture xsized 15mm; \stopuseMPgraphic \setupMPvariables[demo] \startTEXpage \vskip1ex \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}} \vskip1ex \nointerlineskip \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}} \vskip1ex \stopTEXpage \stoptext I have some more ideas but want to approach it stepwise. It bpils down to the fact that one can put stuff on different 'layers' and optionally flush these (by default all are flushed but the stackling order is honored). An advantage is that one doesn't have to set up a graphic in order (read: save pictures, flush them later on) and it is actually a rather cheap extension in terms of runtime and overhead. Although I could emulate it in mkiv, it is currently an LMTX only feature. The (optional) list accepts the usual {1,2,5,7-9} kind of specification. Very interesting. What will be the syntax to use this with \processMPbuffer and \startMPcode? For now just use: \setupMPvariables[list=4] etc (grouped) btw, i noticed that I need to reset something between graphics Hans - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] weekend upload
On Fri, 9 Jul 2021, Hans Hagen wrote: > Hi, > > This weekend upload has something new for metapost animation lovers: > > \starttext > > \startuseMPgraphic{demo} > stacking := 6; > fill fullcircle scaled 10cm > withcolor "red" ; >% stacking := 3; > stacking := 9; > fill fullcircle scaled 10cm shifted (3cm,0) > withcolor "green" ; > interim stacking := 4; > fill fullcircle scaled 10cm shifted (3cm,3cm) > withcolor "blue" ; > for i=1 upto 10 : > draw fullcircle scaled (i*cm) > withstacking 8 > withpen pencircle scaled 1mm > withcolor"gray" ; > endfor ; > for i=1 upto 20 : > draw fullcircle scaled (i*cm/2) > withstacking (if odd(i) : i else : 5 fi) > withpen pencircle scaled 2mm ; > endfor ; > draw boundingbox currentpicture > withpen pencircle scaled 1pt > withstacking 0 ; > currentpicture := currentpicture xsized 15mm; > \stopuseMPgraphic > > \setupMPvariables[demo] > > \startTEXpage > \vskip1ex > \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,#1}}\space}} > \vskip1ex \nointerlineskip > \hbox{\space\dorecurse{10}{\useMPgraphic{demo}{list={0,1-#1}}\space}} > \vskip1ex > \stopTEXpage > > \stoptext > > I have some more ideas but want to approach it stepwise. It bpils down > to the fact that one can put stuff on different 'layers' and optionally > flush these (by default all are flushed but the stackling order is > honored). An advantage is that one doesn't have to set up a graphic in > order (read: save pictures, flush them later on) and it is actually a > rather cheap extension in terms of runtime and overhead. Although I > could emulate it in mkiv, it is currently an LMTX only feature. > > The (optional) list accepts the usual {1,2,5,7-9} kind of specification. Very interesting. What will be the syntax to use this with \processMPbuffer and \startMPcode? Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
Dear Otared, > > Regarding the way Aditya uses \startuseMPgraphic, it is also very > instructive. > Dalyoung, can you also share the animation example for the foldings ? I am > sure we are a few on the list to learn something… > 1. Here is the working sample of animation using \processMPbuffer which I did before. You can see it using adobe reader. \startbuffer[UDBasic] pair A,B,C,D; pair E, F, G, H; path p,q; numeric ang,maxNum; u:=1in; A=(.95*TextWidth,u); B=(0,u); C=(0,0); D=(.95*TextWidth,0); p := A--B--C--D; q := (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle; z0=(.1u,0); vardef nextPt (expr M,N) = if ypart(N) = 0: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B]; else: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[C,D]; fi; H enddef; def grayUD(expr i) = draw G -- if ypart(B)=ypart(G): B -- C else: C -- B fi --z[i]; filldraw z[i]+2*(G-z[i])*u -- z[i] -- z[i+1] -- z[i+1]+(G-z[i])*u -- cycle withcolor .75white; draw G -- z[i+1] dashed evenly; draw z[0] for k=0 upto i: --z[k] endfor dashed evenly; clip currentpicture to q; setbounds currentpicture to boundingbox q; enddef; def linesUD(expr i) = draw p; draw z0 for k=0 upto i+1: --z[k] endfor dashed evenly; setbounds currentpicture to boundingbox q; enddef; \stopbuffer \startbuffer[UDpts] ang := 40; z[1] = whatever[z[0], z[0]+dir(ang)*u] = whatever[A,B]; G := whatever[z[0], z[0]+dir(2*ang)*u] = whatever[A,B]; for k = 2 upto 20: z[k] = nextPt(z[k-2],z[k-1]); maxNum := k; exitif xpart(z[k]) > TextWidth; endfor; \stopbuffer \startbuffer[UD0] draw p; setbounds currentpicture to boundingbox q; \stopbuffer \startbuffer[UD1] grayUD(0); \stopbuffer \startbuffer[UD11] linesUD(0); \stopbuffer \startbuffer[UD2] G := z0; grayUD(1) \stopbuffer \startbuffer[UD21] linesUD(1); \stopbuffer \startbuffer[UD3] G := z1; grayUD(2); \stopbuffer \startbuffer[UD31] linesUD(2); \stopbuffer \startbuffer[UD4] G := z2; grayUD(3); \stopbuffer \startbuffer[UD41] linesUD(3); \stopbuffer \startbuffer[UD5] G := z3; grayUD(4); \stopbuffer \startbuffer[UD51] linesUD(4); \stopbuffer \startbuffer[UDFinal] draw p; draw z0--z1--z2--z3--z4--z5--z6--z7--z8 dashed evenly; setbounds currentpicture to boundingbox q; \stopbuffer \setupinteraction[state=start] \usemodule[animation] \starttext \startanimation[menu=yes] {\processMPbuffer[UDBasic,UDpts,UD0]} {\processMPbuffer[UDBasic,UDpts,UD1]} {\processMPbuffer[UDBasic,UDpts,UD11]} {\processMPbuffer[UDBasic,UDpts,UD2]} {\processMPbuffer[UDBasic,UDpts,UD21]} {\processMPbuffer[UDBasic,UDpts,UD3]} {\processMPbuffer[UDBasic,UDpts,UD31]} {\processMPbuffer[UDBasic,UDpts,UD4]} {\processMPbuffer[UDBasic,UDpts,UD41]} {\processMPbuffer[UDBasic,UDpts,UD5]} {\processMPbuffer[UDBasic,UDpts,UD51]} {\processMPbuffer[UDBasic,UDpts,UDFinal]} \stopanimation \stoptext Now, I am trying to do the same thing using \startuseMPgraphic, but I don’t the correct result yet. Using \startuseMPgraphic, and \dorecurse, the code is simpler. But, it seems to me that \startanimation … \stopanimation is not working with \dorecurse{}{} … It just list all the graphics. Any hint is welcome. \startMPinitializations%{UDBasic} pair A,B,C,D; pair E, F, G, H; path p,q; numeric ang,maxNum; numeric n; %AM Added u:=1in; A=(.95*TextWidth,u); B=(0,u); C=(0,0); D=(.95*TextWidth,0); p := A--B--C--D; q := (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle; z0=(.1u,0); vardef nextPt (expr M,N) = if ypart(N) = 0: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B]; else: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[C,D]; fi; H enddef; def grayUD(expr i) = draw G -- if ypart(B)=ypart(G): B -- C else: C -- B fi --z[i]; filldraw z[i]+2*(G-z[i])*u -- z[i] -- z[i+1] -- z[i+1]+(G-z[i])*u -- cycle withcolor .75white; draw G -- z[i+1] dashed evenly; draw z[0] for k=0 upto i: --z[k] endfor dashed evenly; clip currentpicture to q; enddef; def linesUD(expr i) = draw p; draw z0 for k=0 upto i+1: --z[k] endfor dashed evenly; % AM: removed. Set in in the main code % setbounds currentpicture to boundingbox q; enddef; ang := 40; z[1] = whatever[z[0], z[0]+dir(ang)*u] = whatever[A,B]; % AM: Changed next line from G to z[-1] z[-1] = whatever[z[0], z[0]+dir(2*ang)*u] = whatever[A,B]; for k = 2 upto 20: z[k] = nextPt(z[k-2],z[k-1]); maxNum := k; exitif xpart(z[k]) > TextWidth; endfor; \stopMPinitializations \startuseMPgraphic{foldUD}{num} numeric n; n := \MPvar{num}-1; G := z[n-1]; grayUD(n); \stopuseMPgraphic \startuseMPgraphic{dotLines}{num} numeric n; n := \MPvar{num}-1; linesUD(n); \stopuseMPgraphic \setupinteraction[state=sta
Re: [NTG-context] simplifying repeated macro calls in metafun
Dear Dalyoung, dear Mikael Thank you both for your explanations: indeed this « whatever » command in MetaPost is magic and very useful (I am not sure whether it is a command only in MetaFun, or it exists also in the original MetaPost). Regarding the way Aditya uses \startuseMPgraphic, it is also very instructive. Dalyoung, can you also share the animation example for the foldings ? I am sure we are a few on the list to learn something… Best regards: Otared > On 21 Jun 2021, at 23:50, Jeong Dal wrote: > > > Dear Otared, > > I received list mail in condensed form, I didn’t see your mail before I sent > one. > > As Mikael explained, “whatever” is very nice to find the intersection point > of two lines. > You can see nice examples which use “whatever” in MetaFun manual. > > In my code, the next point is the intersection point of the edge and the > folding line which bisect the angle of the former folding line [M,N]. > > H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B]; > > Enjoy the use of “whatever”! > > I made an animation of the folding process using animation module and > \processMPbuffer. > But Woldgang’s code showed a way to make it using \startuseMPgraphic. > > > Best regards, > > Dalyoung > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
Dear Otared, I received list mail in condensed form, I didn’t see your mail before I sent one. As Mikael explained, “whatever” is very nice to find the intersection point of two lines. You can see nice examples which use “whatever” in MetaFun manual. In my code, the next point is the intersection point of the edge and the folding line which bisect the angle of the former folding line [M,N]. H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B]; Enjoy the use of “whatever”! I made an animation of the folding process using animation module and \processMPbuffer. But Woldgang’s code showed a way to make it using \startuseMPgraphic. Best regards, Dalyoung___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
Hi, yes, sure, I should have copied my code from the geometry document where I do this kind of constructions over and over... /Mikael On Mon, Jun 21, 2021 at 4:31 PM Otared Kavian wrote: > > Hi Mikael, > > Thank you so much for the explanation: I am ashamed for not having read this > in the MetaPost manual. > > Just to make sure whether I am beginning to understand, in your example code > > > z3 = whatever[z1,z2] = z0+whatever*dir(angle(z1-z0)+90)); > > should the second « whatever » be > > z0 + whatever*dir(angle(z2 - z1) + 90)) ; > > or am I proving that I have not yet understood this wonderful command ? > > Thanks again and best regards: Otared > > > On 21 Jun 2021, at 14:21, Mikael Sundqvist wrote: > > > > Hi, > > > > As is written in the MetaPost manual: Whatever generates a new > > anonymous variable each time it is used. It is very useful in cases > > where you are not interested in the value of a variable, but want to > > use it to (let MP) calculate something. Example > > > > you have three points z0, z1, z2 forming a triangle, and you want to > > find where the altitude from z0 is intersecting the line between z1 > > and z2. You can find that intersection z3 by writing > > > > z3 = whatever[z1,z2] = z0+whatever*dir(angle(z1-z0)+90)); > > > > The first equality says only that z3 should be on the line between z1 > > and z2, the second one says that z3 should be on the line through z0, > > perpendicular to the line between z1 and z2. Since MetaPost solves > > linear equations, this defines z3, and we need not to think more about > > the actual values of the "whatevers" (note that they are not in > > general equal in this example!). > > > > Hope it helps! > > > > /Mikael > > > > > > On Mon, Jun 21, 2021 at 2:07 PM Otared Kavian wrote: > >> > >> Hi Aditya, > >> > >> Thanks for the detailed file you sent to answer Dalyoung’s question and > >> file. And going through both files I have a question. > >> I see that both of you use a function « whatever » (but is it a function > >> ?): what does this do and where can it be used (actually I have seen Hans > >> using this expression, but I had always thought this is just a name… > >> > >> Best regards: Otared > >> > >>> On 21 Jun 2021, at 06:26, Aditya Mahajan wrote: > >>> > >>> On Mon, 21 Jun 2021, Jeong Dal wrote: > >>> > >>>> > >>>> Hi, > >>>> > >>>> I defined a macro definition in metafun, and draw figures using > >>>> \startbuffer[] … \stopbuffer and \processMPbuffer[]. > >>>> As you see in the attached code, the same macro definition is used > >>>> repeatedly by changing the numeric argument. > >>>> Is there a better way to simplify the code, for example, using > >>>> \dorecurse and recurselevel? > >>> > >>> See attached. The main idea is to store the repetitive bits in > >>> \startuseMPgraphic{...} and then reuse them using \includeMPgraphic. > >>> > >>> Aditya___ > >>> If your question is of interest to others as well, please add an entry to > >>> the Wiki! > >>> > >>> maillist : ntg-context@ntg.nl / > >>> http://www.ntg.nl/mailman/listinfo/ntg-context > >>> webpage : http://www.pragma-ade.nl / http://context.aanhet.net > >>> archive : https://bitbucket.org/phg/context-mirror/commits/ > >>> wiki : http://contextgarden.net > >>> ___ > >> > >> ___ > >> If your question is of interest to others as well, please add an entry to > >> the Wiki! > >> > >> maillist : ntg-context@ntg.nl / > >> http://www.ntg.nl/mailman/listinfo/ntg-context > >> webpage : http://www.pragma-ade.nl / http://context.aanhet.net > >> archive : https://bitbucket.org/phg/context-mirror/commits/ > >> wiki : http://contextgarden.net > >> ___ > > ___ > > If your question is of interest to others as well, please add an entry t
Re: [NTG-context] simplifying repeated macro calls in metafun
Hi Mikael, Thank you so much for the explanation: I am ashamed for not having read this in the MetaPost manual. Just to make sure whether I am beginning to understand, in your example code > z3 = whatever[z1,z2] = z0+whatever*dir(angle(z1-z0)+90)); should the second « whatever » be z0 + whatever*dir(angle(z2 - z1) + 90)) ; or am I proving that I have not yet understood this wonderful command ? Thanks again and best regards: Otared > On 21 Jun 2021, at 14:21, Mikael Sundqvist wrote: > > Hi, > > As is written in the MetaPost manual: Whatever generates a new > anonymous variable each time it is used. It is very useful in cases > where you are not interested in the value of a variable, but want to > use it to (let MP) calculate something. Example > > you have three points z0, z1, z2 forming a triangle, and you want to > find where the altitude from z0 is intersecting the line between z1 > and z2. You can find that intersection z3 by writing > > z3 = whatever[z1,z2] = z0+whatever*dir(angle(z1-z0)+90)); > > The first equality says only that z3 should be on the line between z1 > and z2, the second one says that z3 should be on the line through z0, > perpendicular to the line between z1 and z2. Since MetaPost solves > linear equations, this defines z3, and we need not to think more about > the actual values of the "whatevers" (note that they are not in > general equal in this example!). > > Hope it helps! > > /Mikael > > > On Mon, Jun 21, 2021 at 2:07 PM Otared Kavian wrote: >> >> Hi Aditya, >> >> Thanks for the detailed file you sent to answer Dalyoung’s question and >> file. And going through both files I have a question. >> I see that both of you use a function « whatever » (but is it a function ?): >> what does this do and where can it be used (actually I have seen Hans using >> this expression, but I had always thought this is just a name… >> >> Best regards: Otared >> >>> On 21 Jun 2021, at 06:26, Aditya Mahajan wrote: >>> >>> On Mon, 21 Jun 2021, Jeong Dal wrote: >>> >>>> >>>> Hi, >>>> >>>> I defined a macro definition in metafun, and draw figures using >>>> \startbuffer[] … \stopbuffer and \processMPbuffer[]. >>>> As you see in the attached code, the same macro definition is used >>>> repeatedly by changing the numeric argument. >>>> Is there a better way to simplify the code, for example, using \dorecurse >>>> and recurselevel? >>> >>> See attached. The main idea is to store the repetitive bits in >>> \startuseMPgraphic{...} and then reuse them using \includeMPgraphic. >>> >>> Aditya___ >>> If your question is of interest to others as well, please add an entry to >>> the Wiki! >>> >>> maillist : ntg-context@ntg.nl / >>> http://www.ntg.nl/mailman/listinfo/ntg-context >>> webpage : http://www.pragma-ade.nl / http://context.aanhet.net >>> archive : https://bitbucket.org/phg/context-mirror/commits/ >>> wiki : http://contextgarden.net >>> ___ >> >> ___ >> If your question is of interest to others as well, please add an entry to >> the Wiki! >> >> maillist : ntg-context@ntg.nl / >> http://www.ntg.nl/mailman/listinfo/ntg-context >> webpage : http://www.pragma-ade.nl / http://context.aanhet.net >> archive : https://bitbucket.org/phg/context-mirror/commits/ >> wiki : http://contextgarden.net >> ___ > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
Hi, As is written in the MetaPost manual: Whatever generates a new anonymous variable each time it is used. It is very useful in cases where you are not interested in the value of a variable, but want to use it to (let MP) calculate something. Example you have three points z0, z1, z2 forming a triangle, and you want to find where the altitude from z0 is intersecting the line between z1 and z2. You can find that intersection z3 by writing z3 = whatever[z1,z2] = z0+whatever*dir(angle(z1-z0)+90)); The first equality says only that z3 should be on the line between z1 and z2, the second one says that z3 should be on the line through z0, perpendicular to the line between z1 and z2. Since MetaPost solves linear equations, this defines z3, and we need not to think more about the actual values of the "whatevers" (note that they are not in general equal in this example!). Hope it helps! /Mikael On Mon, Jun 21, 2021 at 2:07 PM Otared Kavian wrote: > > Hi Aditya, > > Thanks for the detailed file you sent to answer Dalyoung’s question and file. > And going through both files I have a question. > I see that both of you use a function « whatever » (but is it a function ?): > what does this do and where can it be used (actually I have seen Hans using > this expression, but I had always thought this is just a name… > > Best regards: Otared > > > On 21 Jun 2021, at 06:26, Aditya Mahajan wrote: > > > > On Mon, 21 Jun 2021, Jeong Dal wrote: > > > >> > >> Hi, > >> > >> I defined a macro definition in metafun, and draw figures using > >> \startbuffer[] … \stopbuffer and \processMPbuffer[]. > >> As you see in the attached code, the same macro definition is used > >> repeatedly by changing the numeric argument. > >> Is there a better way to simplify the code, for example, using \dorecurse > >> and recurselevel? > > > > See attached. The main idea is to store the repetitive bits in > > \startuseMPgraphic{...} and then reuse them using \includeMPgraphic. > > > > Aditya___ > > If your question is of interest to others as well, please add an entry to > > the Wiki! > > > > maillist : ntg-context@ntg.nl / > > http://www.ntg.nl/mailman/listinfo/ntg-context > > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > > archive : https://bitbucket.org/phg/context-mirror/commits/ > > wiki : http://contextgarden.net > > ___ > > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
Hi Aditya, Thanks for the detailed file you sent to answer Dalyoung’s question and file. And going through both files I have a question. I see that both of you use a function « whatever » (but is it a function ?): what does this do and where can it be used (actually I have seen Hans using this expression, but I had always thought this is just a name… Best regards: Otared > On 21 Jun 2021, at 06:26, Aditya Mahajan wrote: > > On Mon, 21 Jun 2021, Jeong Dal wrote: > >> >> Hi, >> >> I defined a macro definition in metafun, and draw figures using >> \startbuffer[] … \stopbuffer and \processMPbuffer[]. >> As you see in the attached code, the same macro definition is used >> repeatedly by changing the numeric argument. >> Is there a better way to simplify the code, for example, using \dorecurse >> and recurselevel? > > See attached. The main idea is to store the repetitive bits in > \startuseMPgraphic{...} and then reuse them using \includeMPgraphic. > > Aditya___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] simplifying repeated macro calls in metafun
On Mon, 21 Jun 2021, Jeong Dal wrote: > > Hi, > > I defined a macro definition in metafun, and draw figures using > \startbuffer[] … \stopbuffer and \processMPbuffer[]. > As you see in the attached code, the same macro definition is used repeatedly > by changing the numeric argument. > Is there a better way to simplify the code, for example, using \dorecurse and > recurselevel? See attached. The main idea is to store the repetitive bits in \startuseMPgraphic{...} and then reuse them using \includeMPgraphic. Aditya mp-test.tex Description: TeX document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] simplifying repeated macro calls in metafun
Hi, I defined a macro definition in metafun, and draw figures using \startbuffer[] … \stopbuffer and \processMPbuffer[]. As you see in the attached code, the same macro definition is used repeatedly by changing the numeric argument. Is there a better way to simplify the code, for example, using \dorecurse and recurselevel? Thank you for reading. Best regards, Dalyoung \startbuffer[UDBasic] pair A,B,C,D; pair E, F, G, H; path p,q; numeric ang,maxNum; u:=1in; A=(.95*TextWidth,u); B=(0,u); C=(0,0); D=(.95*TextWidth,0); p := A--B--C--D; q := (TextWidth,1.5u)--(0,1.5u)--(0,-.5u)--(TextWidth,-.5u)--cycle; z0=(.1u,0); vardef nextPt (expr M,N) = if ypart(N) = 0: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[A,B]; else: H := whatever[N, N + dir(.5*angle(M-N))*u] = whatever[C,D]; fi; H enddef; def grayUD(expr i) = draw G -- if ypart(B)=ypart(G): B -- C else: C -- B fi --z[i]; filldraw z[i]+2*(G-z[i])*u -- z[i] -- z[i+1] -- z[i+1]+(G-z[i])*u -- cycle withcolor .75white; draw G -- z[i+1] dashed evenly; draw z[0] for k=0 upto i: --z[k] endfor dashed evenly; clip currentpicture to q; enddef; def linesUD(expr i) = draw p; draw z0 for k=0 upto i+1: --z[k] endfor dashed evenly; setbounds currentpicture to boundingbox q; enddef; \stopbuffer \startbuffer[UDpts] ang := 40; z[1] = whatever[z[0], z[0]+dir(ang)*u] = whatever[A,B]; G := whatever[z[0], z[0]+dir(2*ang)*u] = whatever[A,B]; for k = 2 upto 20: z[k] = nextPt(z[k-2],z[k-1]); maxNum := k; exitif xpart(z[k]) > TextWidth; endfor; \stopbuffer \startbuffer[UD0] draw p; setbounds currentpicture to boundingbox q; \stopbuffer \startbuffer[UD1] grayUD(0); \stopbuffer \startbuffer[UD11] linesUD(0); \stopbuffer \startbuffer[UD2] G := z0; grayUD(1) \stopbuffer \startbuffer[UD21] linesUD(1); \stopbuffer \startbuffer[UD3] G := z1; grayUD(2); \stopbuffer \startbuffer[UD31] linesUD(2); \stopbuffer \startbuffer[UD4] G := z2; grayUD(3); \stopbuffer \startbuffer[UD41] linesUD(3); \stopbuffer \startbuffer[UD5] G := z3; grayUD(4); \stopbuffer \startbuffer[UD51] linesUD(4); \stopbuffer \startbuffer[UDFinal] draw p; draw z0--z1--z2--z3--z4--z5--z6--z7--z8 dashed evenly; setbounds currentpicture to boundingbox q; \stopbuffer \starttext \processMPbuffer[UDBasic,UDpts,UD0] \processMPbuffer[UDBasic,UDpts,UD1] \processMPbuffer[UDBasic,UDpts,UD11] \processMPbuffer[UDBasic,UDpts,UD2] \processMPbuffer[UDBasic,UDpts,UD21] \processMPbuffer[UDBasic,UDpts,UD3] \processMPbuffer[UDBasic,UDpts,UD31] \processMPbuffer[UDBasic,UDpts,UD4] \processMPbuffer[UDBasic,UDpts,UD41] \processMPbuffer[UDBasic,UDpts,UD5] \processMPbuffer[UDBasic,UDpts,UD51] \processMPbuffer[UDBasic,UDpts,UDFinal] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] missing "{ }" in metafun.
Hi, Set notation “{}” is OK in TeX mode. But it is missing in the output of the metafun code. Here is an MWE. It is same in two different versions. ConTeXt ver: 2021.01.17 21:42 LMTX fmt: 2021.2.4 int: english/english ConTeXt ver: 2021.03.13 11:22 LMTX fmt: 2021.3.14 int: english/english \startbuffer[test] label(textext("$\{a,b\}$"),origin); \stopbuffer \starttext Let $A = \{a,b\}$. \processMPbuffer[test] \stoptext Thanks. Best regards, Dalyoung___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] missing "{ }" in metafun.
On 3/14/2021 10:22 AM, Jeong Dal wrote: Hi, Set notation “{}” is OK in TeX mode. But it is missing in the output of the metafun code. Here is an MWE. It is same in two different versions. ConTeXt ver: 2021.01.17 21:42 LMTX fmt: 2021.2.4 int: english/english ConTeXt ver: 2021.03.13 11:22 LMTX fmt: 2021.3.14 int: english/english \startbuffer[test] label(textext("$\{a,b\}$"),origin); \stopbuffer \starttext Let $A = \{a,b\}$. \processMPbuffer[test] \stoptext \$ \_ \& \{ \} become letters when we flush a mp graphic, so use \lbrace \rbrace instead - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] add more blank space when using \starteffect[hidden]
On 3/12/2021 10:08 PM, Jeong Dal wrote: Hi, Sometimes, I need to hide the solution of a problem. So I use \doifmode{} and \starteffect[hidden] as in the following sample file. Since I want to set more blank space if it is hidden, I add \blank[5cm] when it is in the \enablemode[hideSolution]. It works well except the figures and bars are not hidden. Only texts, even in the mp part, are hidden. It is OK for me. However, it would be much better to set the height of blank space depends on the height of hidden texts. Is there a way to set the variable height using “overlay” stuff instead of \blank[5cm]? Thank for reading. Best regards, Dalyoung \startbuffer[circles] draw fullcircle scaled 1cm; draw fullcircle scaled 1cm shifted (2cm,0); dotlabel.top(“O”,origin); \stopbuffer \def\StartHide{\doifmode{hideSolution}{\starteffect[hidden]}} \def\StopHide{\doifmode{hideSolution}{\stopeffect\blank[5cm]}} %\enablemode[hideSolution] \starttext \framed[]{This is what I want:} \framedtext[]{ \StartHide \samplefile{knuth} Overbar is not \overbar{hidden}. {\processMPbuffer[circles]} \StopHide } \stoptext In your case it's easier than you mightt think: \framedtext[empty=yes] - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] add more blank space when using \starteffect[hidden]
Hi, Sometimes, I need to hide the solution of a problem. So I use \doifmode{} and \starteffect[hidden] as in the following sample file. Since I want to set more blank space if it is hidden, I add \blank[5cm] when it is in the \enablemode[hideSolution]. It works well except the figures and bars are not hidden. Only texts, even in the mp part, are hidden. It is OK for me. However, it would be much better to set the height of blank space depends on the height of hidden texts. Is there a way to set the variable height using “overlay” stuff instead of \blank[5cm]? Thank for reading. Best regards, Dalyoung \startbuffer[circles] draw fullcircle scaled 1cm; draw fullcircle scaled 1cm shifted (2cm,0); dotlabel.top(“O”,origin); \stopbuffer \def\StartHide{\doifmode{hideSolution}{\starteffect[hidden]}} \def\StopHide{\doifmode{hideSolution}{\stopeffect\blank[5cm]}} %\enablemode[hideSolution] \starttext \framed[]{This is what I want:} \framedtext[]{ \StartHide \samplefile{knuth} Overbar is not \overbar{hidden}. {\processMPbuffer[circles]} \StopHide } \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Combining modes and MetaFun
Thank you Hans, this is exactly what I need. I will wikify the examples. Kind regards,Jan Willem Flamma From: Hans HagenSent: Friday, 4 September 2020 15:09To: mailing list for ConTeXt users; Jan Willem FlammaSubject: Re: [NTG-context] Combining modes and MetaFun On 9/4/2020 2:20 PM, Jan Willem Flamma wrote:> Dear list members,> > Is it possible to combine modes and MetaFun?> > In the below MWE, the \doifmode construction does not work.> > Kind regards,> > Jan Willem Flamma> > ===> > \enablemode[en]> > %\enablemode[nl]> > \starttext> > \startbuffer[square]> > u := 2cm ;> > draw unitsquare scaled u ;> > drawdblarrow (0,-0.2u)..(u,-0.2u) ;> > drawdblarrow (1.2u, 0)..(1.2u, u) ;> > %\doifmode{en}{label(\sometxt{length}, (0.5u,-0.4u)) ;}> > %\doifmode{nl}{label(\sometxt{lengte}, (0.5u,-0.4u)) ;}> > %\doifmode{en}{label(\sometxt{width}, (1.6u, 0.5u)) ;}> > %\doifmode{nl}{label(\sometxt{breedte}, (1.6u, 0.5u)) ;}> > \stopbuffer> > \placefigure> > [here,none][]{}> > {\scale[width=0.5\textwidth]{\processMPbuffer[square]}}> > \stoptextYou need to compensate these solutions by "wikifying" them: \starttext \startuseMPgraphic{whatever}{s::mode} u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; if "\MPvar{mode}" = "en" : label("e", (0.5u,-0.4u)) ; label("n", (1.6u, 0.5u)) ; else : label("n", (0.5u,-0.4u)) ; label("l", (1.6u, 0.5u)) ; fi ;\stopuseMPgraphic \useMPgraphic{whatever}{mode=en} \blank\useMPgraphic{whatever}{mode=nl} \blank \startuseMPgraphic{whatever} u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; if texmode("en") : label("e", (0.5u,-0.4u)) ; label("n", (1.6u, 0.5u)) ; else : label("n", (0.5u,-0.4u)) ; label("l", (1.6u, 0.5u)) ; fi ;\stopuseMPgraphic { \enablemode[en] \useMPgraphic{whatever} } \blank{ \useMPgraphic{whatever} } \blank \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl- ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Combining modes and MetaFun
On 9/4/2020 2:20 PM, Jan Willem Flamma wrote: Dear list members, Is it possible to combine modes and MetaFun? In the below MWE, the \doifmode construction does not work. Kind regards, Jan Willem Flamma === \enablemode[en] %\enablemode[nl] \starttext \startbuffer[square] u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; %\doifmode{en}{label(\sometxt{length}, (0.5u,-0.4u)) ;} %\doifmode{nl}{label(\sometxt{lengte}, (0.5u,-0.4u)) ;} %\doifmode{en}{label(\sometxt{width}, (1.6u, 0.5u)) ;} %\doifmode{nl}{label(\sometxt{breedte}, (1.6u, 0.5u)) ;} \stopbuffer \placefigure [here,none][]{} {\scale[width=0.5\textwidth]{\processMPbuffer[square]}} \stoptext You need to compensate these solutions by "wikifying" them: \starttext \startuseMPgraphic{whatever}{s::mode} u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; if "\MPvar{mode}" = "en" : label("e", (0.5u,-0.4u)) ; label("n", (1.6u, 0.5u)) ; else : label("n", (0.5u,-0.4u)) ; label("l", (1.6u, 0.5u)) ; fi ; \stopuseMPgraphic \useMPgraphic{whatever}{mode=en} \blank \useMPgraphic{whatever}{mode=nl} \blank \startuseMPgraphic{whatever} u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; if texmode("en") : label("e", (0.5u,-0.4u)) ; label("n", (1.6u, 0.5u)) ; else : label("n", (0.5u,-0.4u)) ; label("l", (1.6u, 0.5u)) ; fi ; \stopuseMPgraphic { \enablemode[en] \useMPgraphic{whatever} } \blank { \useMPgraphic{whatever} } \blank \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] Combining modes and MetaFun
Dear list members, Is it possible to combine modes and MetaFun? In the below MWE, the \doifmode construction does not work. Kind regards,Jan Willem Flamma ===\enablemode[en]%\enablemode[nl] \starttext \startbuffer[square] u := 2cm ; draw unitsquare scaled u ; drawdblarrow (0,-0.2u)..(u,-0.2u) ; drawdblarrow (1.2u, 0)..(1.2u, u) ; %\doifmode{en}{label(\sometxt{length}, (0.5u,-0.4u)) ;} %\doifmode{nl}{label(\sometxt{lengte}, (0.5u,-0.4u)) ;} %\doifmode{en}{label(\sometxt{width}, (1.6u, 0.5u)) ;} %\doifmode{nl}{label(\sometxt{breedte}, (1.6u, 0.5u)) ;}\stopbuffer \placefigure [here,none][]{} {\scale[width=0.5\textwidth]{\processMPbuffer[square]}} \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Code lua in a table
Dear Fabrice, You may split Binom(n,k) function into two functions as following: * \startluacode P={} combi = P function P.fact (n) if n <= 0 then return 1 else return n * P.fact(n-1) end end function P.ncr(n,r) return P.fact(n)/(P.fact(r)*P.fact(n-r)) end combi = { fact = fact, ncr = ncr, } \stopluacode ** Your table is actually Pascal’d triangle. Using the above function, I was able to draw Pascal’s triangles. Hans helped me to complete it. I couldn’t wikify it at that time because I don’t know how to. I’ll do it soon. Here is the whole code for Pascal’s triangle in two different ways using Lua, Metafun and ConTeXt. You may enhance the code. \startbuffer[pt1] numeric n,r,s,u,dx,dy,tt; u := 1.8cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 4: start := n*dir(210)*u; for r=0 upto n: s := n-r; tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); draw (now+A) -- now -- (now+B); endfor; endfor; \stopbuffer \startbuffer[pt2] numeric n,r,s,u,dx,dy,tt; u := 1cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 8: start := n*dir(210)*u; for r=0 upto n: s := n-r; tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; label(textext("$" & decimal tt & "$"),now); endfor; endfor; \stopbuffer \startluacode P={} combi = P function P.fact (n) if n <= 0 then return 1 else return n * P.fact(n-1) end end function P.ncr(n,r) return P.fact(n)/(P.fact(r)*P.fact(n-r)) end combi = { fact = fact, ncr = ncr, } \stopluacode \starttext \processMPbuffer[pt1] \blank[big] \processMPbuffer[pt2] \stoptext I hope that it helps. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] running lua in metafun and in ConTeXt
Dear Hans, Thank you for your nice code. lua.MP.Whatever is something! Have a nice weekend. Best regards, Dalyoung > 2020. 4. 12. 오전 2:08, Hans Hagen 작성: > > On 4/11/2020 4:15 PM, Jeong Dal wrote: >> Dear all, >> The problem is solved by using the namespace of lua as below: >> I am not sure what I did is the right way. >> If it is not the right way, please let me know. >> Thanks for reading. >> Best regards, >> Dalyoung >> \startluacode >> P={} >> combi = P >> function P.fact (n) >> if n <= 0 then >> return 1 >> else >> return n * P.fact(n-1) >> end >> end >> function P.ncr(n,r) >> return P.fact(n)/(P.fact(r)*P.fact(n-r)) >> end >> combi = { >> fact = fact, >> ncr = ncr, >> } >> \stopluacode >> \startbuffer[fig121] >> numeric n,r,s,u,dx,dy,tt; u := 1.8cm; >> path p, q; >> pair A,B,start,now; >> A := dir(210)*u; >> B := dir(-30)*u; >> dy := sind(30)*u; >> dx := 2*cosd(30)*u; >> for n=0 upto 4: >> start := n*dir(210)*u; >> for r=0 upto n: >> s := n-r; >> % tt := lua("mp.print(P.fact(" & decimal n & ")/(P.fact(" & decimal r & >> ")*P.fact(" & decimal s &" )))"); >> tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); >> now := start+r*right*dx; >> dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r >> & "} = "& decimal tt & "$"),now); >> draw now -- (now+A); >> draw now -- (now+B); >> endfor; >> endfor; >> \stopbuffer > Sunday afternoon educational moment (that you can wikify), four variants: > > 1 : A more metafunish alternative of your example. > 2 : The same but avoiding a temporary variable. > 3 : Less code and clutter, the real deal. > 4 : Idem, but permits more tuning at the TeX end. > > \unexpanded\def\MyWhatever#1#2#3% > {$\displaystyle{#1\choose #2} = #3$} > > \startluacode > local function fact(n) >if n <= 0 then >return 1 >else >return n * fact(n - 1) >end > end > > local function whatever(n,r) > return fact(n) / (fact(r) * fact(n-r)) > end > > MP.WhateverA = whatever > > function MP.WhateverB(n,r) > mp.quoted("%.0f",whatever(n,r)) > end > > function MP.WhateverC(n,r) > mp.quoted([[$\displaystyle{%.0f\choose %.0f} = %.0f$]],n,r,whatever(n,r)) > end > > function MP.WhateverD(n,r) > mp.quoted([[\MyWhatever{%.0f}{%.0f}{%.0f}]],n,r,whatever(n,r)) > end > \stopluacode > > \startbuffer[fig121] >numeric n, r, s, u, dx, dy, tt; >path p, q ; pair A, B, start, now; >u := 1.8cm; >A := dir(210)*u; >B := dir(-30)*u; >dy := sind(30)*u; >dx := 2*cosd(30)*u; >for n = 0 upto 4: >start := n*dir(210)*u; >for r = 0 upto n: >s := n - r; > now := start + r*right*dx; >draw (now + A) -- now -- (now + B); > >tt := lua.MP.WhateverA(n,r) ; > >dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & > decimal r & "} = "& decimal tt & "$"),now); > >dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & > decimal r & "} = "& lua.MP.WhateverB(n,r) & "$"),now); > >dotlabel.top(textext(lua.MP.WhateverC(n,r)),now); > >dotlabel.top(textext(lua.MP.WhateverD(n,r)),now); > >endfor; >endfor; > \stopbuffer > > \starttext > >{\switchtobodyfont[11pt]\processMPbuffer[fig121]} > > \stoptext > > > > - > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] running lua in metafun and in ConTeXt
On 4/11/2020 4:15 PM, Jeong Dal wrote: Dear all, The problem is solved by using the namespace of lua as below: I am not sure what I did is the right way. If it is not the right way, please let me know. Thanks for reading. Best regards, Dalyoung \startluacode P={} combi = P function P.fact (n) if n <= 0 then return 1 else return n * P.fact(n-1) end end function P.ncr(n,r) return P.fact(n)/(P.fact(r)*P.fact(n-r)) end combi = { fact = fact, ncr = ncr, } \stopluacode \startbuffer[fig121] numeric n,r,s,u,dx,dy,tt; u := 1.8cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 4: start := n*dir(210)*u; for r=0 upto n: s := n-r; % tt := lua("mp.print(P.fact(" & decimal n & ")/(P.fact(" & decimal r & ")*P.fact(" & decimal s &" )))"); tt := lua("mp.print(P.ncr(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); draw now -- (now+A); draw now -- (now+B); endfor; endfor; \stopbuffer Sunday afternoon educational moment (that you can wikify), four variants: 1 : A more metafunish alternative of your example. 2 : The same but avoiding a temporary variable. 3 : Less code and clutter, the real deal. 4 : Idem, but permits more tuning at the TeX end. \unexpanded\def\MyWhatever#1#2#3% {$\displaystyle{#1\choose #2} = #3$} \startluacode local function fact(n) if n <= 0 then return 1 else return n * fact(n - 1) end end local function whatever(n,r) return fact(n) / (fact(r) * fact(n-r)) end MP.WhateverA = whatever function MP.WhateverB(n,r) mp.quoted("%.0f",whatever(n,r)) end function MP.WhateverC(n,r) mp.quoted([[$\displaystyle{%.0f\choose %.0f} = %.0f$]],n,r,whatever(n,r)) end function MP.WhateverD(n,r) mp.quoted([[\MyWhatever{%.0f}{%.0f}{%.0f}]],n,r,whatever(n,r)) end \stopluacode \startbuffer[fig121] numeric n, r, s, u, dx, dy, tt; path p, q ; pair A, B, start, now; u := 1.8cm; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n = 0 upto 4: start := n*dir(210)*u; for r = 0 upto n: s := n - r; now := start + r*right*dx; draw (now + A) -- now -- (now + B); tt := lua.MP.WhateverA(n,r) ; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& lua.MP.WhateverB(n,r) & "$"),now); dotlabel.top(textext(lua.MP.WhateverC(n,r)),now); dotlabel.top(textext(lua.MP.WhateverD(n,r)),now); endfor; endfor; \stopbuffer \starttext {\switchtobodyfont[11pt]\processMPbuffer[fig121]} \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] running lua in metafun and in ConTeXt
Hi Dalyoung, I tested your code: it works fine with both definitions of the variable tt in your code. I am using the current LMTX version 2020.04.08 14:38. Best regards: Otared > On 11 Apr 2020, at 14:32, Jeong Dal wrote: > > Dear all, > > I draw Pascal’s triangle with the label of each point created by using lua > functions. > As you see in the code below, I defined fact(n) and combi(n,r) using lua. > For the calculation tt, I used two different methods. > Both are working well when I run the given code. > > But I got an error, when I added this code to a ConTeXt file composed product > and components, > and using the second method, i.e. combi(n,r). The first method is still > working well. > The error message is as following: > > metapost log> loading metafun, including plain.mp version 1.004 for > metafun iv and xl > metapost log> > luatex warning > mplib: run script: [string "return mp.print(combi(0,0 > ))"]:1: attempt to call a nil value (global 'combi') > > metapost log> >> tt > metapost log> >> vacuous > metapost log> ! Equation cannot be performed (numeric=vacuous). > metapost log> > metapost log>; > metapost log> ...(0)&","(EXPR0)&" ))"); > metapost log> > now:=start+(EXPR0)*right*d... > metapost log> now--(now+A);draw.now--(now+B);endfor > metapost log> ; ENDFOR > metapost log> <*> ...now+A); draw now -- (now+B); endfor; endfor > metapost log> ;; > > I don’t know why the same code treated differently. > I think that I have to do something more in luacode which I don’t know. > Comments are wellcome! > > Best regards, > > Dalyoung > > %%% > > \startluacode > function fact (n) > if n <= 0 then > return 1 > else > return n * fact(n-1) > end > end > function combi(n,r) >return fact(n)/(fact(r)*fact(n-r)) > end > \stopluacode > \startbuffer[fig121] > numeric n,r,s,u,dx,dy,tt; u := 1.8cm; > path p, q; > pair A,B,start,now; > A := dir(210)*u; > B := dir(-30)*u; > dy := sind(30)*u; > dx := 2*cosd(30)*u; > for n=0 upto 4: >start := n*dir(210)*u; >for r=0 upto n: > s := n-r; > % tt := lua("mp.print(fact(" & decimal n & ")/(fact(" & decimal r & > ")*fact(" & decimal s &" )))"); > tt := lua("mp.print(combi(" & decimal n & "," & decimal r & " ))"); > > now := start+r*right*dx; > dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & > decimal r & "} = "& decimal tt & "$"),now); > draw now -- (now+A); > draw now -- (now+B); >endfor; > endfor; > \stopbuffer > \starttext > \switchtobodyfont[11pt] > \processMPbuffer[fig121] > \switchtobodyfont[12pt] > \stoptext > > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] running lua in metafun and in ConTeXt
Dear all, I draw Pascal’s triangle with the label of each point created by using lua functions. As you see in the code below, I defined fact(n) and combi(n,r) using lua. For the calculation tt, I used two different methods. Both are working well when I run the given code. But I got an error, when I added this code to a ConTeXt file composed product and components, and using the second method, i.e. combi(n,r). The first method is still working well. The error message is as following: metapost log> loading metafun, including plain.mp version 1.004 for metafun iv and xl metapost log> luatex warning > mplib: run script: [string "return mp.print(combi(0,0 ))"]:1: attempt to call a nil value (global 'combi') metapost log> >> tt metapost log> >> vacuous metapost log> ! Equation cannot be performed (numeric=vacuous). metapost log> metapost log>; metapost log> ...(0)&","(EXPR0)&" ))"); metapost log> now:=start+(EXPR0)*right*d... metapost log> now--(now+A);draw.now--(now+B);endfor metapost log> ; ENDFOR metapost log> <*> ...now+A); draw now -- (now+B); endfor; endfor metapost log> ;; I don’t know why the same code treated differently. I think that I have to do something more in luacode which I don’t know. Comments are wellcome! Best regards, Dalyoung %%% \startluacode function fact (n) if n <= 0 then return 1 else return n * fact(n-1) end end function combi(n,r) return fact(n)/(fact(r)*fact(n-r)) end \stopluacode \startbuffer[fig121] numeric n,r,s,u,dx,dy,tt; u := 1.8cm; path p, q; pair A,B,start,now; A := dir(210)*u; B := dir(-30)*u; dy := sind(30)*u; dx := 2*cosd(30)*u; for n=0 upto 4: start := n*dir(210)*u; for r=0 upto n: s := n-r; % tt := lua("mp.print(fact(" & decimal n & ")/(fact(" & decimal r & ")*fact(" & decimal s &" )))"); tt := lua("mp.print(combi(" & decimal n & "," & decimal r & " ))"); now := start+r*right*dx; dotlabel.top(textext("$\displaystyle {" & decimal n & "\choose" & decimal r & "} = "& decimal tt & "$"),now); draw now -- (now+A); draw now -- (now+B); endfor; endfor; \stopbuffer \starttext \switchtobodyfont[11pt] \processMPbuffer[fig121] \switchtobodyfont[12pt] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] margintext and floats in the margin
Dear Otared, Please have a look at: https://www.mail-archive.com/ntg-context@ntg.nl/msg63579.html <https://www.mail-archive.com/ntg-context@ntg.nl/msg63579.html> Kind regards, Jan Willem Flamma > On 29 Jan 2020, at 09:30, Otared Kavian wrote: > > Hi, > > Is it possible to put some short notes in the margin, together with a float? > Below is an example, which puts the float on top of the text in the margin. > The option « stack=yes » works fine for the margintext when there is no > float, but it does not seems to be an option which puts the figure and > margintext in a sort of stack. > > Thanks for any advice: Otared K. > > % begin margintext-float.tex > \setuppapersize[A4][A4] > \setuplayout[ > width=120mm, > leftmargin=25mm,rightmargin=50mm] > > \setupmargindata[margintext] > [align=raggedright, > stack=yes, > location=outer, > style={\rm}] > > \showframe > \startbuffer[sine] > numeric u ; u = 5mm ; > draw function (1,"x","1.5*sin(x)",0,710/113,.01) scaled u > withcolor transparent(1,.5,darkblue) > withpen pencircle scaled 2pt ; > \stopbuffer > > \starttext > > This is some text.\margintext{This is a remark in the margin.} > This is some more text.\margintext{This text is also in the margin.} > \startplacefigure[location=outermargin,number=no] > \scale[width=\rightmarginwidth]{\processMPbuffer[sine]} > \stopplacefigure > > \stoptext > % end margintext-float.tex > > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] margintext and floats in the margin
Hi, Is it possible to put some short notes in the margin, together with a float? Below is an example, which puts the float on top of the text in the margin. The option « stack=yes » works fine for the margintext when there is no float, but it does not seems to be an option which puts the figure and margintext in a sort of stack. Thanks for any advice: Otared K. % begin margintext-float.tex \setuppapersize[A4][A4] \setuplayout[ width=120mm, leftmargin=25mm,rightmargin=50mm] \setupmargindata[margintext] [align=raggedright, stack=yes, location=outer, style={\rm}] \showframe \startbuffer[sine] numeric u ; u = 5mm ; draw function (1,"x","1.5*sin(x)",0,710/113,.01) scaled u withcolor transparent(1,.5,darkblue) withpen pencircle scaled 2pt ; \stopbuffer \starttext This is some text.\margintext{This is a remark in the margin.} This is some more text.\margintext{This text is also in the margin.} \startplacefigure[location=outermargin,number=no] \scale[width=\rightmarginwidth]{\processMPbuffer[sine]} \stopplacefigure \stoptext % end margintext-float.tex ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] margintext and floats in the margin
Hi, Is it possible to put some short notes in the margin, together with a float? Below is an example, which puts the float on top of the text in the margin. The option « stack=yes » works fine for the margintext when there is no float, but it does not seems to be an option which puts the figure and margintext in a sort of stack. Thanks for any advice: Otared K. % begin margintext-float.tex \setuppapersize[A4][A4] \setuplayout[ width=120mm, leftmargin=25mm,rightmargin=50mm] \setupmargindata[margintext] [align=raggedright, stack=yes, location=outer, style={\rm}] \showframe \startbuffer[sine] numeric u ; u = 5mm ; draw function (1,"x","1.5*sin(x)",0,710/113,.01) scaled u withcolor transparent(1,.5,darkblue) withpen pencircle scaled 2pt ; \stopbuffer \starttext This is some text.\margintext{This is a remark in the margin.} This is some more text.\margintext{This text is also in the margin.} \startplacefigure[location=outermargin,number=no] \scale[width=\rightmarginwidth]{\processMPbuffer[sine]} \stopplacefigure \stoptext % end margintext-float.tex ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaFun: how to check the number of arguments
On 1/16/2019 12:53 AM, Jeong Dal wrote: Dear Hans, Thank you for a solution. In my memory, it is possible to check the argument in Lua, so I hope that there is a similar method in MetaFun. It may be easier to draw grid using lines instead of squares. vardef textlength(text t) = save n ; n := 0 ; for i = t : n := n + 1 ; endfor; n enddef; def drawGridF (expr nb) (text s) = if textlength(s) = 0 : draw textext("A grid!"); else : path p ; picture pic ; numeric n; p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; fi ; enddef; Thank you again. Best regards, Dalyoung 2019. 1. 16. 오전 2:04, Hans Hagen <mailto:j.ha...@xs4all.nl>> 작성: On 1/14/2019 10:44 PM, Jeong Dal wrote: Dear all, In the following sample, it draws squares with label which is given. I’d like to know how to check the number of elements in the second argument? If it is 0, then I just draw grids only. Thank you for reading. Best regards, Dalyoung \startbuffer[defs] def drawGridF (expr nb) (text s) = p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; enddef; \stopbuffer \startbuffer[3x3b] wu := \MPvar{width}; drawGridF (3) (1,2,3,0,1, 1,4,5,8); \stopbuffer \starttext \setupMPvariables[width=30pt] \processMPbuffer[defs,3x3b] \stoptext \startbuffer[defs] def drawGridF (expr nb) (text s) = path p ; picture pic ; numeric n; p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; if n == 0 : draw textext("A grid!"); fi ; enddef; \stopbuffer \startbuffer[3x3b] wu := \MPvar{width}; drawGridF (3) (1,2,3,0,1, 1,4,5,8); currentpicture := currentpicture shifted (bbwidth(currentpicture),0); drawGridF (3) (); \stopbuffer \setupMPvariables[width=30pt] \processMPbuffer[defs,3x3b] 2019. 1. 14. 오후 8:00, ntg-context-requ...@ntg.nl <mailto:ntg-context-requ...@ntg.nl> 작성: Send ntg-context mailing list submissions to ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> To subscribe or unsubscribe via the World Wide Web, visit https://mailman.ntg.nl/mailman/listinfo/ntg-context or, via email, send a message with subject or body 'help' to ntg-context-requ...@ntg.nl You can reach the person managing the list at ntg-context-ow...@ntg.nl When replying, please edit your Subject line so it is more specific than "Re: Contents of ntg-context digest..." Today's Topics: 1. Re: Manipulating the left blank page when chapter starts on the right page (Wolfgang Schuster) 2. Re: Footnotes in float combinations missing in output (Wolfgang Schuster) 3. Re: Manipulating the left blank page when chapter starts on the right page (Jan U. Hasecke) -- Message: 1 Date: Sun, 13 Jan 2019 16:56:40 +0100 From: Wolfgang Schuster To: mailing list for ConTeXt users , "Jan U. Hasecke" Subject: Re: [NTG-context] Manipulating the left blank page when chapter starts on the right page Message-ID: Content-Type: text/plain; charset=utf-8; format=flowed Jan U. Hasecke schrieb am 12.01.19 um 22:08: Hi Aditya, Am 12.01.19 um 20:11 schrieb Aditya Mahajan: On Sat, 12 Jan 2019, Jan U. Hasecke wrote: Hi all, in my document \startchapter and \starttitle starts a new chapter on the right (odd) page. So sometimes, there is a blank even page just before a new chapter. I would like to manipulate this blank even page. There are several things I would like to do, eg. having no headers and footers, setting the background color to a named color, placing an image or some graphics on the page. Is there a way to define such a page, name it and call it in \startchapter so that it is placed on the left side. See https://tex.stackexchange.com/q/457428/323 Thanks a lot, but I wasn't looking for a way to just delete page numbers but to style the empty page in arbitrary ways. Maybe it is better to do this manually. I would let chapter open on even pages too and just insert a styled page by hand. Here is a example which shows how you can change the background color of a empty page before the chapter title. \setuppagenumbering [alternative=doublesided] \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=black] \page[empty,right] \popbackground} \stopsetups \setuphead [chapter] [page=yes, before=\directsetup{chapter:before}] \starttext \startchapter[t
Re: [NTG-context] MetaFun: how to check the number of arguments
Dear Hans, Thank you for a solution. In my memory, it is possible to check the argument in Lua, so I hope that there is a similar method in MetaFun. It may be easier to draw grid using lines instead of squares. Thank you again. Best regards, Dalyoung > 2019. 1. 16. 오전 2:04, Hans Hagen 작성: > > On 1/14/2019 10:44 PM, Jeong Dal wrote: >> Dear all, >> In the following sample, it draws squares with label which is given. >> I’d like to know how to check the number of elements in the second argument? >> If it is 0, then I just draw grids only. >> Thank you for reading. >> Best regards, >> Dalyoung >> >> \startbuffer[defs] >> def drawGridF (expr nb) (text s) = >> p := unitsquare scaled wu; >> n:= 0; >> for m = s: >> i:= n mod nb; >> j:= n div nb; >> pic := image (draw p; label(textext(m), center p); ); >> draw pic shifted (i*wu, j*wu); >> n:= n+ 1; >> endfor; >> enddef; >> \stopbuffer >> \startbuffer[3x3b] >> wu := \MPvar{width}; >> drawGridF (3) (1,2,3,0,1, 1,4,5,8); >> \stopbuffer >> \starttext >> \setupMPvariables[width=30pt] >> \processMPbuffer[defs,3x3b] >> \stoptext > > > \startbuffer[defs] > def drawGridF (expr nb) (text s) = >path p ; >picture pic ; >numeric n; > p := unitsquare scaled wu; > n:= 0; > for m = s: > i:= n mod nb; > j:= n div nb; > pic := image (draw p; label(textext(m), center p); ); > draw pic shifted (i*wu, j*wu); > n:= n+ 1; > endfor; >if n == 0 : >draw textext("A grid!"); >fi ; > enddef; > \stopbuffer > > \startbuffer[3x3b] > wu := \MPvar{width}; > drawGridF (3) (1,2,3,0,1, 1,4,5,8); > currentpicture := currentpicture shifted (bbwidth(currentpicture),0); > drawGridF (3) (); > \stopbuffer > > \setupMPvariables[width=30pt] > \processMPbuffer[defs,3x3b] > > > > >>> 2019. 1. 14. 오후 8:00, ntg-context-requ...@ntg.nl 작성: >>> >>> Send ntg-context mailing list submissions to >>> ntg-context@ntg.nl >>> >>> To subscribe or unsubscribe via the World Wide Web, visit >>> https://mailman.ntg.nl/mailman/listinfo/ntg-context >>> or, via email, send a message with subject or body 'help' to >>> ntg-context-requ...@ntg.nl >>> >>> You can reach the person managing the list at >>> ntg-context-ow...@ntg.nl >>> >>> When replying, please edit your Subject line so it is more specific >>> than "Re: Contents of ntg-context digest..." >>> >>> >>> Today's Topics: >>> >>> 1. Re: Manipulating the left blank page when chapter starts on >>> the right page (Wolfgang Schuster) >>> 2. Re: Footnotes in float combinations missing in output >>> (Wolfgang Schuster) >>> 3. Re: Manipulating the left blank page when chapter starts on >>> the right page (Jan U. Hasecke) >>> >>> >>> -- >>> >>> Message: 1 >>> Date: Sun, 13 Jan 2019 16:56:40 +0100 >>> From: Wolfgang Schuster >>> To: mailing list for ConTeXt users , "Jan U. >>> Hasecke" >>> Subject: Re: [NTG-context] Manipulating the left blank page when >>> chapter starts on the right page >>> Message-ID: >>> Content-Type: text/plain; charset=utf-8; format=flowed >>> >>> Jan U. Hasecke schrieb am 12.01.19 um 22:08: >>>> Hi Aditya, >>>> >>>> Am 12.01.19 um 20:11 schrieb Aditya Mahajan: >>>>> On Sat, 12 Jan 2019, Jan U. Hasecke wrote: >>>>> >>>>>> Hi all, >>>>>> >>>>>> in my document \startchapter and \starttitle starts a new chapter on the >>>>>> right (odd) page. So sometimes, there is a blank even page just before a >>>>>> new chapter. >>>>>> >>>>>> I would like to manipulate this blank even page. >>>>>> >>>>>> There are several things I would like to do, eg. having no headers and >>>>>> footers, setting the background color to a named color, placing an image >>>>>> or some graphics on the page. >>>>>> >>>>>> Is there a way to define such a page, name it and ca
Re: [NTG-context] MetaFun: how to check the number of arguments
On 1/14/2019 10:44 PM, Jeong Dal wrote: Dear all, In the following sample, it draws squares with label which is given. I’d like to know how to check the number of elements in the second argument? If it is 0, then I just draw grids only. Thank you for reading. Best regards, Dalyoung \startbuffer[defs] def drawGridF (expr nb) (text s) = p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; enddef; \stopbuffer \startbuffer[3x3b] wu := \MPvar{width}; drawGridF (3) (1,2,3,0,1, 1,4,5,8); \stopbuffer \starttext \setupMPvariables[width=30pt] \processMPbuffer[defs,3x3b] \stoptext \startbuffer[defs] def drawGridF (expr nb) (text s) = path p ; picture pic ; numeric n; p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; if n == 0 : draw textext("A grid!"); fi ; enddef; \stopbuffer \startbuffer[3x3b] wu := \MPvar{width}; drawGridF (3) (1,2,3,0,1, 1,4,5,8); currentpicture := currentpicture shifted (bbwidth(currentpicture),0); drawGridF (3) (); \stopbuffer \setupMPvariables[width=30pt] \processMPbuffer[defs,3x3b] 2019. 1. 14. 오후 8:00, ntg-context-requ...@ntg.nl 작성: Send ntg-context mailing list submissions to ntg-context@ntg.nl To subscribe or unsubscribe via the World Wide Web, visit https://mailman.ntg.nl/mailman/listinfo/ntg-context or, via email, send a message with subject or body 'help' to ntg-context-requ...@ntg.nl You can reach the person managing the list at ntg-context-ow...@ntg.nl When replying, please edit your Subject line so it is more specific than "Re: Contents of ntg-context digest..." Today's Topics: 1. Re: Manipulating the left blank page when chapter starts on the right page (Wolfgang Schuster) 2. Re: Footnotes in float combinations missing in output (Wolfgang Schuster) 3. Re: Manipulating the left blank page when chapter starts on the right page (Jan U. Hasecke) -- Message: 1 Date: Sun, 13 Jan 2019 16:56:40 +0100 From: Wolfgang Schuster To: mailing list for ConTeXt users , "Jan U. Hasecke" Subject: Re: [NTG-context] Manipulating the left blank page when chapter starts on the right page Message-ID: Content-Type: text/plain; charset=utf-8; format=flowed Jan U. Hasecke schrieb am 12.01.19 um 22:08: Hi Aditya, Am 12.01.19 um 20:11 schrieb Aditya Mahajan: On Sat, 12 Jan 2019, Jan U. Hasecke wrote: Hi all, in my document \startchapter and \starttitle starts a new chapter on the right (odd) page. So sometimes, there is a blank even page just before a new chapter. I would like to manipulate this blank even page. There are several things I would like to do, eg. having no headers and footers, setting the background color to a named color, placing an image or some graphics on the page. Is there a way to define such a page, name it and call it in \startchapter so that it is placed on the left side. See https://tex.stackexchange.com/q/457428/323 Thanks a lot, but I wasn't looking for a way to just delete page numbers but to style the empty page in arbitrary ways. Maybe it is better to do this manually. I would let chapter open on even pages too and just insert a styled page by hand. Here is a example which shows how you can change the background color of a empty page before the chapter title. \setuppagenumbering [alternative=doublesided] \startsetups [chapter:before] \doifoddpageelse {} {\pushbackground[page] \setupbackgrounds[page][background=color,backgroundcolor=black] \page[empty,right] \popbackground} \stopsetups \setuphead [chapter] [page=yes, before=\directsetup{chapter:before}] \starttext \startchapter[title={Knuth}] \dorecurse{10}{\samplefile{knuth}} \stopchapter \startchapter[title={Zapf}] \dorecurse{10}{\samplefile{zapf}} \stopchapter \startchapter[title={Ward}] \dorecurse{10}{\samplefile{ward}} \stopchapter \stoptext Wolfgang -- Message: 2 Date: Sun, 13 Jan 2019 21:06:42 +0100 From: Wolfgang Schuster To: mailing list for ConTeXt users , Lars Subject: Re: [NTG-context] Footnotes in float combinations missing in output Message-ID: Content-Type: text/plain; charset=utf-8; format=flowed Lars schrieb am 09.01.19 um 23:01: Hi there, hi Hans, I just want to let you know that footnotes insterted in float-combinations don't get rendered properly, i. e. only the last footnote is placed i
[NTG-context] MetaFun: how to check the number of arguments
Dear all, In the following sample, it draws squares with label which is given. I’d like to know how to check the number of elements in the second argument? If it is 0, then I just draw grids only. Thank you for reading. Best regards, Dalyoung \startbuffer[defs] def drawGridF (expr nb) (text s) = p := unitsquare scaled wu; n:= 0; for m = s: i:= n mod nb; j:= n div nb; pic := image (draw p; label(textext(m), center p); ); draw pic shifted (i*wu, j*wu); n:= n+ 1; endfor; enddef; \stopbuffer \startbuffer[3x3b] wu := \MPvar{width}; drawGridF (3) (1,2,3,0,1, 1,4,5,8); \stopbuffer \starttext \setupMPvariables[width=30pt] \processMPbuffer[defs,3x3b] \stoptext > 2019. 1. 14. 오후 8:00, ntg-context-requ...@ntg.nl 작성: > > Send ntg-context mailing list submissions to > ntg-context@ntg.nl > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.ntg.nl/mailman/listinfo/ntg-context > or, via email, send a message with subject or body 'help' to > ntg-context-requ...@ntg.nl > > You can reach the person managing the list at > ntg-context-ow...@ntg.nl > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of ntg-context digest..." > > > Today's Topics: > > 1. Re: Manipulating the left blank page when chapter starts on > the right page (Wolfgang Schuster) > 2. Re: Footnotes in float combinations missing in output > (Wolfgang Schuster) > 3. Re: Manipulating the left blank page when chapter starts on > the right page (Jan U. Hasecke) > > > -- > > Message: 1 > Date: Sun, 13 Jan 2019 16:56:40 +0100 > From: Wolfgang Schuster > To: mailing list for ConTeXt users , "Jan U. > Hasecke" > Subject: Re: [NTG-context] Manipulating the left blank page when > chapter starts on the right page > Message-ID: > Content-Type: text/plain; charset=utf-8; format=flowed > > Jan U. Hasecke schrieb am 12.01.19 um 22:08: >> Hi Aditya, >> >> Am 12.01.19 um 20:11 schrieb Aditya Mahajan: >>> On Sat, 12 Jan 2019, Jan U. Hasecke wrote: >>> >>>> Hi all, >>>> >>>> in my document \startchapter and \starttitle starts a new chapter on the >>>> right (odd) page. So sometimes, there is a blank even page just before a >>>> new chapter. >>>> >>>> I would like to manipulate this blank even page. >>>> >>>> There are several things I would like to do, eg. having no headers and >>>> footers, setting the background color to a named color, placing an image >>>> or some graphics on the page. >>>> >>>> Is there a way to define such a page, name it and call it in >>>> \startchapter so that it is placed on the left side. >>> See https://tex.stackexchange.com/q/457428/323 >> Thanks a lot, but I wasn't looking for a way to just delete page numbers >> but to style the empty page in arbitrary ways. >> >> Maybe it is better to do this manually. >> >> I would let chapter open on even pages too and just insert a styled page >> by hand. > > Here is a example which shows how you can change the background color > of a empty page before the chapter title. > > \setuppagenumbering > [alternative=doublesided] > > \startsetups [chapter:before] > \doifoddpageelse > {} > {\pushbackground[page] > \setupbackgrounds[page][background=color,backgroundcolor=black] > \page[empty,right] > \popbackground} > \stopsetups > > \setuphead > [chapter] > [page=yes, >before=\directsetup{chapter:before}] > > \starttext > > \startchapter[title={Knuth}] > \dorecurse{10}{\samplefile{knuth}} > \stopchapter > > \startchapter[title={Zapf}] > \dorecurse{10}{\samplefile{zapf}} > \stopchapter > > \startchapter[title={Ward}] > \dorecurse{10}{\samplefile{ward}} > \stopchapter > > \stoptext > > Wolfgang > > > > -- > > Message: 2 > Date: Sun, 13 Jan 2019 21:06:42 +0100 > From: Wolfgang Schuster > To: mailing list for ConTeXt users , Lars > > Subject: Re: [NTG-context] Footnotes in float combinations missing in > output > Message-ID: > Content-Type: text/plain; charset=utf-8; format=flowed > > Lars schrieb am 09.01.19 um 23:01: >> Hi there, hi Hans, >> >> I just want to let you know that footnotes insterted in >> float-combinatio
Re: [NTG-context] Metafun: Finding intersection between characters
Dear Hans, I have tested using your code. I just replace “N”, “T” with Korean letters. Here is an MWE which is a simplified version of your code. I tested using two fonts, and the outputs are different. Thank you for your concern. Best regards, Dalyoung %%% \usetypescriptfile[type-hcrlvt] \usetypescript[HcrFont] \setupbodyfont[Myface, rm, 12pt] %\setupbodyfont[unfonts, rm, 12pt] \startMPdefinitions def filloutlinetext(expr o) = draw image ( save n, m ; numeric n, m ; n := m := 0 ; for i within o : n := n + 1 ; endfor ; for i within o : m := m + 1 ; if n = m : eofill else : nofill fi pathpart i ; endfor ; ) enddef ; def drawoutlinetext(expr o) = draw image ( % nicer for properties for i within o : draw pathpart i ; endfor ; ) enddef ; def outlinetexttopath(text o, p, n) = scantokens("numeric " & str n & ";") ; scantokens("path "& str p & "[];") ; n := 0 ; for i within o : p[incr(n)] := pathpart i ; endfor ; enddef ; \stopMPdefinitions \startbuffer[ho] picture first ; first := outlinetext.p("호") ; first := first scaled 10 ; filloutlinetext(first ) withcolor .5[blue,white] ; drawoutlinetext(first ) ; \stopbuffer \startbuffer[ha] picture first ; first := outlinetext.p("하") ; first := first scaled 10 ; filloutlinetext(first ) withcolor .5[blue,white] ; drawoutlinetext(first ) ; \stopbuffer \startbuffer[wang] picture first ; first := outlinetext.p("왕") ; first := first scaled 10 ; filloutlinetext(first ) withcolor .5[blue,white] ; drawoutlinetext(first ) ; \stopbuffer \starttext \processMPbuffer[ho] \processMPbuffer[ha] \processMPbuffer[wang] \stoptext %%% type-hcrlvt.mkiv Description: Binary data ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] labeling in meta post
On 07/09/18 10:55, Jeong Dal wrote: > Hi, > > What is the difference between {\delta} and \delta? > Former is OK, but the second is not compiled. > > Here is a MWE. > > > \startbuffer[delta] > label.bot(btex ${\delta}$ etex, (1cm,0)); % > %label.bot(btex $\delta$ etex, (3cm,0)); Why not just label.bot("$\delta$", (3cm,0)); > label.bot(btex $\frac{2-\delta}{2}$ etex, (5cm,0)); % > \stopbuffer > \starttext > \processMPbuffer[delta] > \stoptext > > Best regards, > > Dalyoung > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > ___ > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] labeling in meta post
Hi, What is the difference between {\delta} and \delta? Former is OK, but the second is not compiled. Here is a MWE. \startbuffer[delta] label.bot(btex ${\delta}$ etex, (1cm,0)); % %label.bot(btex $\delta$ etex, (3cm,0)); label.bot(btex $\frac{2-\delta}{2}$ etex, (5cm,0)); % \stopbuffer \starttext \processMPbuffer[delta] \stoptext Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] metafun: error when I call the same function twice consecutively.
On 01/06/18 14:22, Jeong Dal wrote: Hi, I defined a function using MetaFun, and call it to draw a figure. It is OK when I call it once. But there is an error when it runs the same function second time. (it stops when it call fap(3,2) after fap(2,2)) I have no idea what is wrong and how to fix it. Would you please tell me what I miss? You have to save x, y; otherwise z[i] = ... will be an ill-defined equation. \startMPpage numeric u; u := 1cm; path p[]; def fap(expr n, m) = begingroup ; save x, y ; numeric size ; size := m*u ; for i = 0 upto (n*n-1): z[i] = ((i mod n),(floor(i/n)))*size; drawdot z[i] withpen pencircle scaled 5pt withcolor blue; endfor ; endgroup ; enddef; fap(2,2); fap(3,2); \stopMPpage Thank you. Best regards, Dalyoung %%% \startbuffer[test] numeric u; u := 1cm; path p[]; def fap(expr n, m) = numeric size; size := m*u; for i = 0 upto (n*n-1): z[i] = ((i mod n),(floor(i/n)))*size; drawdot z[i] withpen pencircle scaled 5pt withcolor blue; endfor; enddef; fap(2,2); fap(3,2); \stopbuffer \starttext \processMPbuffer[test] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] metafun: error when I call the same function twice consecutively.
Hi, I defined a function using MetaFun, and call it to draw a figure. It is OK when I call it once. But there is an error when it runs the same function second time. (it stops when it call fap(3,2) after fap(2,2)) I have no idea what is wrong and how to fix it. Would you please tell me what I miss? Thank you. Best regards, Dalyoung %%% \startbuffer[test] numeric u; u := 1cm; path p[]; def fap(expr n, m) = numeric size; size := m*u; for i = 0 upto (n*n-1): z[i] = ((i mod n),(floor(i/n)))*size; drawdot z[i] withpen pencircle scaled 5pt withcolor blue; endfor; enddef; fap(2,2); fap(3,2); \stopbuffer \starttext \processMPbuffer[test] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] blank line at the beginning of the theorem or proof
Dear all, placing a figure at the right or left of the text using \placefigure[right][]{}{} insert at the begining of the paragraph under the enumerations while there is no blank line if we comment out \placefigure. See the below sample. Is there a way to make text begin from the same line of “Theorem 1” with the figure at the right? Thank you. Best regards, Dalyoung \defineenumeration[Theorem] [text={\translate[en=Theorem, kr=정리]}, style=, title=yes, prefix=yes, prefixsegments=chapter, way=bychapter, number=yes, before={\blank[big]}, after=\blank] \defineenumeration[Proof] [text={\translate[en=Proof, kr=증명]}, % headstyle=bold, alternative=hanging, titlestyle=, style=normal, number=no, closesymbol=\mathematics{\blacksquare},] \startbuffer[circleA] draw fullcircle scaled 2cm; \stopbuffer \starttext \startTheorem %\placefigure[right][]{}{\processMPbuffer[circleA]} This is a test for placing a figure in the theorem or in the proof. \tex{placefigure[right][]{}{\processMPbuffer[circleA]}} insert a blank line at the beginning of the paragraph while there is no blank line without a figure. %\placefigure[right][]{}{\processMPbuffer[circleA]} \stopTheorem \startProof %\placefigure[right][]{}{\processMPbuffer[circleA]} \input knuth \stopProof \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] getting the glyph of a character
MetaPost's documentation mentions that glyph operator works on Adobe Type 1 fonts. Does it also work with OpenType fonts when used from within LuaTeX and CONTEXT? On Mon, May 1, 2017 at 7:36 PM, Jeong Dal <hak...@me.com> wrote: > Dear all, > > First of all, the sample code is working under the ConTeXt > beta(standalone) installed in my notebook. > I am very sorry to send mails of false result. > > I found the file “lm-ec.map” installed in the ConTeXt beta(standalone), > and I don’t know why it was not working in the iMac. I have to check the > installation. > > However, I’d like to know how to make map files of the fonts in the system > for which the map file is not provided? > > Thank you for reading. > > Best regards, > > Dalyoung > > > \startbuffer[outline] > fontmapfile "=lm-ec.map"; > %beginfig(56); > picture q; > path p; > interim ahlength := 12bp; > interim ahangle := 25; > q := glyph “E" of "ec-lmr10" scaled .2; > %draw q; > for item within q: > p := pathpart item; > draw p withcolor (.6,.9,.6) > withpen pencircle scaled 1.5; > endfor > \stopbuffer > > \starttext > \processMPbuffer[outline] > \stoptext > > ___ > If your question is of interest to others as well, please add an entry to > the Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/ > listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : http://contextgarden.net > > ___ > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] getting the glyph of a character
Dear all, First of all, the sample code is working under the ConTeXt beta(standalone) installed in my notebook. I am very sorry to send mails of false result. I found the file “lm-ec.map” installed in the ConTeXt beta(standalone), and I don’t know why it was not working in the iMac. I have to check the installation. However, I’d like to know how to make map files of the fonts in the system for which the map file is not provided? Thank you for reading. Best regards, Dalyoung \startbuffer[outline] fontmapfile "=lm-ec.map"; %beginfig(56); picture q; path p; interim ahlength := 12bp; interim ahangle := 25; q := glyph “E" of "ec-lmr10" scaled .2; %draw q; for item within q: p := pathpart item; draw p withcolor (.6,.9,.6) withpen pencircle scaled 1.5; endfor \stopbuffer \starttext \processMPbuffer[outline] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] getting the glyph of a character
Dear all, In the previous mail, I tested the given code under the ConTeXt beta(standalone) which has no file “lm-ec.map” installed, so I couldn’t get the result. But the following sample is working under MKIV in TeXlive 2016. It looks great. I guess that it is also working any font if the map file is provided. If my guess is true, is it possible to make map files of the fonts in the system? Thank you for reading. Best regards, Dalyoung \startbuffer[outline] fontmapfile "=lm-ec.map"; %beginfig(56); picture q; path p; interim ahlength := 12bp; interim ahangle := 25; q := glyph “E" of "ec-lmr10" scaled .2; %draw q; for item within q: p := pathpart item; draw p withcolor (.6,.9,.6) withpen pencircle scaled 1.5; endfor \stopbuffer \starttext \processMPbuffer[outline] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] getting the glyph of a character
Dear all. At page 50-52 of the manual of metapost, “Mpman”, it is explained to get a glyph of font using the command ‘glyph'. glyph ⟨numeric expression⟩ of ⟨string expression⟩ glyph ⟨string expression⟩ of ⟨string expression⟩ . Is it possible to do the similar thing in metafun? I couldn’t make it happen using the following code. \startbuffer[outline] %fontmapfile "=lm-ec.map"; picture q; path p; interim ahlength := 12bp; interim ahangle := 25; q := glyph 100 of "ArialMT"; %nfont defaultfont scaled defaultscale; draw q; \stopbuffer \starttext \processMPbuffer[outline] \stoptext if the first line “fontmapfile …” is alive, then fatal error occurred. Without it, it is running without error, but no output at all. I copied the sample code in mpman below. Thank you for reading. Best regards, Dalyoung fontmapfile “=lm-ec.map”; beginfig(56); picture q; path p; interim ahlength := 12bp; interim ahangle := 25; q := glyph "Dcaron" of "ec-lmr10" scaled .2; for item within q: p := pathpart item; drawarrow p withcolor (.6,.9,.6) withpen pencircle scaled 1.5; for j=0 upto length p: pickup pencircle scaled .7; draw (point j of p -- precontrol j of p) dashed evenly withcolor blue; draw (point j of p -- postcontrol j of p) dashed evenly withcolor blue; pickup pencircle scaled 3; draw precontrol j of p withcolor red; draw postcontrol j of p withcolor red; pickup pencircle scaled 2; draw point j of p withcolor black; endfor endfor endfig; > 2017. 4. 30. 오후 7:00, ntg-context-requ...@ntg.nl 작성: > > Send ntg-context mailing list submissions to > ntg-context@ntg.nl > > To subscribe or unsubscribe via the World Wide Web, visit > https://mailman.ntg.nl/mailman/listinfo/ntg-context > or, via email, send a message with subject or body 'help' to > ntg-context-requ...@ntg.nl > > You can reach the person managing the list at > ntg-context-ow...@ntg.nl > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of ntg-context digest..." > > > Today's Topics: > > 1. Re: Wrong redirection in contextgarden.net (Mojca Miklavec) > 2. Re: Wrong redirection in contextgarden.net (Nicola) > 3. Re: Wrong redirection in contextgarden.net (Mojca Miklavec) > 4. High-level command for translated names (Henri Menke) > 5. Re: High-level command for translated names (Wolfgang Schuster) > > > -- > > Message: 1 > Date: Sat, 29 Apr 2017 18:05:14 +0200 > From: Mojca Miklavec <mojca.miklavec.li...@gmail.com> > To: mailing list for ConTeXt users <ntg-context@ntg.nl> > Subject: Re: [NTG-context] Wrong redirection in contextgarden.net > Message-ID: > <calbomsbtkzqwa9k7vfnjoyacumyc3xs8hu9gg-pyx-yxmbx...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > On 29 April 2017 at 09:47, Nicola wrote: >> For a while now, when I connect to contextgarden.net, I get redirected >> to wiki.contextgarden.net// (note the double slash). Is it just me, or >> something to be fixed in the web site? > > The server uses >RedirectMatch permanent ^(.*)$ http://wiki.contextgarden.net/$1 > > I'm looking for a better suggestion. > > Mojca > > > -- > > Message: 2 > Date: Sat, 29 Apr 2017 20:25:20 +0200 > From: Nicola <nvitacolo...@gmail.com> > To: ntg-context@ntg.nl > Subject: Re: [NTG-context] Wrong redirection in contextgarden.net > Message-ID: <oe2lqb$ehk$1...@blaine.gmane.org> > Content-Type: text/plain; charset=utf-8; format=flowed > > On 29/04/2017 18:05, Mojca Miklavec wrote: >> On 29 April 2017 at 09:47, Nicola wrote: >>> For a while now, when I connect to contextgarden.net, I get redirected >>> to wiki.contextgarden.net// (note the double slash). Is it just me, or >>> something to be fixed in the web site? >> >> The server uses >>RedirectMatch permanent ^(.*)$ http://wiki.contextgarden.net/$1 >> >> I'm looking for a better suggestion. > > Wouldn't just > > Redirect permanent / http://wiki.contextgarden.net/ > > do? (It may be recursive if the virtual host is the same.) > > If not, how about: > > RedirectMatch permanent ^/(.*)$ http://wiki.contextgarden.net/$1 > > As a last resource, mod_rewrite should work: > > RewriteEngine on > RewriteCond %{HTTP_HOST} ^contextgarden\.net$ [NC] > RewriteRule ^(.*)$ http://wiki.contextgarden.net/$1 [R=301,L] > > Nicola > > > > > -- > > Message: 3 > Date: Sat, 29 Apr 2017 21:29:06 +0200 > From: Mojca Miklavec <mojca.miklavec.li...@gmail.com> > To: mailing list for ConTeXt users <ntg-context@ntg.nl> > Subject: Re: [NTG-context] Wrong redirection in contextgarden.net > Message-ID: >
Re: [NTG-context] buffers inside startMPpage
Thank you Wolfgang. This suits my needs just fine. Kind regards, Jan Willem Flamma > On 14 okt. 2016, at 10:34, Wolfgang Schuster <schuster.wolfg...@gmail.com> > wrote: > >> Jan Willem Flamma <mailto:jwfregis...@icloud.com> 14. Oktober 2016 um 10:12 >> Dear list members, >> >> I create all my MetaFun drawings in a separate environment file where each >> individual drawing sits inside a start/stopbuffer. This allows me to easily >> use those drawings in all my documents using \processMPbuffer[name]. Works >> just fine. >> >> However, I also wish to have all the drawing available in a pdf file (each >> drawing on a separate page). This allows me to split the pdf and use the >> drawing elsewhere (e.g. in a Powerpoint) or include page(s) from the pdf in >> another document. >> >> The below MWE represent my MetaFun drawings file. >> The idea is that by uncommenting the \enablemode[makepdf] I can create the >> pdf file with drawings. It seems however that startMPpage does not accept >> buffers (I also tried processbuffer and processMPbuffer). >> >> Is it possible to somehow make this work? > You can use > > \startTEXpage > \processMPbuffer[…] > \stopTEXpage > > but loading a buffer in MPpage doesn’t work because the content of the > environment > is just passed to MetaPost and buffers can’t be loaded inside MetaPost code > unless > Hans adds a function for this, e.g. > > \startMPcode > buffer("mybuffer") > \stopMPcode > > Wolfgang > ___ > If your question is of interest to others as well, please add an entry to the > Wiki! > > maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context > webpage : http://www.pragma-ade.nl / http://context.aanhet.net > archive : http://foundry.supelec.fr/projects/contextrev/ > wiki : http://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] buffers inside startMPpage
Jan Willem Flamma <mailto:jwfregis...@icloud.com> 14. Oktober 2016 um 10:12 Dear list members, I create all my MetaFun drawings in a separate environment file where each individual drawing sits inside a start/stopbuffer. This allows me to easily use those drawings in all my documents using \processMPbuffer[name]. Works just fine. However, I also wish to have all the drawing available in a pdf file (each drawing on a separate page). This allows me to split the pdf and use the drawing elsewhere (e.g. in a Powerpoint) or include page(s) from the pdf in another document. The below MWE represent my MetaFun drawings file. The idea is that by uncommenting the \enablemode[makepdf] I can create the pdf file with drawings. It seems however that startMPpage does not accept buffers (I also tried processbuffer and processMPbuffer). Is it possible to somehow make this work? You can use \startTEXpage \processMPbuffer[…] \stopTEXpage but loading a buffer in MPpage doesn’t work because the content of the environment is just passed to MetaPost and buffers can’t be loaded inside MetaPost code unless Hans adds a function for this, e.g. \startMPcode buffer("mybuffer") \stopMPcode Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] buffers inside startMPpage
Dear list members, I create all my MetaFun drawings in a separate environment file where each individual drawing sits inside a start/stopbuffer. This allows me to easily use those drawings in all my documents using \processMPbuffer[name]. Works just fine. However, I also wish to have all the drawing available in a pdf file (each drawing on a separate page). This allows me to split the pdf and use the drawing elsewhere (e.g. in a Powerpoint) or include page(s) from the pdf in another document. The below MWE represent my MetaFun drawings file. The idea is that by uncommenting the \enablemode[makepdf] I can create the pdf file with drawings. It seems however that startMPpage does not accept buffers (I also tried processbuffer and processMPbuffer). Is it possible to somehow make this work? Thanks and regards, Jan Willem Flamma %\enablemode[makepdf] \startbuffer[fig1] draw fullcircle scaled 2cm withcolor red ; \stopbuffer \startbuffer[fig2] draw unitsquare scaled 2cm withcolor red ; \stopbuffer \startmode[makepdf] \starttext \startMPpage \getbuffer[fig1] \stopMPpage \startMPpage \getbuffer[fig2] \stopMPpage \stoptext \stopmode ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] \startanimation and \dorecurse
Hi, I tested the following simple code to generate enlarging circles as a test of animation. But it just draw 5 circles in a row. \usemodule[animation] \setupinteraction[state=start] \startbuffer[Circles] numeric u; u:= 1cm; draw fullcircle scaled \MPrawvar{Circles}{s}u; \stopbuffer \starttext \startanimation { \dorecurse{5}{% \setupMPvariables[Circles][s=\recurselevel] \processMPbuffer [Circles] }} \stopanimation \stoptext It seems to me that \startanimation just treat the figures {\dorecurse … } as just one figure. Is there a way to treat it 5 figures to generate animation? Thank you for reading. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] \startanimation and \dorecurse
Am 20.10.2014 um 13:32 schrieb Jeong Dal hak...@me.com: Hi, I tested the following simple code to generate enlarging circles as a test of animation. But it just draw 5 circles in a row. \usemodule[animation] \setupinteraction[state=start] \startbuffer[Circles] numeric u; u:= 1cm; draw fullcircle scaled \MPrawvar{Circles}{s}u; \stopbuffer \starttext \startanimation { \dorecurse{5}{% \setupMPvariables[Circles][s=\recurselevel] \processMPbuffer [Circles] }} \stopanimation \stoptext It seems to me that \startanimation just treat the figures {\dorecurse … } as just one figure. Is there a way to treat it 5 figures to generate animation? Thank you for reading. 1. You have to expand the \recurselevel value. 2. Don’t put braces around \dorecurse because when \startanimation sees a opening braces it assumes you want to put each frame into a group of braces. Variant 1: \usemodule[animation] \setupinteraction[state=start] \startbuffer[Circles] numeric u; u:= 1cm; draw fullcircle scaled \MPrawvar{Circles}{s}u; \stopbuffer \starttext \startanimation \dorecurse{5} {\startexpanded \startframe \setupMPvariables[Circles][s=\recurselevel] \processMPbuffer [Circles] \stopframe \stopexpanded} \stopanimation \stoptext Variant 2: \usemodule[animation] \setupinteraction[state=start] \startuseMPgraphic{Circles}{s} numeric u; u:= 1cm; draw fullcircle scaled \MPvar{s}u; \stopuseMPgraphic \starttext \startanimation \dorecurse{5} {\startexpanded \frame{\useMPgraphic{Circles}{s=\recurselevel}}% \stopexpanded} \stopanimation \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] passing arguments to \processMPbuffer
Dear Wolfgang, Thank you for your solution. Sometimes I need to use \processMPbuffer for the animated graphics. BTW, what is the differences between ‘MPrawvar’ and ‘MPvar’. MPvar didn’t work in your example. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] passing arguments to \processMPbuffer
Am 22.04.2014 um 14:42 schrieb Jeong Dal hak...@me.com: Dear Wolfgang, Thank you for your solution. Sometimes I need to use \processMPbuffer for the animated graphics. BTW, what is the differences between ‘MPrawvar’ and ‘MPvar’. MPvar didn’t work in your example. The \Mprawvar command takes two argument, the first takes the same name which you have used for the \setupMPvariables command and the second argument is the names of the key. Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] passing arguments to \processMPbuffer
Dear all, For \startuseMPgraphic, there is a way to do that (found in metafun book) as following: \startuseMPgraphic{Labels}{s, t} numeric u; u:= 1cm; for i=0 upto 7: label (textext($v_{ decimal (i) }$ ), \MPvar{s}[origin,3u*dir(30*i)]) ; label (textext($v_{ decimal (i) }$ ), \MPvar{t}[origin,3u*dir(30*i)]) ; endfor; \stopuseMPgraphic \starttext \placefigure[][]{} {\useMPgraphic{ColoringFace::Labeling}{s=0.8, t=1.3}} \stoptext Is there a way to the same job for \processMPbuffer instead of .5 and .7 in buffer? \startbuffer[Labels]%{s, t} numeric u; u:= 1cm; for i=0 upto 7: label (textext($v_{ decimal (i) }$ ), .5[origin,3u*dir(30*i)]) ; label (textext($v_{ decimal (i) }$ ), .7[origin,3u*dir(30*i)]) ; endfor; \stopbuffer \starttext \processMPbuffer[Labels]%% ?{s, t}? \stoptext Thank you. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] passing arguments to \processMPbuffer
Am 21.04.2014 um 15:46 schrieb Jeong Dal hak...@me.com: Dear all, For \startuseMPgraphic, there is a way to do that (found in metafun book) as following: \startuseMPgraphic{Labels}{s, t} numeric u; u:= 1cm; for i=0 upto 7: label (textext($v_{ decimal (i) }$ ), \MPvar{s}[origin,3u*dir(30*i)]) ; label (textext($v_{ decimal (i) }$ ), \MPvar{t}[origin,3u*dir(30*i)]) ; endfor; \stopuseMPgraphic \starttext \placefigure[][]{} {\useMPgraphic{ColoringFace::Labeling}{s=0.8, t=1.3}} \stoptext Is there a way to the same job for \processMPbuffer instead of .5 and .7 in buffer? \startbuffer[Labels]%{s, t} numeric u; u:= 1cm; for i=0 upto 7: label (textext($v_{ decimal (i) }$ ), .5[origin,3u*dir(30*i)]) ; label (textext($v_{ decimal (i) }$ ), .7[origin,3u*dir(30*i)]) ; endfor; \stopbuffer \starttext \processMPbuffer[Labels]%% ?{s, t}? \stoptext You can’t pass variables with the buffer command but a direct setup and access of them is possible: \startbuffer[Labels] numeric u; u:= 1cm; for i=0 upto 7: label (textext($v_{ decimal (i) }$ ), \MPrawvar{Labels}{s}[origin,3u*dir(30*i)]) ; label (textext($v_{ decimal (i) }$ ), \MPrawvar{Labels}{t}[origin,3u*dir(30*i)]) ; endfor; \stopbuffer \starttext \setupMPvariables[Labels][s=0.8, t=1.3] \processMPbuffer [Labels] \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] internal mptopdf converter skips some glyphs in labels
On Fri, 9 Aug 2013, Sanjoy Mahajan wrote: The internal mptopdf converter in MkIV omit some glyphs in the labels. Here's a minimal example (test.tex): \starttext \externalfigure[testfig.1][frame=on] \blank \externalfigure[testfig-1.pdf][frame=on] \stoptext And testfig.1 is produced by testfig.mp Any particular reason that you are compiling metapost files using mp and then including them in ConTeXt rather than directly using any one of the inbuilt ConTeXt environments for handling mp (\startMPcode, \useMPgraphic, \processMPbuffer, etc.) beginfig(1) label(btex $\Omega$ etex, (0,0)); currentpicture := currentpicture scaled 5; endfig; end Here's testfig.1 to save a step in debugging: %!PS %%BoundingBox: -18 -18 18 18 %%HiResBoundingBox: -17.98805 -17.0195 17.98798 17.0195 %%Creator: MetaPost 1.803 %%CreationDate: 2013.08.09:1612 %%Pages: 1 %*Font: cmr10 49.81323 9.96265 0a:8 %%BeginProlog %%EndProlog %%Page: 1 1 0 0 0 setrgbcolor -17.98805 -17.0195 moveto (\012) cmr10 49.81323 fshow showpage %%EOF Then do: mptopdf testfig.1 context test.tex xpdf test.pdf The first framed box, using the internal mps-pdf conversion, is empty. The second framed go, using the pdf file produced by mptopdf, correctly contains \Omega. Try adding prologues := 2; or prologues := 3; in your mp file. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] internal mptopdf converter skips some glyphs in labels
Try adding prologues := 2; or prologues := 3; in your mp file. Good thought, which I tried, though neither setting resolved the problem. Any particular reason that you are compiling metapost files using mp and then including them in ConTeXt rather than directly using any one of the inbuilt ConTeXt environments for handling mp (\startMPcode, \useMPgraphic, \processMPbuffer, etc.) Mostly conservatism. I cannot quite figure out the canonical replacement for btex ... etex (textext, sometext?), and then I get confused by the many possible environments. What do you recommend as the best btex...etex replacement and the best environment for replacing a standalong metapost figure (that I would otherwise just include with \externalfigure)? -Sanjoy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] internal mptopdf converter skips some glyphs in labels
On Fri, 9 Aug 2013, Sanjoy Mahajan wrote: Try adding prologues := 2; or prologues := 3; in your mp file. Good thought, which I tried, though neither setting resolved the problem. Any particular reason that you are compiling metapost files using mp and then including them in ConTeXt rather than directly using any one of the inbuilt ConTeXt environments for handling mp (\startMPcode, \useMPgraphic, \processMPbuffer, etc.) Mostly conservatism. I cannot quite figure out the canonical replacement for btex ... etex (textext, sometext?), and then I get confused by the many possible environments. What do you recommend as the best btex...etex replacement Nothing. Just leave them as it is and MkIV is smart enough to process them [^1]. If you used the TEX macros (to build strings with metapost variables), use textext(...) instead of TEX(). and the best environment for replacing a standalong metapost figure (that I would otherwise just include with \externalfigure)? I use the following: \startcomponent figures \startbuffer[system-1] ... mp code .. \stopbuffer % Other figures in separate buffer \stopcomponent and then use \processMPbuffer[list of buffers] to typeset them [^2]. With this approach you loose some of the features of \externalfigure (scaling, backgrounds, etc.) For scaling, you can use \scale[]{\processMPbuffer[...]} and if you really need a background, you can use \framed. Another option is to use \startMPcode \stopMPcode environment, but I usually like my figures to be separate files. [^1]: To process btex ... etex, the content of each metapost environment is processed twice. This can sometimes lead to unexpected results. Basically you have to careful with := vs =, otherwise you'll get inconsistent equations. [^2]: You also need to keep in mind that all metapost graphics are processed in a single run (think of a single mp file with multiple beginfigs). So you have to be careful with initializing and resetting variables (\startMPinclusions, \startMPinitializations, \startMPdefinitions, see wiki for difference) or adding bgroup ... egroup at appropriate location to limit scope. Another way to avoid interference is to use separate MPinstances, but in my opinion that feature is more useful to module writers than normal users. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] command for a MP graphic
Hi, I did this code to get a regular polygon with metafun, it works but I would like to have an user command like \define or \def to be able to choose the number of sides, n. I don't know how to do that ... \startbuffer[largeurdeslignes] drawoptions (withpen pencircle scaled 2pt); \stopbuffer \startbuffer[polygoneregulier] numeric u ; u:=1*cm ; numeric n ; n:=7 ; pair a[]; a[0]:=(0,3u); path polygone[] ; for i=1 upto n : a[i]:=a[0] rotatedaround(origin,i*360/n) ; polygone[i]:=a[i-1]--a[i]; draw polygone[i]; endfor; \stopbuffer \startbuffer[cercleunite] draw fullcircle scaled 6u withcolor blue; \stopbuffer \define \polyreg {\processMPbuffer[largeurdeslignes,polygoneregulier,cercleunite]} \starttext \polyreg \stoptext Thanks, Roland Thiers ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] TeX macro to MP variable
Hi, I am looking for a way to assign the value of a TeX macro to an MP variable. However, this only works the first time, then the value is not updated any longer. Example: \startMPdefinitions size = \somesize ; \stopMPdefinitions \startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic \starttext \def\somesize{1cm} \useMPgraphic{alpha} %% diameter = 1cm \def\somesize{2cm} \useMPgraphic{alpha} %% diameter = 1cm \stoptext I looked into \setupMPvariables, but I couldn't manage to assign them to an MP variable. The setups key from \defineMPinstance seems to to the job, but it's TeX, not MetaPost. What comes to mind is a \processMPbuffer before every MPgraphic: \startbuffer[foo] size := \somesize ; \stopbuffer \startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic \starttext \def\somesize{1cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 1cm \def\somesize{2cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 2cm \stoptext Is there a better way? Marco signature.asc Description: Digital signature ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] TeX macro to MP variable
On 3/16/2013 4:07 PM, Marco Patzer wrote: Hi, I am looking for a way to assign the value of a TeX macro to an MP variable. However, this only works the first time, then the value is not updated any longer. Example: \startMPdefinitions size = \somesize ; \stopMPdefinitions \startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic \starttext \def\somesize{1cm} \useMPgraphic{alpha} %% diameter = 1cm \def\somesize{2cm} \useMPgraphic{alpha} %% diameter = 1cm \stoptext I looked into \setupMPvariables, but I couldn't manage to assign them to an MP variable. The setups key from \defineMPinstance seems to to the job, but it's TeX, not MetaPost. What comes to mind is a \processMPbuffer before every MPgraphic: \startbuffer[foo] size := \somesize ; \stopbuffer \startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic \starttext \def\somesize{1cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 1cm \def\somesize{2cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 2cm \stoptext Is there a better way? grep for \includeMPgraphic -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun textext()
On Thu, 10 Jan 2013, Alan BRASLAU wrote: On Thu, 10 Jan 2013 06:51:50 -0500 Aditya Mahajan adit...@umich.edu wrote: Since the beginning of MkIV, colors in metapost labels need to be set at the ConTeXt end (Untested): T := thelabel(textext(\color[blue]{I'm seeing double}), origin); Aditya I don't believe that this is true, but I am most likely wrong. Well, I think it was true in the beginning (as I remember a discussion from Mojca on how to handle labels differently in the gnuplot module), but clearly that is not the case now. Indeed \blue text has worked, but 'draw T withcolor blue;' *should* work as well. The processing of textext() has changed recently, it seems. \startMPcode label(textext(I'm seeing double),origin) withcolor green ; label(textext(I'm seeing double),(-1mm,1mm)) withcolor blue ; \stopMPcode DOES work. Of course, these are much simplified minimal examples of what I would like to do. Minimal example to show what is happening: \startbuffer[initialize] picture T; T := textext(Hello); picture Q; Q := T; \stopbuffer \startbuffer[T] draw T withcolor blue; \stopbuffer \startbuffer[Q] draw Q shifted (-1mm, 1mm) withcolor red; \stopbuffer \startlines Only draw T: \processMPbuffer[initialize,T] Only draw Q: \processMPbuffer[initialize,Q] Draw T Q : \processMPbuffer[initialize,T,Q] Draw Q T : \processMPbuffer[initialize,Q,T] \stoplines Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun textext()
On 1/10/2013 2:18 PM, Aditya Mahajan wrote: On Thu, 10 Jan 2013, Alan BRASLAU wrote: On Thu, 10 Jan 2013 06:51:50 -0500 Aditya Mahajan adit...@umich.edu wrote: Since the beginning of MkIV, colors in metapost labels need to be set at the ConTeXt end (Untested): T := thelabel(textext(\color[blue]{I'm seeing double}), origin); Aditya I don't believe that this is true, but I am most likely wrong. Well, I think it was true in the beginning (as I remember a discussion from Mojca on how to handle labels differently in the gnuplot module), but clearly that is not the case now. Indeed \blue text has worked, but 'draw T withcolor blue;' *should* work as well. The processing of textext() has changed recently, it seems. The mkiv implementation has always been rather different from the mkii one: text handling as well as dealing with colors. \startMPcode label(textext(I'm seeing double),origin) withcolor green ; label(textext(I'm seeing double),(-1mm,1mm)) withcolor blue ; \stopMPcode DOES work. Of course, these are much simplified minimal examples of what I would like to do. Minimal example to show what is happening: \startbuffer[initialize] picture T; T := textext(Hello); picture Q; Q := T; \stopbuffer \startbuffer[T] draw T withcolor blue; \stopbuffer \startbuffer[Q] draw Q shifted (-1mm, 1mm) withcolor red; \stopbuffer \startlines Only draw T: \processMPbuffer[initialize,T] Only draw Q: \processMPbuffer[initialize,Q] Draw T Q : \processMPbuffer[initialize,T,Q] Draw Q T : \processMPbuffer[initialize,Q,T] \stoplines You and Alan can pick up the beta from the ftp server and play with this: \setupbodyfont[dejavu] \starttext \startMPpage[offset=10pt] picture MyText ; MyText := textext(Dummy) ; % not used later on picture MyText ; MyText := textext(\red Red) ; draw MyText ; draw MyText scaled 2 shifted (0,-1cm) ; draw MyText scaled 3 shifted (0,-2cm) ; picture MyText ; MyText := textext(Blue Green Red) ; draw MyText rotatedaround(center MyText,10) shifted (0,-3cm) withcolor blue ; draw MyText shifted (0,-4cm) withcolor green ; draw MyText rotatedaround(center MyText,-10) shifted (0,-5cm) withcolor red ; picture MyText ; MyText := image ( draw textext(Green Red Blue {\yellow YELLOW} Whatever 1) ; draw textext(Green Red Blue {\yellow YELLOW} Whatever 2) shifted (10cm,0) ; ) ; draw MyText shifted (0,-6cm) withcolor green ; draw MyText shifted (0,-7cm) withcolor red ; draw MyText shifted (0,-8cm) withcolor blue ; \stopMPpage \stoptext The complication is that we reuse a picture which once defined has frozen properties. However, after hours of lua/tex juggling I managed to made a variant that better keeps track of applied colors. I'm not sure if this is foolproof but it's probably quite ok for what Alan wants to do. Although ... being a scientist he will look for the next frontier ... (or even more scientific: try to prove me wrong). Hans -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - textext-002.pdf Description: Adobe PDF document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaPost Animations
Dear Wolfgang, Thank you for the explanation, and your sample works nicely. I enclosed \processMPbuffer using \startframe and \stopframe as following. Then I got a 'undefined control sequence' error. If I use '\framed[]' instead of '\startframe … \stopframe', then it gave all 7 circles of different radius in two pages without error. If I add \startanimation … \stopanimation, the only change is the appearance of menu at the bottom of the last circle.(no animation) What is wrong in the code? Best regards, Dalyoung Happy New Year to all listers!!! \startbuffer[circles] path p; numeric n, u; u := 1cm; n:=\recurselevel*u; p := fullcircle scaled n; draw p; \stopbuffer \usemodule[animation] \setupinteraction[state=start] \starttext %\startanimation[menu=yes] \dorecurse{7}{ \startframe % \framed[]%{\processMPbuffer[circles]}} \processMPbuffer[circles] \stopframe } %\stopanimation \stoptext ! Undefined control sequence. system tex error on line 23 in file test-ani.tex: Undefined control sequence ... 13 \setupinteraction[state=start] 14 15 \starttext 16 17 %\startanimation[menu=yes] 18 \dorecurse{7}{ 19 \startframe 20 %\framed[]%{\processMPbuffer[circles]}} 21 \processMPbuffer[circles] 22 \stopframe 23 } 24 %\stopanimation 25 26 \stoptext 27 \121 #1#2- \startframe \processMPbuffer [circles] \stopframe \syst_helpers_recurse_indeed_yes ...curse_content \syst_helpers_recurse_indeed to be read again { inserted text 2 \syst_helpers_recurse_indeed ...the \innerrecurse }{#2} l.23 } ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaPost Animations
Am 01.01.2013 um 04:50 schrieb Jeong Dal hak...@me.com: Dear Wolfgang, Thank you for the explanation, and your sample works nicely. I enclosed \processMPbuffer using \startframe and \stopframe as following. Then I got a 'undefined control sequence' error. If I use '\framed[]' instead of '\startframe … \stopframe', then it gave all 7 circles of different radius in two pages without error. If I add \startanimation … \stopanimation, the only change is the appearance of menu at the bottom of the last circle.(no animation) What is wrong in the code? 1. The \frame and \startframe commands are only available *in* the animation environment where they are locally defined. 2. Although \framed sound similar to \frame there is no relation between both commands. 3. You have to expand the loop value *before* it is passed to metapost, see below. \usemodule[animation] \setupinteraction[state=start] \startuseMPgraphic{circles}{counter} path p; numeric n, u; u := 1cm; n:=\MPvar{counter}*u; p := fullcircle scaled n; draw p; \stopuseMPgraphic \starttext \startanimation[menu=yes] \dorecurse{7}{% \startframe \useMPgraphic{circles}{counter=#1}% \stopframe} \stopanimation \stoptext 4. You can also include the metapost code in the frame but you have to expand the \recurselevel value with the \expanded command (I have to upload a new version of the module first because \startframe isn’t expandable yet). \usemodule[animation] \setupinteraction[state=start] \starttext \startanimation[menu=yes] \dorecurse{7}{\expanded {\startframe \startMPcode path p; numeric n, u; u := 1cm; n:=\recurselevel*u; p := fullcircle scaled n; draw p; \stopMPcode \stopframe}} \stopanimation \stoptext 5. Use a PDF viewer with javascript support (e.g. Adobe Reader) to view the animation. Kind regards and a happy new year, Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaPost Animations
Dear Troy, The animations are impressive and thank you for sharing the code. In the creation of many pdf for animation, it changes the recurselevel only. I wonder if there is a way to make such kind of animation in ConTeXt using Wolfgang's animation module. Then we can include the animation in PDF output directly. Here is my trial. I modified it as following and got an animation. But it is only good for a few step animation. % \startbuffer[base] N:=64;%\N; u:=136; pair f; c:=2/(1+sqrt(5));%\c; if c1: f:=(1+-+c,0); v:=u/2; else: f:=(0,1+-+(1/c)); v:=u/c/2; fi; % Focus f is defined path p,q; pair z; picture base; numeric L; p:=fullcircle yscaled c; % This is the ellipse L:=length p; draw p scaled (2*v) withpen pencircle scaled (v/260) dashed evenly; % Draw the ellipse dashed (will be traced later) base:= currentpicture; q:=bbox currentpicture enlarged (v/64); % Enlarge the bounding box slightly q:=(llcorner q+(-v/128,-v/128))--(lrcorner q+(v/128,-v/128))--(urcorner q+(v/128,v/128))--(urcorner q+(-v/128,v/128))--cycle; fill fullcircle scaled (v/32) shifted (f*v) withcolor red; % Focus fill fullcircle scaled (v/32) shifted (-f*v) withcolor red; % Focus base:=currentpicture; % Save this picture to draw in every frame setbounds currentpicture to q; % Set the bounding box as described before \stopbuffer \startbuffer[fig1] %\startMPpage n:=1;%\recurselevel%1; draw base; % Draw the common picture saved above draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled (v/130) withcolor blue; % Trace the ellipse in blue z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are thusfar fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string used to trace the ellipse setbounds currentpicture to q; % Set the bounding box so that it is the same for each frame %\stopMPpage \stopbuffer \startbuffer[fig2] %\startMPpage n:=2; draw base; % Draw the common picture saved above draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled (v/130) withcolor blue; % Trace the ellipse in blue z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are thusfar fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string used to trace the ellipse setbounds currentpicture to q; % Set the bounding box so that it is the same for each frame %\stopMPpage \stopbuffer \startbuffer[fig3] %\startMPpage n:=3; draw base; % Draw the common picture saved above draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled (v/130) withcolor blue; % Trace the ellipse in blue z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are thusfar fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string used to trace the ellipse setbounds currentpicture to q; % Set the bounding box so that it is the same for each frame %\stopMPpage \stopbuffer \setupinteraction[state=start] \usemodule[animation] \starttext \startanimation[menu=yes] {\processMPbuffer[base, fig1]} {\processMPbuffer[base, fig2]} {\processMPbuffer[base, fig3]} \stopanimation \stoptext % I also tried to simplify the code as following, but it just draw 10 figures not an animation. Is there a way to combine them as an animation? Thank you. Best regards, Dalyoung % \startbuffer[base] N:=64;%\N; u:=136; pair f; c:=2/(1+sqrt(5));%\c; if c1: f:=(1+-+c,0); v:=u/2; else: f:=(0,1+-+(1/c)); v:=u/c/2; fi; % Focus f is defined path p,q; pair z; picture base; numeric L; p:=fullcircle yscaled c; % This is the ellipse L:=length p; draw p scaled (2*v) withpen pencircle scaled (v/260) dashed evenly; % Draw the ellipse dashed (will be traced later) base:= currentpicture; q:=bbox currentpicture enlarged (v/64); % Enlarge the bounding box slightly q:=(llcorner q+(-v/128,-v/128))--(lrcorner q+(v/128,-v/128))--(urcorner q+(v/128,v/128))--(urcorner q+(-v/128,v/128))--cycle; fill fullcircle scaled (v/32) shifted (f*v) withcolor red; % Focus fill fullcircle scaled (v/32) shifted (-f*v) withcolor red; % Focus base:=currentpicture; % Save this picture to draw in every frame setbounds currentpicture to q; % Set the bounding box as described before \stopbuffer \startbuffer[fig1] %\startMPpage n:=\recurselevel; draw base; % Draw the common picture saved above draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled (v/130) withcolor blue; % Trace the ellipse in blue z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are thusfar fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v
Re: [NTG-context] Using MPgraphics as externalfigures?
Hi Marco al, On Thu, Aug 2, 2012 at 11:34 AM, Marco Patzer home...@lavabit.com wrote: Read http://wiki.contextgarden.net/Metapost I was on http://wiki.contextgarden.net/Mpgraphic which I actually found for informative, but not quite enough for my very dummy level. and 3.3 Integrated Graphics in the MetaFun Manual. *This* was my missing link (and I was being pretty stupid). I dug the book out of my pile of ConTeXt papers and found exactly what I needed, at the end of chapter 3.3, pages 115-117 in my paper copy. To answer to myself (in case somebody else ever looks for this); At least in theory the key to the problem is to create a file somefile.mp, then write the MP code in the file beginfig{01} . . . endfig ; end . The whole file is used by \startMPrun input somefile ; \stopMPrun and the individual figure is available in the virtual file mprun.01. Thus it can be included with \externalfigure[mprun.01][width=0.5\textwidth] %etcetera Page 117 even has an example of exactly the type of combination I'm trying to achieve, so now it's just down to creating the graphic(s) file(s). As my braiding graphics come in groups (steps and variations, to be exact), this solution looks like a winner for now. \defineframed [graphicframe] [frame=on,offset=none] \define[1]\MPframed {\graphicframe{\useMPgraphic{#1}}} \startuseMPgraphic{first} fill fullcircle scaled 2cm withcolor red; \stopuseMPgraphic \startreusableMPgraphic{second} fill fullsquare rotated 45 scaled 2cm withcolor blue; \stopreusableMPgraphic \startbuffer [third] fill fullsquare scaled 1cm withcolor green; \stopbuffer \starttext \useMPgraphic{first} \reuseMPgraphic{second} \processMPbuffer [third] \MPframed{second} \stoptext Thank you! I'll have to delve into this bit once the current almost-past-deadline project is done, looks like this'll take a bit of processing before it starts to make sense to me (my computer has no such problems...). Now, time for some recoding, thanks once more! Mari ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using MPgraphics as externalfigures?
On Thu, 2 Aug 2012, Mari Voipio wrote: Hi All, I'm being a bit clueless about the MPgraphics again... I've got a pile of instructional graphics that will be used and reused in a project. My first try is/was an unwieldy buffer construction, but I'm sure there's a better way than \placefigure[here] [fig: 5 loop departed setup] {The start position for a 5-loop braid with departed loops} {\framed{\getbuffer[setup 5-loop basic]}} Come to think of it, is there another way of framing the incoming graphic? I don't want to include the frames in the MPcode as I may not always want them, but that \framed{\getbuffer} construction is downright ugly. (Untested code, but this should work) \startbuffer[figure 1] draw fullcircle scaled 1cm; \stopbuffer \startbuffer[frame] draw (bbox currentpicture) withcolor blue; \stopbuffer \processMPbuffer[figure 1, frame] Basically, you can concatinate various buffers in \processMPbuffer. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Using MPgraphics as externalfigures?
On 2012-08-02 Mari Voipio mari.voi...@iki.fi wrote: Hi Mari, I'm being a bit clueless about the MPgraphics again... Read http://wiki.contextgarden.net/Metapost and 3.3 Integrated Graphics in the MetaFun Manual. Any ideas of how to do this in a smart way? Preferably without having to go into the bowels of ConTeXt to get it done... \defineframed [graphicframe] [frame=on,offset=none] \define[1]\MPframed {\graphicframe{\useMPgraphic{#1}}} \startuseMPgraphic{first} fill fullcircle scaled 2cm withcolor red; \stopuseMPgraphic \startreusableMPgraphic{second} fill fullsquare rotated 45 scaled 2cm withcolor blue; \stopreusableMPgraphic \startbuffer [third] fill fullsquare scaled 1cm withcolor green; \stopbuffer \starttext \useMPgraphic{first} \reuseMPgraphic{second} \processMPbuffer [third] \MPframed{second} \stoptext Marco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] scaling the mp figure in ConTeXt
On 14-11-2011 08:23, Jeong Dalyoung wrote: \startbuffer[test] draw fullcircle scaled 3cm; \stopbuffer \starttext \placefigure[][]{} \processMPbuffer[test] \stoptext currentpicture := currentpicture xsized(TextWidth) ; or \placefigure[][]{}{\scale[width=\textwidth]{\processMPbuffer[test]}} -- - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] scaling the mp figure in ConTeXt
Dear all, I use MetaFun to create a figure and embed it using \processMPbuffer[]. for example, \startbuffer[test] draw fullcircle scaled 3cm; \stopbuffer \starttext \placefigure[][]{} \processMPbuffer[test] \stoptext But sometimes, I need to rescaling the mp figure to fit the page. Is there a way of rescaling the figure at the stage \processMPbuffer or \useMPgraphic? In the above example, I got a circle of radius 3cm. How to get a circle of radius 2cm? Thank you for reading. best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metapost to pdf on the fly
I am afraid I don't completely understand this. Doing: \startbuffer[fig-1] \startMPcode draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. cycle withcolor darkgreen; label(textext(Test),origin); \stopMPcode \stopbuffer \starttext \processMPbuffer[fig-1] \stoptext I get the error: ! Argument of \dostartMPpositiongraphic has an extra }. system tex error on line 8 in file onfly.tex: Argument of ... 1 \startbuffer[fig-1] 2 \startMPcode 3 draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. cycle withcolor darkgreen; 4 label(textext(Test),origin); 5 \stopMPcode 6 \stopbuffer 7 \starttext 8 \processMPbuffer[fig-1] .. inserted text \par to be read again } \processMPgraphic ...le ;\!!es , \MPaskedfigure )} }\egroup \placeMPgraphic \... \doprocessMPbuffer ...(\currentMPgraphicname )}} \endMPgraphicgroup l.8 \processMPbuffer[fig-1] Hans van der Meer On 29 sep. 2011, at 21:21, Aditya Mahajan wrote: On Thu, 29 Sep 2011, Meer, H. van der wrote: I would like to generate metapost figures in separate pdf-files (in some convenient directory, they are reused elsewhere). This as part of a project structure. I know that on a separate run such a pdf can be generated with: context figurefile running on input \input some-metapost-inclusions \starttext \startMPpage .. \stopMPpage \stoptext But the idea is to do it on the fly while typesetting a project (using mode=*first to prevent further iterations): .. \component figurefile .. And in the figurefile \startcomponent figurefile \environment some-metapost-inclusions \starttext .. BUT THEN WHAT? As such it is not sufficient for the goal proposed. Can this be done at all? What I usually do is have all the figures in separate buffers: \startenvironment figures \startbuffer[fig-1] ... \stopbuffer \stopenvironment and in the main file \environment figures \starttext \processMPbuffer[fig-1] \stoptext This way you can also combine multiple figures using \processMPbuffer[fig-common,fig-1] etc. The metapost processing is fast enough that there is no noticable speed difference. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metapost to pdf on the fly
Am 03.10.2011 um 09:05 schrieb Meer, H. van der: I am afraid I don't completely understand this. Doing: \startbuffer[fig-1] \startMPcode draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. cycle withcolor darkgreen; label(textext(Test),origin); \stopMPcode \stopbuffer \starttext \processMPbuffer[fig-1] \stoptext This works: \startbuffer[fig-1] draw (-20,0) .. (0,20) .. (20,0) .. (0,-20) .. cycle withcolor \MPcolor{darkgreen}; label(textext(Test),origin); \stopbuffer \starttext \processMPbuffer[fig-1] \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metapost to pdf on the fly
Thanks, this works indeed. But I hoped to be able to produce in this manner at one stroke a series of separate figures, each in its own pdf file. Or is this an impossible action? Hans van der Meer On 3 okt. 2011, at 09:09, Wolfgang Schuster wrote: Am 03.10.2011 um 09:05 schrieb Meer, H. van der: I am afraid I don't completely understand this. Doing: \startbuffer[fig-1] \startMPcode draw origin-(20,0) .. origin+(0,20) .. origin+(20,0) .. origin+(0,-20) .. cycle withcolor darkgreen; label(textext(Test),origin); \stopMPcode \stopbuffer \starttext \processMPbuffer[fig-1] \stoptext This works: \startbuffer[fig-1] draw (-20,0) .. (0,20) .. (20,0) .. (0,-20) .. cycle withcolor \MPcolor{darkgreen}; label(textext(Test),origin); \stopbuffer \starttext \processMPbuffer[fig-1] \stoptext Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metapost to pdf on the fly
On Thu, 29 Sep 2011, Meer, H. van der wrote: I would like to generate metapost figures in separate pdf-files (in some convenient directory, they are reused elsewhere). This as part of a project structure. I know that on a separate run such a pdf can be generated with: context figurefile running on input \input some-metapost-inclusions \starttext \startMPpage .. \stopMPpage \stoptext But the idea is to do it on the fly while typesetting a project (using mode=*first to prevent further iterations): .. \component figurefile .. And in the figurefile \startcomponent figurefile \environment some-metapost-inclusions \starttext .. BUT THEN WHAT? As such it is not sufficient for the goal proposed. Can this be done at all? What I usually do is have all the figures in separate buffers: \startenvironment figures \startbuffer[fig-1] ... \stopbuffer \stopenvironment and in the main file \environment figures \starttext \processMPbuffer[fig-1] \stoptext This way you can also combine multiple figures using \processMPbuffer[fig-common,fig-1] etc. The metapost processing is fast enough that there is no noticable speed difference. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun shifting pictures - again
Dear Hans, Thank you for the suggestion to use setbounds. And sorry to send you a untested sample file which is not working. However, I couldn't succeed because of my lack of knowledge on setbounds, boundingbox. Instead, I try to use addto and get a wanted result. There is a better way to do that, but it is not easy for me to find a better way right now. Here is a tested sample code. \startbuffer[dominos] picture finalpicture; def dominoV (expr m,n, i, j) = numeric dx, dy, DieSize,corner_rad; path p, DominoFace; DieSize := 1cm; corner_rad := 1/12; DominoFace := (1,0)--(1,1)--(corner_rad, 1){left}..{down}(0,1-corner_rad) ..(0,corner_rad){down}..{right}(corner_rad,0) ..(2-corner_rad,0){right}..{up}(2,corner_rad) ..(2,1-corner_rad){up}..{left}(2-corner_rad,1)--(1,1); currentpicture := nullpicture; dx := 1.1*i*DieSize; dy := 2.1*j*DieSize; draw DominoFace scaled DieSize rotated 270; %draw pips[m] scaled DieSize;% shifted (dx, dy); %draw pips[n] scaled DieSize shifted (DieSize, 0) ; addto finalpicture also currentpicture shifted (dx, dy); currentpicture := nullpicture; enddef; finalpicture := nullpicture; dominoV (6, 0, 0, 0); dominoV (5, 1, 1, 0); dominoV (4, 2, 2, 0); dominoV (3, 3, 3, 0); currentpicture := finalpicture; \stopbuffer \starttext \processMPbuffer[dominos] \stoptext Thank you again. Best regards, Dalyoung On 2011. 6. 23., at 오후 4:41, Hans Hagen wrote: On 23-6-2011 6:32, Jeong Dalyoung wrote: Hi all, I got the reason why the pictures locate in different position. rotation causes the problem. I defined domino as follows. It is not the exact code but just show the form of the codes. def domino (a, b, c, d ) save pic; picture pic; draw something 1; draw something 2; pic := currentpicture; draw pic rotated 90 shifted ( c, d ); enddef; and call it using \startbuffer[domino3] domino (1, 2, 3, 4); domino (2, 1, 1, 2); domino (3, 3, 2, 3); \stopbuffer and \processMPbuffer[]. it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn. Previous drawings are rotated again again when the function domino called. How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure? If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94. set the boundingbox in each domino to the same size - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun shifting pictures - again
On 24-6-2011 8:32, dalyoung wrote: Dear Hans, Thank you for the suggestion to use setbounds. And sorry to send you a untested sample file which is not working. However, I couldn't succeed because of my lack of knowledge on setbounds, boundingbox. Instead, I try to use addto and get a wanted result. There is a better way to do that, but it is not easy for me to find a better way right now. \startbuffer[dominos] vardef dominoV (expr m) = numeric corner_rad ; path DominoFace ; corner_rad := 1/12 ; DominoFace := (1,0) -- (1,1) -- (corner_rad,1) {left} .. {down} (0,1-corner_rad) ... (0,corner_rad) {down} .. {right}(corner_rad,0) ... (2-corner_rad,0){right} .. {up} (2,corner_rad) ... (2,1-corner_rad){up}.. {left} (2-corner_rad,1) -- (1,1) ; DominoFace rotated 270 enddef ; def shiftX(expr d) = currentpicture := currentpicture shifted (-xpart urcorner currentpicture - d, 0) ; enddef ; numeric d ; d := 1cm ; draw dominoV(6) scaled d ; shiftX(d/10) ; draw dominoV(5) scaled d ; shiftX(d/10) ; draw dominoV(4) scaled d ; shiftX(d/10) ; draw dominoV(3) scaled d ; \stopbuffer \starttext \processMPbuffer[dominos] \stoptext - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun shifting pictures - again
On 23-6-2011 6:32, Jeong Dalyoung wrote: Hi all, I got the reason why the pictures locate in different position. rotation causes the problem. I defined domino as follows. It is not the exact code but just show the form of the codes. def domino (a, b, c, d ) save pic; picture pic; draw something 1; draw something 2; pic := currentpicture; draw pic rotated 90 shifted ( c, d ); enddef; and call it using \startbuffer[domino3] domino (1, 2, 3, 4); domino (2, 1, 1, 2); domino (3, 3, 2, 3); \stopbuffer and \processMPbuffer[]. it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn. Previous drawings are rotated again again when the function domino called. How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure? If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94. set the boundingbox in each domino to the same size - Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun shifting pictures - again
Hi all, I got the reason why the pictures locate in different position. rotation causes the problem. I defined domino as follows. It is not the exact code but just show the form of the codes. ... def domino (a, b, c, d ) save pic; picture pic; draw something 1; draw something 2; pic := currentpicture; draw pic rotated 90 shifted ( c, d ); enddef; and call it using \startbuffer[domino3] domino (1, 2, 3, 4); domino (2, 1, 1, 2); domino (3, 3, 2, 3); \stopbuffer and \processMPbuffer[]. it draw the first domino at the right place, but it is rotated when the second domino is drawn. Hence, it actually rotated 180 degree. Also two dominos rotated again when the third domino is drawn. Previous drawings are rotated again again when the function domino called. How to avoid this problem? How to draw one figure and move to wanted position and draw another figure and move to another location without changing the previous figure? If you want to see the whole codes, please see the attachment in the previous mail in ntg-context Digest, Vol 84, Issue 94. Thank you. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] about JS(Walk_Field{})
Dear all, I tried the following code for presentation, but not succeeded. It just draw a small circle without frame even frame=on. The word here is colored green but there is no interaction when I click here. Is there anything wrong in the following code? Thank you. Best regards, Dalyoung \setupinteraction[state=start] \startbuffer[a] draw fullcircle scaled 1cm; \stopbuffer \startbuffer[b] draw fullcircle scaled 2cm; \stopbuffer \startbuffer[c] draw fullcircle scaled 3cm; \stopbuffer \definesymbol[step1][{\processMPbuffer[a]}] \definesymbol[step2][{\processMPbuffer[a,b]}] \definesymbol[step3][{\processMPbuffer[a,b,c]}] \definefieldstack [circles] [step1, step2, step3] [frame= on, offset= 3pt,framecolor=darkyellow,rulethickness=1pt] \starttext \placefigure[here][] {To see the animation, please click \goto{here}[JS(Walk_Field{circles})]} {\fieldstack[circles]} \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] metafun- how to pass array as an argument
Dear all, I draw a simple figure using the code as below. In the code, I use for i = 3,5,0,2,1,7: in def draw_balls. However, if I can pass the array 3,5,0,2,1,7 as an argument for def draw_balls (expr n) and call draw_balls (3,5,0,2,1,7), then it can be used for different number of balls and number of boxes. Is there a way to do that or any suggestions? Thank you for reading. Regards, Dalyoung \startbuffer[a] path p; numeric bwidth, u, lastpoint; u :=1cm; p := fullcircle scaled .3u; lastpoint := 0; def draw_balls = %(expr s) draw (0,0) -- (0, u); for i=3,5,0,2,1,7: for j = 1 upto i: draw p shifted (lastpoint+.32*j*u,.3u); endfor; bwidth := .32i*u+.5u; draw (lastpoint,0) -- (lastpoint +bwidth,0) -- (lastpoint +bwidth,u); lastpoint := lastpoint+bwidth; endfor; enddef; draw_balls; \stopbuffer \starttext \processMPbuffer[a] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metafun- how to pass array as an argument
Am 24.01.2011 13:18, schrieb dalyoung: \startbuffer[a] path p; numeric bwidth, u, lastpoint; u :=1cm; p := fullcircle scaled .3u; lastpoint := 0; def draw_balls = %(expr s) def draw_balls(text s) = draw (0,0) -- (0, u); for i=3,5,0,2,1,7: for i=s: for j = 1 upto i: draw p shifted (lastpoint+.32*j*u,.3u); endfor; bwidth := .32i*u+.5u; draw (lastpoint,0) -- (lastpoint +bwidth,0) -- (lastpoint +bwidth,u); lastpoint := lastpoint+bwidth; endfor; enddef; draw_balls; \stopbuffer \starttext \processMPbuffer[a] \stoptext works in mkii, but fails in mkiv. i use an outdated version (31.12.2010) here. ! LuaTeX error main ctx instance:1: attempt to call field 'feedback' (a nil value) stack traceback: main ctx instance:1: in main chunk. argument feedback(\currentMPgraphicname )} \processMPgraphic ...ntMPgraphicformat , \!!bs #1 ;\!!es , \!!bs \currentMPi... argument ...feedback(\currentMPgraphicname )}} \endMPgraphicgroup \secondoftwoarguments #1#2-#2 l.25 \processMPbuffer[a] ? best wishes, Peter ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] metafun- how to pass array as an argument
Am 24.01.2011 13:50, schrieb Peter Rolf: Am 24.01.2011 13:18, schrieb dalyoung: \startbuffer[a] path p; numeric bwidth, u, lastpoint; u :=1cm; p := fullcircle scaled .3u; lastpoint := 0; def draw_balls = %(expr s) def draw_balls(text s) = draw (0,0) -- (0, u); for i=3,5,0,2,1,7: for i=s: for j = 1 upto i: draw p shifted (lastpoint+.32*j*u,.3u); endfor; bwidth := .32i*u+.5u; draw (lastpoint,0) -- (lastpoint +bwidth,0) -- (lastpoint +bwidth,u); lastpoint := lastpoint+bwidth; endfor; enddef; draw_balls; draw_balls(3,5,0,2,1,7) sorry, i forgot to change this line. example code is attached for testing... \stopbuffer \starttext \processMPbuffer[a] \stoptext works in mkii, but fails in mkiv. i use an outdated version (31.12.2010) here. ! LuaTeX error main ctx instance:1: attempt to call field 'feedback' (a nil value) stack traceback: main ctx instance:1: in main chunk. argument feedback(\currentMPgraphicname )} \processMPgraphic ...ntMPgraphicformat , \!!bs #1 ;\!!es , \!!bs \currentMPi... argument ...feedback(\currentMPgraphicname )}} \endMPgraphicgroup \secondoftwoarguments #1#2-#2 l.25 \processMPbuffer[a] ? best wishes, Peter ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ \startbuffer[a] path p; numeric bwidth, u, lastpoint; u :=1cm; p := fullcircle scaled .3u; lastpoint := 0; def draw_balls(text s) = draw (0,0) -- (0, u); for i=s: for j = 1 upto i: draw p shifted (lastpoint+.32*j*u,.3u); endfor; bwidth := .32i*u+.5u; draw (lastpoint,0) -- (lastpoint +bwidth,0) -- (lastpoint +bwidth,u); lastpoint := lastpoint+bwidth; endfor; enddef; draw_balls(3,5,0,2,1,7); \stopbuffer \starttext \processMPbuffer[a] \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] [MP] labels of points on a circle
Hi Dalyoung, You can try to adapt the following snippet: numeric i; pickup pencircle scaled 4pt; for i = 1 upto 10: z[i] = dir(uniformdeviate 360); drawdot z[i] scaled 4cm; label(decimal(i), z[i] scaled 4.3cm); endfor; Best regards, Bostjan On Mon, Oct 19, 2009 at 2:48 PM, dalyoung hak...@me.com wrote: Hi all, To draw 9 points with labels, I used the following code. \startbuffer[point2] path p; numeric i; i=1; for j =0.5,1.3,2.5,3,4,4.8,6,7.2,7.9: z[i] = dir(j*45) scaled 4cm; i:= i+1; endfor; p := z1..z2..z3..z4..z5..z6..z7..z8..z9..cycle; draw p; drawpoints p; drawpointlabels p; \stopbuffer \placefigure[middle][]{}{\processMPbuffer[point2]} Then it draw everything well except writing labels inside the circle. How can I write the labels of the points outside of the circle? I'd like to draw 9 points randomly on a circle. Is there a nice way to do it? Thank you. Best regards, Dalyoung___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Metapost and mkiv
Hi all, The following minimal example used to work with mkiv (until last May, I would guess…) but now it doesn't work with the latest ConTeXt version 2009.09.21 17:39 Can any one tell me please what am I doing wrong? Best regards: OK %% begin \setupcolors[state=start] \starttext \startbuffer[axes-1] numeric u ; u := .5cm ; path xox ; xox := (-u,0)--(8u,0) ; path yoy ; yoy := (0,-u)--(0,7u) ; draw xox withcolor blue ; draw yoy withcolor blue ; \stopbuffer This MetaPost graphic is \doifmodeelse{mkiv}{not shown with mkiv} {shown with mkii}: \placefigure[middle][-]{}{\processMPbuffer[axes-1]} {} \stoptext %% end ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] mkiv and MetaPost
On 14 janv. 09, at 08:57, Taco Hoekwater wrote: Otared Kavian wrote: Thanks Aditya for your explanation, but I must say that it is not convincing because with mkiv one of the buffers is processed with \processMPbuffer, while the other is not… So there must be some other hidden behaviour which has changed between mkii and mkiv. I will leave it for Hans to figure what exactly goes wrong, but the problem is caused by the comment characters in the axes-1 buffer. Best wishes, Taco Hi Taco, Thanks for finding the problem: indeed as you point out, in the minimal example which I reproduce below, one sees that the comment character % in the \startbuffer[axes-2] part is not interpreted correctly in mkiv: if one puts that character at the end of last line of the buffer the ouput is correct, while if one puts it at the end of other lines the result is undefined. So for the file I have to typeset right now, I'll remove those nasty %, but I hope that the problem will be solved in mkiv… By the way, in one of your messages some time ago you said that there is a command \luatexversion but it doesn't exist on my installation: is it removed or I understod wrong? Best wishes: OK % bug-metapost-1.tex %!TEX TS-program = mkiv \setupcolors[state=start] \starttext \startbuffer[axes-1] numeric u ; u := .5cm ; path xox ; xox := (-u,0)--(8u,0) ; path yoy ; yoy := (0,-u)--(0,7u) ; draw xox withcolor blue ; draw yoy withcolor blue ; \stopbuffer \startbuffer[axes-2] numeric u ; u := .5cm ; path xox ; xox := (-u,0)--(8u,0) ; path yoy ; yoy := (0,-u)--(0,7u) ; draw xox withcolor blue ; % -- here is the problem draw yoy withcolor blue ; \stopbuffer This file has been typeset on \currentdate{} at \currenttime, with \doifmodeelse{mkiv} {mkiv, LuaTeX revision \luatexrevision, (LuaTeX date stamp \luatexdatestamp)} {mkii, using the command: \type{texexec basic-test.tex}}, ConTeXt version \contextversion. % LuaTeX version \luatexversion, \blank[2*big] This MetaPost graphic is shown correctly with mkiv: \placefigure[middle][-]{}{\processMPbuffer[axes-1]} {} \blank but not this one \placefigure[middle][-]{}{\processMPbuffer[axes-2]} {} \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] mkiv and MetaPost
Hi all, I have a file which contains the lines below: I can typeset it and obtain a correct result with mkii, but not with mkiv (the second buffer named axes-1 does not result in a MetaPost graphic when one says \processMPbuffer[axes-1]). The file and the resulting PDF can be found on http://www.kavian.fr/tex/bug-mkiv Thanks in advance for any help. Best regards: OK %% begin bug-metapost.tex \setupcolors[state=start] \starttext \startbuffer[axes-1] textextoffset := ExHeight ; numeric u ; u := .5cm ; vardef arrowheadonpath (expr p, s) = save autoarrows ; boolean autoarrows ; autoarrows := true ; set_ahlength(scaled ahfactor) ; % arrowhead p if s1 : cutafter (point (s*arclength(p)+.5ahlength) on p) fi enddef ; path xox ; xox := (-u,0)--(8u,0) ; path yoy ; yoy := (0,-u)--(0,7u) ; draw xox withcolor blue ; draw yoy withcolor blue ; ahfactor := 4 ; % default is 2.5 fill arrowheadonpath(xox,1) withcolor .625blue ; % try .25 fill arrowheadonpath(yoy,1) withcolor .625blue ; % try .25 \stopbuffer \startbuffer[chemin-1] textextoffset := ExHeight ; numeric u ; u := .5cm ; z1 = (5u,0) ; z2 = z1 rotated 60 ; z11 = z1 rotated 15 ; z12 = z1 rotated 30 ; z13 = z1 rotated 45 ; z0 = (2u,0) rotated 30 ; path gamma ; gamma := (0,0)--(5u,0) ; draw gamma withpen pencircle scaled .4mm withcolor .625yellow ; path gammaR ; gammaR := z1..z11..z12..z13..z2 ; draw gammaR withpen pencircle scaled .4mm withcolor .625yellow ; dotlabel.bot (btex \switchtobodyfont[10pt] \strut $R$ etex, z1) ; path gammaRR ; gammaRR := z2--(0,0) ; draw gammaRR withpen pencircle scaled .4mm withcolor .625yellow ; dotlabel.top (btex \switchtobodyfont[10pt] \strut $R{\rm e}^{2{\rm i} \pi/n}$ etex , z2) ; dotlabel.rt (btex \switchtobodyfont[10pt] \strut ${\rm e}^{{\rm i}\pi/ n}$ etex , z0) ; label.rt (btex \switchtobodyfont[10pt] \strut $\Gamma_{R}$ etex , z11) ; fill arrowheadonpath(gamma,.4) withcolor .625yellow ; fill arrowheadonpath(gammaR,.4) withcolor .625yellow ; fill arrowheadonpath(gammaRR,.4) withcolor .625yellow ; \stopbuffer This file has been typeset on \currentdate{} at \currenttime, with \doifmodeelse{mkiv} {mkiv, LuaTeX revision \luatexrevision, (LuaTeX date stamp \luatexdatestamp)} {mkii, using the command: \type{texexec basic-test.tex}}, ConTeXt version \contextversion. % LuaTeX version \luatexversion, This MetaPost graphic is shown with mkiv: \placefigure[middle][-]{}{\processMPbuffer[chemin-1]} {} \blank but not this one \placefigure[middle][-]{}{\processMPbuffer[axes-1]} {} \blank nor this one \placefigure[middle][-]{}{\processMPbuffer[axes-1,chemin-1]} {} \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] mkiv and MetaPost
On Wed, 14 Jan 2009, Otared Kavian wrote: Hi all, I have a file which contains the lines below: I can typeset it and obtain a correct result with mkii, but not with mkiv (the second buffer named axes-1 does not result in a MetaPost graphic when one says \processMPbuffer[axes-1]). The file and the resulting PDF can be found on http://www.kavian.fr/tex/bug-mkiv Thanks in advance for any help. Best regards: OK I did not run the file, just guessing. In MKIV, by default buffers are not written to disk, so \processMPbuffer does not find any. You can force \startbuffer to write stuff to disk, but a better way would be to modify \processMPbuffer to also search for memory buffers. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] mkiv and MetaPost
On 14 janv. 09, at 06:51, Aditya Mahajan wrote: On Wed, 14 Jan 2009, Otared Kavian wrote: Hi all, I have a file which contains the lines below: I can typeset it and obtain a correct result with mkii, but not with mkiv (the second buffer named axes-1 does not result in a MetaPost graphic when one says \processMPbuffer[axes-1]). The file and the resulting PDF can be found on http://www.kavian.fr/tex/bug-mkiv Thanks in advance for any help. Best regards: OK I did not run the file, just guessing. In MKIV, by default buffers are not written to disk, so \processMPbuffer does not find any. You can force \startbuffer to write stuff to disk, but a better way would be to modify \processMPbuffer to also search for memory buffers. Aditya Thanks Aditya for your explanation, but I must say that it is not convincing because with mkiv one of the buffers is processed with \processMPbuffer, while the other is not… So there must be some other hidden behaviour which has changed between mkii and mkiv. Best regards: OK ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] mkiv and MetaPost
Otared Kavian wrote: Thanks Aditya for your explanation, but I must say that it is not convincing because with mkiv one of the buffers is processed with \processMPbuffer, while the other is not… So there must be some other hidden behaviour which has changed between mkii and mkiv. I will leave it for Hans to figure what exactly goes wrong, but the problem is caused by the comment characters in the axes-1 buffer. Best wishes, Taco ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to overlap two figures?
On Tue, Nov 25, 2008 at 8:59 AM, 그래프 수학과 [EMAIL PROTECTED] wrote: Dear Yue, Thank you for the reply. why not process the base file figure each time before process each figure. Yes, That is what I did. I am curious if there is a way of shorten the length of code which is less important. you dont have to type the same code in each mp figure. see sec 3.4 of the metafun manual, you can processMPbuffer. Thank you again. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] How to overlap two figures?
2008/11/25 Yue Wang [EMAIL PROTECTED]: On Tue, Nov 25, 2008 at 8:59 AM, 그래프 수학과 [EMAIL PROTECTED] wrote: Dear Yue, Thank you for the reply. why not process the base file figure each time before process each figure. Yes, That is what I did. I am curious if there is a way of shorten the length of code which is less important. you dont have to type the same code in each mp figure. see sec 3.4 of the metafun manual, you can processMPbuffer. also, \includeMPgraphic discussed in sec 3.7 Thank you again. Best regards, Dalyoung ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] mkiv: bug in processMPbuffer
Hi Hans and Taco, The latest beta solves the problems metioned by Thomas Schmitz and myself concerning \uniqueMPgraphic: many thanks for your attention. However, I observed the following regarding \processMPbuffer: some grahpics don't show up when tyepset with mkiv, while they are fine with mkii. (This with mkiv, LuaTeX revision 2, (LuaTeX date stamp 2008102016), ConTeXt version 2008.10.23 17:32). (For the Chief of Rumour Control: it is not crucial to address the reported bug urgently…). Best regards: OK %% begin bug-processMPbuffer.tex \setupcolors[state=start] \starttext \startbuffer[axes-1] textextoffset := ExHeight ; numeric u ; u := .5cm ; vardef arrowheadonpath (expr p, s) = save autoarrows ; boolean autoarrows ; autoarrows := true ; set_ahlength(scaled ahfactor) ; % arrowhead p if s1 : cutafter (point (s*arclength(p)+.5ahlength) on p) fi enddef ; path xox ; xox := (-u,0)--(8u,0) ; path yoy ; yoy := (0,-u)--(0,7u) ; draw xox withcolor blue ; draw yoy withcolor blue ; ahfactor := 4 ; % default is 2.5 fill arrowheadonpath(xox,1) withcolor .625blue ; % try .25 fill arrowheadonpath(yoy,1) withcolor .625blue ; % try .25 \stopbuffer \startbuffer[chemin-1] textextoffset := ExHeight ; numeric u ; u := .5cm ; z1 = (5u,0) ; z2 = z1 rotated 60 ; z11 = z1 rotated 15 ; z12 = z1 rotated 30 ; z13 = z1 rotated 45 ; z0 = (2u,0) rotated 30 ; path gamma ; gamma := (0,0)--(5u,0) ; draw gamma withpen pencircle scaled .4mm withcolor .625yellow ; path gammaR ; gammaR := z1..z11..z12..z13..z2 ; draw gammaR withpen pencircle scaled .4mm withcolor .625yellow ; dotlabel.bot (btex \switchtobodyfont[10pt] \strut $R$ etex, z1) ; path gammaRR ; gammaRR := z2--(0,0) ; draw gammaRR withpen pencircle scaled .4mm withcolor .625yellow ; dotlabel.top (btex \switchtobodyfont[10pt] \strut $R{\rm e}^{2{\rm i} \pi/n}$ etex , z2) ; dotlabel.rt (btex \switchtobodyfont[10pt] \strut ${\rm e}^{{\rm i}\pi/ n}$ etex , z0) ; label.rt (btex \switchtobodyfont[10pt] \strut $\Gamma_{R}$ etex , z11) ; fill arrowheadonpath(gamma,.4) withcolor .625yellow ; fill arrowheadonpath(gammaR,.4) withcolor .625yellow ; fill arrowheadonpath(gammaRR,.4) withcolor .625yellow ; \stopbuffer This file has been typeset on \currentdate{} at \currenttime, with \doifmodeelse{mkiv} {mkiv, LuaTeX revision \luatexrevision, (LuaTeX date stamp \luatexdatestamp)} {mkii, using the command: \type{texexec basic-test.tex}}, ConTeXt version \contextversion. % LuaTeX version \luatexversion, This MetaPost graphic is shown with mkiv: \placefigure[middle][-]{none}{\processMPbuffer[chemin-1]} {} \blank but not this one \placefigure[middle][-]{none}{\processMPbuffer[axes-1]} {} \blank nor this one \placefigure[middle][-]{none}{\processMPbuffer[axes-1,chemin-1]} {} \stoptext %% end of bug-processMPbuffer.tex ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] Some Progress on Installing mswincontext.zip
All, As Idris and Hans expected, Ruby was the culprit. I had installed Ruby before downloading mswincontext.zip, as that was what I used to do in the old days with a Miktex installation. After following exactly these directions: http:// blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/173018 Scite now works on context documents. I tried to add metapost.properties to the global with import metapost. I can Build a file, but the Go command does not work because I don't have gv installed. So I opened metapost.properties and tried changing the gv command to gsview32 (and even tried c: \Program Files\ghostgum\gsview\gsview32.exe), but neither worked. Any suggestions how I can get the go command to work? Secondly, what would I do to compile a metapost file in scite directly into PDF? I am aware of context way with processMPbuffer and other assorted tricks, and I am aware of mptopdf, but what I am looking for is to configure Scite to compile the metapost file and open it in acrobat reader. Here is the test file I am trying to compile. beginfig(1); numeric u; 10u=4in; drawdblarrow (-5u,0)--(5u,0); drawdblarrow (0,-5u)--(0,5u); endfig; end. David Arnold College of the Redwoods Mathematics Department Eureka, CA 95501 (707) 476-4222 http://online.redwoods.edu/instruct/darnold/ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] new version
Aditya Mahajan wrote: On Fri, 11 Apr 2008, Hans Hagen wrote: Hi, concerning the mplibrary in mkiv ... - it does not use the metafun mem file; when formats are generated a special mem file is made and put alongside the context format - however, this only happens when a new version is found (is the case with a new zip), or when an error is encountered in the format (compatibility issue) - in case of doubt, or when you patch metafun, you can say ctxtool --touch texexec --make i will try to make this more robust in the future the new mkiv mp graphics implementations is prepared for mixed usage, i.e. we can use multiple metapost formats; i'm still not sure about the interface, for instance: \startuseMPgraphic{metafun:bla} ... \startuseMPgraphic{mpost:bla} ... or so, more news later This could break existing code. I sometimes use \startuseMPgraphic{system:bla} and {system:blabla} etc to distinguish all system diagrams. sure, but seldom metafun: i suppose -) How about 1. \defineMPreusegraphic[useMPgraphic][format=metafun] \defineMPreusegraphic[useMPOSTgraphic][format=mpost] and then one can use \startuseMPgraphic and \startuseMPOSTgraphic. 2. If you have to make the label of the graphic determine the format, then maybe something like \startuseMPgraphic{::metafun::bla} so that it does not break existing code. \startuseMPgraphic[metafun]{...} is also an option but not consistent, unless we provide \startuseMPgraphic[optional format][name][optional settings] which i somehow dislike 3. What about \startMPcode, \startMPpage, and \processMPbuffer? I think that the first approach will be easier to adapt. another option is: \useMPformat{metafun} (the reason for { }instead of [] is that it then can be used within [] without extra {}) yet another option is \startMPcode mpformat := metafun ... \stopMPcode and parse for it, but that has other disadvantages; anyhow ... more thinking needed - 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] new version
On Fri, Apr 11, 2008 at 9:39 AM, Hans Hagen [EMAIL PROTECTED] wrote: Aditya Mahajan wrote: On Fri, 11 Apr 2008, Hans Hagen wrote: Hi, concerning the mplibrary in mkiv ... - it does not use the metafun mem file; when formats are generated a special mem file is made and put alongside the context format - however, this only happens when a new version is found (is the case with a new zip), or when an error is encountered in the format (compatibility issue) - in case of doubt, or when you patch metafun, you can say ctxtool --touch texexec --make i will try to make this more robust in the future the new mkiv mp graphics implementations is prepared for mixed usage, i.e. we can use multiple metapost formats; i'm still not sure about the interface, for instance: \startuseMPgraphic{metafun:bla} ... \startuseMPgraphic{mpost:bla} ... or so, more news later This could break existing code. I sometimes use \startuseMPgraphic{system:bla} and {system:blabla} etc to distinguish all system diagrams. sure, but seldom metafun: i suppose -) How about 1. \defineMPreusegraphic[useMPgraphic][format=metafun] \defineMPreusegraphic[useMPOSTgraphic][format=mpost] and then one can use \startuseMPgraphic and \startuseMPOSTgraphic. 2. If you have to make the label of the graphic determine the format, then maybe something like \startuseMPgraphic{::metafun::bla} so that it does not break existing code. \startuseMPgraphic[metafun]{...} is also an option but not consistent, unless we provide \startuseMPgraphic[optional format][name][optional settings] which i somehow dislike 3. What about \startMPcode, \startMPpage, and \processMPbuffer? I think that the first approach will be easier to adapt. another option is: \useMPformat{metafun} \setupsystem [mpformat=metafun] (the reason for { }instead of [] is that it then can be used within [] without extra {}) This was something i never understood in the past, the difference between the name setting for buffers and MP graphics. yet another option is \startMPcode mpformat := metafun ... \stopMPcode No. Wolfgang ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] new version
On Fri, 11 Apr 2008, Hans Hagen wrote: Hi, concerning the mplibrary in mkiv ... - it does not use the metafun mem file; when formats are generated a special mem file is made and put alongside the context format - however, this only happens when a new version is found (is the case with a new zip), or when an error is encountered in the format (compatibility issue) - in case of doubt, or when you patch metafun, you can say ctxtool --touch texexec --make i will try to make this more robust in the future the new mkiv mp graphics implementations is prepared for mixed usage, i.e. we can use multiple metapost formats; i'm still not sure about the interface, for instance: \startuseMPgraphic{metafun:bla} ... \startuseMPgraphic{mpost:bla} ... or so, more news later This could break existing code. I sometimes use \startuseMPgraphic{system:bla} and {system:blabla} etc to distinguish all system diagrams. How about 1. \defineMPreusegraphic[useMPgraphic][format=metafun] \defineMPreusegraphic[useMPOSTgraphic][format=mpost] and then one can use \startuseMPgraphic and \startuseMPOSTgraphic. 2. If you have to make the label of the graphic determine the format, then maybe something like \startuseMPgraphic{::metafun::bla} so that it does not break existing code. 3. What about \startMPcode, \startMPpage, and \processMPbuffer? I think that the first approach will be easier to adapt. Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] A sometxt bug (rather misfeature)
Aditya Mahajan wrote: On Wed, 29 Aug 2007, Aditya Mahajan wrote: Hi, Found an interesting sometxt misfeature. \startMPinclusions boolean test ; test=true ; \stopMPinclusions \startbuffer[test] if test : label(\sometxt{True}, origin) ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] \blank[big] \startMPinitializations test := false ; \stopMPinitializations \processMPbuffer[test] Too bad context cannnot parse metapost syntax :) Workaround (ugly) Another workaround, slightly less ugly (as long as you count the number of \sometxt in the if part. \startbuffer[test] if test : label(\sometxt{True}, origin) ; else : txtnext := txtnext + 1 ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] picture p ; p := label(\sometxt{True}, origin) ; if test then draw p ; fi ; label(\sometxt{False}, (10,10)) ; - 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
[NTG-context] A sometxt bug (rather misfeature)
Hi, Found an interesting sometxt misfeature. \startMPinclusions boolean test ; test=true ; \stopMPinclusions \startbuffer[test] if test : label(\sometxt{True}, origin) ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] \blank[big] \startMPinitializations test := false ; \stopMPinitializations \processMPbuffer[test] Too bad context cannnot parse metapost syntax :) Workaround (ugly) \startTeXtexts \TeXtext{1000}{True} \stopTeXtexts \startbuffer[test] if test : label(sometxt(1000), origin) ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] A sometxt bug (rather misfeature)
On Wed, 29 Aug 2007, Aditya Mahajan wrote: Hi, Found an interesting sometxt misfeature. \startMPinclusions boolean test ; test=true ; \stopMPinclusions \startbuffer[test] if test : label(\sometxt{True}, origin) ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] \blank[big] \startMPinitializations test := false ; \stopMPinitializations \processMPbuffer[test] Too bad context cannnot parse metapost syntax :) Workaround (ugly) Another workaround, slightly less ugly (as long as you count the number of \sometxt in the if part. \startbuffer[test] if test : label(\sometxt{True}, origin) ; else : txtnext := txtnext + 1 ; fi ; label(\sometxt{False}, (10,10)) ; \stopbuffer \processMPbuffer[test] Aditya ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___
Re: [NTG-context] Draw chess board
Hi guys I've modified my module again, then you can click to demostrate a game. The source file is attached and the resulting pdf file is pretty huge so I just upload to my google page (I think there's a bandwidth limitation so I use winrar to compress it): http://zhichu.chen.googlepages.com/sgfstack.rar On 6/11/07, Zhichu Chen [EMAIL PROTECTED] wrote: Hi Mojca, The stones are very very nice now, thank you for your hints. Since I haven't used TikZ before, I have no idea how to handle these events. I'll learn it later and rewrite my module to be more professional :) All I'm thinking now is how to make each step a single symbol so that I could use \fieldstack to demonstrate the game. By the way, I modified my module to do some fieldstack thing, but it gets a weird error. I have no idea what's the error about, it's fine when I'm using MPdrawing environment but it can't output anything when I switch to buffer and use \processMPbuffer. On 6/10/07, Mojca Miklavec [EMAIL PROTECTED] wrote: On 6/6/07, Zhichu Chen wrote: Hi I've tried to write a test file which can only handle ;B[??], ;W[??], AB[??], AW[??] now, and I haven't added the interaction part. But it is a good start. Any suggestions? Wow - that's really, really impressive! You indeed started parsing the strings in plain TeX! I've changed your source slightly, to give you an idea of yet another approach: using TikZ. It's main advantage over metapost might be: - you can draw more fancy stones (see the example - that could be made configurable of course), although teoretically the same could be achived with slightly improved smooth shading mechanism in mptopdf macros - might be easier to backport to (La)TeX - I can imagine your module to be a new, really nice TikZ package/module (that could be used in other flavours of TeX) + some fancy ConTeXt additions (user interface, javascript, ...). The main difference is that you need to store all the variables in TeX, not in metapost, so that part should be rewritten as well (which I didn't do). But simply forget about my stupid comments about (La)TeX for and do it your way now. Mojca (I have some other comments, but it's too early to speak about them, since the module is not ready/complete yet.) On 5/24/07, Zhichu Chen wrote: Hi I love chess games, especially one kind of them which is generally called Go. I know there is some file can store each details in one game: http://www.red-bean.com/sgf/ AFAIK, there is no module available to draw chess in ConTeXt now. I wanna do this by using MetaPost and fieldstack. But I don't know how to tell metapost the details of the sgf file. Can anyone give me a suggestion? BTW, I don't like the name. It's invented by acient Chinese and it's called Weiqi. I think we can call it Siege Chess in English. -- Best Regards Chen ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___ -- Best Regards Chen Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn -- Best Regards Chen Zhi-chu Chen | Shanghai Synchrotron Radiation Facility No. 2019 | Jialuo Rd. | Jiading | Shanghai | P.R. China tel: 086 21 5955 3405 | zhichu.chen.googlepages.com | www.sinap.ac.cn sgfstack.tex Description: TeX document ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : https://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___