[NTG-context] MetaFun path joiners && and &&&& do not like single point paths
Hi MetaFun fans, Following a suggestion of Hans, I experimented with && and &&& and for joining paths in MetaFun. The joiner &&& produces one long path, but && and seem to produce a disconnected path which includes all the original paths. However, if one of the paths is a single point, then it connects it. MWE below. I spotted this on my globes module, where we saw an extra line appear for a very specific orientation of the globe. I guessed that this orientation had an island right on the horizon, so that only one boundary point was visible, creating a singe point path for that island. I should probably fix my module so it doesn’t do that. However, it might be nice to have && and deal with this situation gracefully. Gavin \startMPpage path p[], q ; p1 = fullcircle scaled 3cm ; p2 = fullcircle scaled 2cm shifted (3cm,0) ; p3 = (3cm,2cm) ; q = for i = 1 upto 3 : p[i] && endfor cycle ; draw p1 withpen pencircle scaled 2pt withcolor .7 ; draw p2 withpen pencircle scaled 2pt withcolor .7 ; draw p3 withpen pencircle scaled 2pt withcolor .7 ; draw q withcolor red ; eofill q withcolor 0.9 ; draw fullcircle scaled 6cm shifted (1.25cm,0) ; \stopMPpage ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___
Re: [NTG-context] metafun paralleled does not give a parallel path
On 8/25/2022 6:05 PM, Bruce Horrocks via ntg-context wrote: I'm seeing the line + arcs behaviour here. fixed in upload (we had a bug in mplib .. direction is now a primitive so that one was wrong) 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] metafun paralleled does not give a parallel path
I'm seeing the line + arcs behaviour here. ConTeXt ver: 2022.08.05 11:44 LMTX fmt: 2022.8.5 int: english/english > On 25 Aug 2022, at 13:03, Fabrice L via ntg-context > wrote: > > Hi, > >> Le 24 août 2022 à 22:50, fv leung via ntg-context a >> écrit : >> >> The following used to produce three parallel lines. >> Now it produces one straight line and two arcs. >> >> \starttext >> >> \startMPcode >> z0 = origin; >> z1 = 72dir(45); >> dotlabel.bot("z0", z0); >> draw z0--z1; >> draw (z0--z1) paralleled -15 withcolor red; >> draw (z0--z1) paralleled 15 withcolor blue; >> \stopMPcode >> >> \stoptext > > Your code produce three perfect parallels lines here, see attached pdf. > F. > > — Bruce Horrocks Hampshire, UK ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] metafun paralleled does not give a parallel path
Hi,Le 24 août 2022 à 22:50, fv leung via ntg-contexta écrit :The following used to produce three parallel lines.Now it produces one straight line and two arcs.\starttext\startMPcode z0 = origin; z1 = 72dir(45); dotlabel.bot("z0", z0); draw z0--z1; draw (z0--z1) paralleled -15 withcolor red; draw (z0--z1) paralleled 15 withcolor blue;\stopMPcode \stoptextYour code produce three perfect parallels lines here, see attached pdf. F. parralel.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 / https://www.ntg.nl/mailman/listinfo/ntg-contextwebpage : https://www.pragma-ade.nl / http://context.aanhet.netarchive : https://bitbucket.org/phg/context-mirror/commits/wiki : https://contextgarden.net__ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] metafun paralleled does not give a parallel path
The following used to produce three parallel lines. Now it produces one straight line and two arcs. \starttext \startMPcode z0 = origin; z1 = 72dir(45); dotlabel.bot("z0", z0); draw z0--z1; draw (z0--z1) paralleled -15 withcolor red; draw (z0--z1) paralleled 15 withcolor blue; \stopMPcode \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] MetaFun keywords extracted by mtxrun --script interface
I am updating Vim syntax coloring for Metapost/MetaFun, which is now based on the files that are automatically generated with mtxrun --script interface --vim To test the results, I am opening ConTeXt's own MetaPost files in the editor and check how they look. It seems that the output of the above command is missing several "keywords". For instance: beginglyph, endglyph, anglestriped, numberstriped, roundedsquarexy, starring, dashing, pathpoint, primitive, immutable, etc. Is it because MetaFun keywords are picked up manually? Nicola ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun hexagons aren't hexagons
On Thu, 21 Jul 2022 18:51:23 +0200 Hans Hagen via ntg-context wrote: > On 7/21/2022 5:56 AM, Alan via ntg-context wrote: > > On Wed, 20 Jul 2022 15:26:53 -0600 > > Max Chernoff via ntg-context wrote: > > > >> The recently added Metafun hexagons seem to be producing octagons > >> instead: > >> > >> \startMPpage > >> fill fullhexagon scaled 100; > >> draw unithexagon scaled 50 withcolor white; > >> \stopMPpage > > > > Of course, for an MP circle is defined by 8 points. > > > > draw textext(decimal length unitcircle) ; > i'll change it to octagon (was only used for some envelope tracing > experiment) \startMPcode fullhexagon := for i=0 upto 5 : .5dir(60i) -- endfor cycle ; unithexagon := fullhexagon shifted (.5,.5) ; draw fullhexagon scaled 1cm ; draw unithexagon scaled 1cm withcolor red ; draw unitcircle scaled 1cm withcolor red ; draw fullcircle scaled 1cm ; \stopMPcode ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun hexagons aren't hexagons
On 7/21/2022 5:56 AM, Alan via ntg-context wrote: On Wed, 20 Jul 2022 15:26:53 -0600 Max Chernoff via ntg-context wrote: The recently added Metafun hexagons seem to be producing octagons instead: \startMPpage fill fullhexagon scaled 100; draw unithexagon scaled 50 withcolor white; \stopMPpage Of course, for an MP circle is defined by 8 points. draw textext(decimal length unitcircle) ; i'll change it to octagon (was only used for some envelope tracing experiment) - 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun hexagons aren't hexagons
On Wed, 20 Jul 2022 15:26:53 -0600 Max Chernoff via ntg-context wrote: > The recently added Metafun hexagons seem to be producing octagons > instead: > >\startMPpage >fill fullhexagon scaled 100; >draw unithexagon scaled 50 withcolor white; >\stopMPpage Of course, for an MP circle is defined by 8 points. draw textext(decimal length unitcircle) ; Alan ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] Metafun hexagons aren't hexagons
Hi, The recently added Metafun hexagons seem to be producing octagons instead: \startMPpage fill fullhexagon scaled 100; draw unithexagon scaled 50 withcolor white; \stopMPpage -- Max ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
Dear Bruce, dear list, > Le 19 juill. 2022 à 07:42, Bruce Horrocks a écrit : > >> On 19 Jul 2022, at 04:28, Fabrice L via ntg-context >> wrote: >> >> Complementary question : I saw that the « pos_a » « pos_b » of the example >> could not take numerical value, for example pos_1, pos_2.. How can I use >> metafun to write a macro to save the contents of hundreds of variable in >> this object, something like : >> >> getparameters "MyData » [ >> for i=1 upto 100 : >> pos_decimal(i) = ThePosition[i], >> endfor ; >> ] ; >> >> If this is possible, then this is wonderful and open news doors ! > > I've adapted this example from the metafun-p manual by adding some "write" > statements. I have read the manuals, but not enough it seems ! I missed this part ! I completely miss the «write to » and « read from » instructions. Even a research on the web before posting did not return something interesting. I guess I did not used the good terms, because now, I find some ressources about these functions ! > > \starttext > \startMPpage > > numeric done[][], i, j, n ; n := 0 ; > forever : > i := round(uniformdeviate(10)) ; > j := round(uniformdeviate(10)) ; > if unknown done[i][j] : > drawdot > (i*cm,j*cm) > withpen pencircle scaled 0.5cm > withcolor darkred; > n := n + 1 ; > done[i][j] := n ; > > write "done[" & tostring(i) & "][" & tostring(j) & "] := " & > tostring(n) & " ;" to "mp_test_file.txt" ; > > fi ; > exitif n = 10 ; > > endfor ; > > write EOF to "mp_test_file.txt" ; > > \stopMPpage > \stoptext > > This results in the expected graphic but also a local file (in the same > directory as the source) called "mp_test_file.txt" that contains: > > done[9][1] := 1 ; > done[4][3] := 2 ; > done[5][3] := 3 ; > done[5][1] := 4 ; > done[2][9] := 5 ; > done[8][6] := 6 ; > done[9][10] := 7 ; > done[9][7] := 8 ; > done[10][2] := 9 ; > done[6][5] := 10 ; > > I think, with a bit of judicious use of "write" statements to add some > ConTeXt / MP setup code, it would be possible to include the output from the > previous run as MP source of the next run. > > Hope this helps, or at least provides some food for thought. Totally, a lot of food ! Here is my yesterday example with these functions : \starttext \startMPpage pair ThePosition[]; ThePosition[1] := (0,0) ; ThePosition[2] := (10,10) ; draw ThePosition[1] -- ThePosition[2] ; % Save the position into a file "bruce.mp" for i=1 upto 2: write "ThePosition[" & tostring(i) & "] := (" & tostring(xpart(ThePosition[i])) & ","& tostring(ypart(ThePosition[i])) &") ;" to "bruce.mp" ; endfor; write EOF to "bruce.mp" ; \stopMPpage % The external file would like like (comment added manually here): % ThePosition[1] := (0,0) ; % ThePosition[2] := (10,10) ; % We modify the value of ThePosition[2] \startMPpage ThePosition[2] := (10,0) ; draw ThePosition[1] -- ThePosition[2] ; \stopMPpage % We now read the value of ThePosition[2] from the file \startMPpage input "bruce.mp"; % Save the data from the external file draw ThePosition[1] -- ThePosition[2] ; \stopMPpage \stoptext > > (Note you need to delete the mp_test_file.txt before re-running else it > fails.) So this totally do the trick : once again, magic is happening ! Note that in my installation, I do not need to delete the external file. > > — > Bruce Horrocks > Hampshire, UK Thanks a lot ! Fabrice. > ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
> On 19 Jul 2022, at 04:28, Fabrice L via ntg-context > wrote: > > Complementary question : I saw that the « pos_a » « pos_b » of the example > could not take numerical value, for example pos_1, pos_2.. How can I use > metafun to write a macro to save the contents of hundreds of variable in this > object, something like : > > getparameters "MyData » [ > for i=1 upto 100 : > pos_decimal(i) = ThePosition[i], > endfor ; > ] ; > > If this is possible, then this is wonderful and open news doors ! I've adapted this example from the metafun-p manual by adding some "write" statements. \starttext \startMPpage numeric done[][], i, j, n ; n := 0 ; forever : i := round(uniformdeviate(10)) ; j := round(uniformdeviate(10)) ; if unknown done[i][j] : drawdot (i*cm,j*cm) withpen pencircle scaled 0.5cm withcolor darkred; n := n + 1 ; done[i][j] := n ; write "done[" & tostring(i) & "][" & tostring(j) & "] := " & tostring(n) & " ;" to "mp_test_file.txt" ; fi ; exitif n = 10 ; endfor ; write EOF to "mp_test_file.txt" ; \stopMPpage \stoptext This results in the expected graphic but also a local file (in the same directory as the source) called "mp_test_file.txt" that contains: done[9][1] := 1 ; done[4][3] := 2 ; done[5][3] := 3 ; done[5][1] := 4 ; done[2][9] := 5 ; done[8][6] := 6 ; done[9][10] := 7 ; done[9][7] := 8 ; done[10][2] := 9 ; done[6][5] := 10 ; I think, with a bit of judicious use of "write" statements to add some ConTeXt / MP setup code, it would be possible to include the output from the previous run as MP source of the next run. Hope this helps, or at least provides some food for thought. (Note you need to delete the mp_test_file.txt before re-running else it fails.) — Bruce Horrocks Hampshire, UK ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
> Le 18 juill. 2022 à 12:31, Hans Hagen via ntg-context a > écrit : > > On 7/18/2022 3:20 PM, Fabrice L via ntg-context wrote: >> Dear list, >> I’m doing animations in MetaFun, by simply using \startMPpage (…) >> \stopMPpage for each frame of the animation. Here is an example: >> https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by >> adjusting the setting in YouTube). >> This works usually great, but when the number of objects to draw by page is >> large, the resulting pdf file could be huge, several gigabytes sometimes. >> Such huge files are difficult (sometimes impossible) to convert in jpeg >> files (I’m using Image magick for the conversion), necessary to do a mp4 >> movie. >> One solution is to do several pdf files, for example one by second; with >> this option, I can do 60 files of 30 pages, for an animation of 60 seconds >> (1800 frames for 1 minute). Everything is smoother this way, quicker to >> convert files. But in order to do so, I have to be able to describe each >> frame of the animation with the same set of instructions; so the position of >> an object at time t is described by an equation for example. >> But this is not always possible. If the animation is based on a random >> process, the position of an object at time t depends on his position at time >> t-1. I can still use this preceeding strategy by simulating the past at the >> begging of each second, starting with a unique random seed. So for example >> if I work on second 9, I begin by calculating the past from frame 1 to frame >> 240 (8*30) and then simulate time 241, draw frame 241, simulate time 242, >> draw time 242, etc.. This could be complicated to do, but is feasible. The >> drawback is that more I advance in time, the more computations I have to do >> at the beginning of each file. >> So to simplify things, one option would be to be save the state of some >> variables at some point in time, say t, in order to be able to access these >> informations at time t+1. So the strategy would be : >> % File second1.pdf >> for frame =1 to 30 : >> simulate position of objects ; >> draw the frame ; >> endfor; >> save the position of all objects ; >> % File second2.pdf >> Read (access) the position of all objects from second 1(after frame 30); >> for frame =31 to 60 : >> simulate position of objects ; >> draw the frame ; >> endfor; >> save the position of all objects ; >> Etc... >> Does someone has an idea of how to do such a thing ? I can read text file in >> Context with no problem and integrate them in the animation process with >> \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write >> information from MetaFun to a text file. Is Lua the solution ? > there's always an idea ... Great ! And thanks… Of course, it takes me some time to understand, and a little reading in the metafun xl manual, but now I catch it ! > > \starttext > \startMPpage > runscript("metapost.setparameterset('test', table.load('mydata.lua') or { > })") ; > path b ; b := getparameterpath "test" "test_c"; > draw fullcircle scaled 3cm ; > draw b scaled .4; > % show(b); > getparameters "test" [ > test_a = 123, > test_b = (456,789), > test_c = (boundingbox currentpicture) > ] ; > runscript("table.save('mydata.lua',(metapost.getparameterset('test')))") ; > \stopMPpage > \stoptext > > but maybe i need abetter one .. a proper save/restore in the tuc file or so, > but you can play with this first > > Hans If someones in the futur needs more explanation (like me!), here is my minimal working example derived from the one of Hans: First page, we assign a value to the pair « ThePosition[2] », write the value in a file (« TheMagicalFile.lua »), change the value in memory in the second page, and then read it from the external file in the third page. Of course, it works ! And this could run in separates process of course. % \starttext \startMPpage pair ThePosition[]; ThePosition[1] := (0,0) ; ThePosition[2] := (10,10) ; draw ThePosition[1] -- ThePosition[2] ; % save the parameters in the object MyData getparameters "MyData" [ pos_a = ThePosition[1], pos_b = ThePosition[2] ] ; % Save this object in a file runscript("table.save('TheMagicalFile.lua',(metapost.getparameterset('MyData')))") ; \stopMPpage % We modify the value of ThePosition[2] \startMPpage ThePosition[2] := (10,0) ; draw ThePosition[1] -- ThePosition[2] ; \stopMPpage % We now read the value of ThePosition[2] from the file \startMPpage % Save the data from the external file runscript("metapost.setparameterset('MyData', table.load('TheMagicalFile.lua') or { })") ; ThePosition[2] := getparameter "MyData" "pos_b" ; draw ThePosition[1] -- ThePosition[2] ; \stopMPpage \stoptext % Complementary question : I saw that the « pos_a » « pos_b » of the example could not take numerical value, for example pos_1, pos_2.. How can I use metafun to write a macro to save the contents of
Re: [NTG-context] Metafun : save memory content ?
Storing in a memory block in the computers' internal memory would be super, of course. But I am afraid that is asking a bit too much;-) dr. Hans van der Meer > On 18 Jul 2022, at 18:31, Hans Hagen via ntg-context > wrote: > > On 7/18/2022 3:20 PM, Fabrice L via ntg-context wrote: >> Dear list, >> I’m doing animations in MetaFun, by simply using \startMPpage (…) >> \stopMPpage for each frame of the animation. Here is an example: >> https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by >> adjusting the setting in YouTube). >> This works usually great, but when the number of objects to draw by page is >> large, the resulting pdf file could be huge, several gigabytes sometimes. >> Such huge files are difficult (sometimes impossible) to convert in jpeg >> files (I’m using Image magick for the conversion), necessary to do a mp4 >> movie. >> One solution is to do several pdf files, for example one by second; with >> this option, I can do 60 files of 30 pages, for an animation of 60 seconds >> (1800 frames for 1 minute). Everything is smoother this way, quicker to >> convert files. But in order to do so, I have to be able to describe each >> frame of the animation with the same set of instructions; so the position of >> an object at time t is described by an equation for example. >> But this is not always possible. If the animation is based on a random >> process, the position of an object at time t depends on his position at time >> t-1. I can still use this preceeding strategy by simulating the past at the >> begging of each second, starting with a unique random seed. So for example >> if I work on second 9, I begin by calculating the past from frame 1 to frame >> 240 (8*30) and then simulate time 241, draw frame 241, simulate time 242, >> draw time 242, etc.. This could be complicated to do, but is feasible. The >> drawback is that more I advance in time, the more computations I have to do >> at the beginning of each file. >> So to simplify things, one option would be to be save the state of some >> variables at some point in time, say t, in order to be able to access these >> informations at time t+1. So the strategy would be : >> % File second1.pdf >> for frame =1 to 30 : >> simulate position of objects ; >> draw the frame ; >> endfor; >> save the position of all objects ; >> % File second2.pdf >> Read (access) the position of all objects from second 1(after frame 30); >> for frame =31 to 60 : >> simulate position of objects ; >> draw the frame ; >> endfor; >> save the position of all objects ; >> Etc... >> Does someone has an idea of how to do such a thing ? I can read text file in >> Context with no problem and integrate them in the animation process with >> \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write >> information from MetaFun to a text file. Is Lua the solution ? > there's always an idea ... > > \starttext >\startMPpage >runscript("metapost.setparameterset('test', table.load('mydata.lua') > or { })") ; >path b ; b := getparameterpath "test" "test_c"; >draw fullcircle scaled 3cm ; >draw b scaled .4; > % show(b); >getparameters "test" [ >test_a = 123, >test_b = (456,789), >test_c = (boundingbox currentpicture) >] ; > runscript("table.save('mydata.lua',(metapost.getparameterset('test')))") ; >\stopMPpage > \stoptext > > but maybe i need abetter one .. a proper save/restore in the tuc file or so, > but you can play with this first > > 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 / > https://www.ntg.nl/mailman/listinfo/ntg-context > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
On 7/18/2022 3:20 PM, Fabrice L via ntg-context wrote: Dear list, I’m doing animations in MetaFun, by simply using \startMPpage (…) \stopMPpage for each frame of the animation. Here is an example: https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by adjusting the setting in YouTube). This works usually great, but when the number of objects to draw by page is large, the resulting pdf file could be huge, several gigabytes sometimes. Such huge files are difficult (sometimes impossible) to convert in jpeg files (I’m using Image magick for the conversion), necessary to do a mp4 movie. One solution is to do several pdf files, for example one by second; with this option, I can do 60 files of 30 pages, for an animation of 60 seconds (1800 frames for 1 minute). Everything is smoother this way, quicker to convert files. But in order to do so, I have to be able to describe each frame of the animation with the same set of instructions; so the position of an object at time t is described by an equation for example. But this is not always possible. If the animation is based on a random process, the position of an object at time t depends on his position at time t-1. I can still use this preceeding strategy by simulating the past at the begging of each second, starting with a unique random seed. So for example if I work on second 9, I begin by calculating the past from frame 1 to frame 240 (8*30) and then simulate time 241, draw frame 241, simulate time 242, draw time 242, etc.. This could be complicated to do, but is feasible. The drawback is that more I advance in time, the more computations I have to do at the beginning of each file. So to simplify things, one option would be to be save the state of some variables at some point in time, say t, in order to be able to access these informations at time t+1. So the strategy would be : % File second1.pdf for frame =1 to 30 : simulate position of objects ; draw the frame ; endfor; save the position of all objects ; % File second2.pdf Read (access) the position of all objects from second 1(after frame 30); for frame =31 to 60 : simulate position of objects ; draw the frame ; endfor; save the position of all objects ; Etc... Does someone has an idea of how to do such a thing ? I can read text file in Context with no problem and integrate them in the animation process with \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write information from MetaFun to a text file. Is Lua the solution ? there's always an idea ... \starttext \startMPpage runscript("metapost.setparameterset('test', table.load('mydata.lua') or { })") ; path b ; b := getparameterpath "test" "test_c"; draw fullcircle scaled 3cm ; draw b scaled .4; % show(b); getparameters "test" [ test_a = 123, test_b = (456,789), test_c = (boundingbox currentpicture) ] ; runscript("table.save('mydata.lua',(metapost.getparameterset('test')))") ; \stopMPpage \stoptext but maybe i need abetter one .. a proper save/restore in the tuc file or so, but you can play with this first 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
On 7/18/2022 4:39 PM, Henning Hraban Ramm via ntg-context wrote: Am 18.07.22 um 15:20 schrieb Fabrice L via ntg-context: Dear list, I’m doing animations in MetaFun, by simply using \startMPpage (…) \stopMPpage for each frame of the animation. Here is an example: https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by adjusting the setting in YouTube). A great piece again! I’m amazed every time I look at your homepage (https://art-aleatoire.com for those who don’t know it). Does someone has an idea of how to do such a thing ? I can read text file in Context with no problem and integrate them in the animation process with \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write information from MetaFun to a text file. Is Lua the solution ? Lua is always the solution ;) but I don’t understand enough of both Lua and MetaFun... Maybe there’s something in luametafun.pdf*? *) Hans, this is one of the manuals that doesn’t have interaction, i.e. links and bookmarks; would be more usable with them. time ... time .. time 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 / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] Metafun : save memory content ?
Am 18.07.22 um 15:20 schrieb Fabrice L via ntg-context: Dear list, I’m doing animations in MetaFun, by simply using \startMPpage (…) \stopMPpage for each frame of the animation. Here is an example: https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by adjusting the setting in YouTube). A great piece again! I’m amazed every time I look at your homepage (https://art-aleatoire.com for those who don’t know it). Does someone has an idea of how to do such a thing ? I can read text file in Context with no problem and integrate them in the animation process with \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write information from MetaFun to a text file. Is Lua the solution ? Lua is always the solution ;) but I don’t understand enough of both Lua and MetaFun... Maybe there’s something in luametafun.pdf*? *) Hans, this is one of the manuals that doesn’t have interaction, i.e. links and bookmarks; would be more usable with them. Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] Metafun : save memory content ?
Dear list, I’m doing animations in MetaFun, by simply using \startMPpage (…) \stopMPpage for each frame of the animation. Here is an example: https://youtu.be/yhxUbVQx9Uo (please note you can watch it in HD by adjusting the setting in YouTube). This works usually great, but when the number of objects to draw by page is large, the resulting pdf file could be huge, several gigabytes sometimes. Such huge files are difficult (sometimes impossible) to convert in jpeg files (I’m using Image magick for the conversion), necessary to do a mp4 movie. One solution is to do several pdf files, for example one by second; with this option, I can do 60 files of 30 pages, for an animation of 60 seconds (1800 frames for 1 minute). Everything is smoother this way, quicker to convert files. But in order to do so, I have to be able to describe each frame of the animation with the same set of instructions; so the position of an object at time t is described by an equation for example. But this is not always possible. If the animation is based on a random process, the position of an object at time t depends on his position at time t-1. I can still use this preceeding strategy by simulating the past at the begging of each second, starting with a unique random seed. So for example if I work on second 9, I begin by calculating the past from frame 1 to frame 240 (8*30) and then simulate time 241, draw frame 241, simulate time 242, draw time 242, etc.. This could be complicated to do, but is feasible. The drawback is that more I advance in time, the more computations I have to do at the beginning of each file. So to simplify things, one option would be to be save the state of some variables at some point in time, say t, in order to be able to access these informations at time t+1. So the strategy would be : % File second1.pdf for frame =1 to 30 : simulate position of objects ; draw the frame ; endfor; save the position of all objects ; % File second2.pdf Read (access) the position of all objects from second 1(after frame 30); for frame =31 to 60 : simulate position of objects ; draw the frame ; endfor; save the position of all objects ; Etc... Does someone has an idea of how to do such a thing ? I can read text file in Context with no problem and integrate them in the animation process with \startMPinclusions (…) \stopMPinclusions, but I did not find a way to write information from MetaFun to a text file. Is Lua the solution ? Thanks for any help ! Fabrice. ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] MetaFun manual's "texvar" is not working for me
Hello list, I’m trying to reproduce the positional graphics examples in the MetaFun manual on pp. 151-153. There are two examples of code for the mpos:box. The first example uses \MPvar to retrieve variables set using \setupMPvariables. This works fine. The second example uses texvar to retrieve variables, but it does not work in the current LMTX. However, the second example does work with my TeXLive install. I’ve put my working example below, with both versions of the mpos:box code. Log output from a failed run is below that. Any ideas where I might be going wrong? Thanks! Gavin \setupbackgrounds [page] [background={backgraphics,foreground,foregraphics}] \defineoverlay [backgraphics] [\positionoverlay{backgraphics}] \defineoverlay [foregraphics] [\positionoverlay{foregraphics}] \setupMPvariables [mpos:box] [linecolor=blue, linewidth=\linewidth, fillcolor=lightgray, filloffset=2pt] This mpos:box works using \MPvar. %%% \startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} string tag; tag := "\MPvar{self}" ; path box ; box := positionbox(tag) ; box := box enlarged \MPvar{filloffset} ; fill box withcolor \MPvar{fillcolor} ; draw box withcolor \MPvar{linecolor} withpen pencircle scaled \MPvar{linewidth} ; positioninregion ; \stopMPpositiongraphic %%% This mpos:box does not work using texvar. (log below) %%% %\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth} % path box ; box := positionbox(texstr("self")) ; % box := box enlarged texvar("filloffset") ; % fill box %withcolor texvar("fillcolor") ; % draw box %withcolor texvar("linecolor") %withpen pencircle scaled texvar("linewidth") ; % positioninregion ; %\stopMPpositiongraphic \starttext to get \hpos {A-0} {positions} sorted \startpositionoverlay{backgraphics} \setMPpositiongraphic{A-0}{mpos:box}{self=A-0} \stoppositionoverlay \stoptext system > system > ConTeXt ver: 2022.05.11 11:36 LMTX fmt: 2022.5.20 int: english/english system > system > 'cont-new.mkxl' loaded open source > level 1, order 1, name '/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl' system > beware: some patches loaded from cont-new.mkiv close source> level 1, order 1, name '/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl' system > files > jobname './ContractionExperiments', input './ContractionExperiments.tex', result './ContractionExperiments' fonts > latin modern fonts are not preloaded languages > language 'en' is active system > synctex functionality is enabled, expect 5-10 pct runtime overhead! open source > level 1, order 2, name './ContractionExperiments.tex' fonts > preloading latin modern fonts (second stage) fonts > 'fallback modern-designsize rm 12pt' is loaded metapost> initializing instance 'metafun:1' using format 'metafun' and method 'double' metapost> loading 'metafun' as 'metafun.mpxl' using method 'double' metapost> initializing number mode 'double' metapost> trace > This is MPLIB for LuaMetaTeX, version 3.12, running in double mode. metapost> trace > metapost> trace > loading metafun for lmtx, including the plain 1.004 base definitions metapost> trace > metafun > log > metafun > log > error: Missing ')' has been inserted metafun > log > metapost> trace > , metapost> trace > paired -> -> begingroup.if.pair(EXPR2):(EXPR2)else:((EXPR2),(EXPR2))fi.endgroup metapost> trace > , metapost> trace > llmoved -> -> ((llcorner(EXPR0))shifted(-xpart.paired((EXPR1)),-ypart.paired((EXPR1 metapost> trace > { metapost> trace > -- -> -> {curl1}..{curl1} metapost> trace > enlarged -> -> ((EXPR0)llmoved(EXPR1)--(EXPR0)lrmoved(EXPR1)--(EXPR0)urmoved(EXPR1)--(EXPR0)ulmoved(EXPR1)--cycle) metapost> trace > ; metafun > log > metafun > log > I found no right delimiter to match a left one. So I've put one in, behind the scenes; this may fix the problem. metafun > log > metapost> trace > path box ; box := positionbox(texstr("self")) ; box := box enlarged texvar("filloffset") ; fill box withcolor texvar("fillcolor") ; draw box withcolor texvar("linecolor") withpen pencircle scaled texvar("linewidth") ; positioninregion ; ; metapost> trace > backend > xmp > using file '/Users/Gavin/context-osx-arm64/tex/texmf-context/tex/context/base/mkiv/lpdf-pdx.xml' pages > flushing realpage 1, userpage 1, subpage 1___ 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
Re: [NTG-context] Metafun, difficulty with graphical element in the margin
Hello Wolfgang, thank you so much for your time and investigation. — Indeed your solution works fine! I use the latest version from March 2022. I use \startbodymatter cum suis. Lieber Gruß Willi > On 20 Mar 2022, at 17:21, Wolfgang Schuster via ntg-context > wrote: > > Willi Egger via ntg-context schrieb am 20.03.2022 um 17:05: >> Hoi Wolfgang, >> >> I tested both variants (bodymatter and bodypart. The compilation runs >> through, however without the thumb-picture in the margin and the metafun >> error is in the log. > > 1. Do you use \startfrontmatter and \startbodymatter in your document to > create blocks? > > 2. Is you installation up-to-date? > > Attached is a slightly modified version of your example, the only thing which > has to be local to the bodypart is the background setting to enable the thumb > pictures. > > 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 : 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] Metafun, difficulty with graphical element in the margin
Willi Egger via ntg-context schrieb am 20.03.2022 um 17:05: Hoi Wolfgang, I tested both variants (bodymatter and bodypart. The compilation runs through, however without the thumb-picture in the margin and the metafun error is in the log. 1. Do you use \startfrontmatter and \startbodymatter in your document to create blocks? 2. Is you installation up-to-date? Attached is a slightly modified version of your example, the only thing which has to be local to the bodypart is the background setting to enable the thumb pictures. Wolfgang \definecolor [chap_frame] [black] \definecolor [textcolor] [white] \startuseMPgraphic{chapter-thumb} path chap_frame ; pair pos,a,b ; picture Chap ; if \somenamedheadnumber{chapter}{current} > 0 : curr_chap := \somenamedheadnumber{chapter}{current} ; else : curr_chap := 1 ; fi; if \somenamedheadnumber{chapter}{last} > 0 : last_chap := \somenamedheadnumber{chapter}{last} ; else : last_chap := 1 ; fi; if \somenamedheadnumber{section}{current} > 0 : curr_sect := \somenamedheadnumber{section}{current} ; else: curr_sect := 1 ; fi; if \somenamedheadnumber{section}{last} > 0 : last_sect := \somenamedheadnumber{section}{last} ; else: last_sect := 1; fi; if curr_chap < 11 : skip := TextHeight * (curr_chap-1)/11 ; elseif curr_chap < 21 : skip := TextHeight * (curr_chap-11)/11 ; else: skip := TextHeight * (curr_chap-21)/11 ; fi; Chap := textext("\bfa\textcolor\getmarking[chapter]") ; StartPage ; chap_frame := lcircle xscaled (2*RightMarginWidth) yscaled (1.5*RightMarginWidth) ; a := ulcorner chap_frame ; b := urcorner chap_frame ; pos := urcorner Field[Text][RightMarginSeparator] - ulcorner chap_frame - (-1mm,skip) ; fill chap_frame shifted pos withcolor "chap_frame" ; draw Chap rotated 90 shifted (xpart pos-4mm,ypart pos) ; StopPage ; \stopuseMPgraphic \defineoverlay[chapter-thumb][\useMPgraphic{chapter-thumb}] \startsectionblockenvironment[bodypart] \setupbackgrounds[rightpage][background=chapter-thumb] \stopsectionblockenvironment \showframe \starttext \startfrontmatter \startchapter[title=Test A] \samplefile{ward} \stopchapter \stopfrontmatter \startbodymatter \startchapter[title=Test C] \samplefile{ward} \stopchapter \stopbodymatter \stoptext % Global settings for all chapters \setuphead[chapter][style=\ssc] % Local settings for chapter in the bodymatter block \startsectionblockenvironment[bodypart] \setuphead[chapter][color=blue] \stopsectionblockenvironment \starttext \startfrontmatter \title{Table of content} \placecontent \stopfrontmatter \startbodymatter \chapter{Knuth} \input knuth \chapter{Zapf} \input zapf \stopbodymatter \stoptext \starttext a\texttilde b\lettertilde c\textasciitilde d \stoptext \definepageinjectionalternative [chapter:image] [renderingsetup=pageinjection:chapter:image] \startsetups [pageinjection:chapter:image] \centerbox{\externalfigure[\dummyparameter{name}]} \stopsetups \definepageinjection [chapter:start] [empty] [page=left] \definepageinjection [chapter:insert] [previouspage] [alternative=chapter:image, offset=1cm, pagestate=stop] \setuphead [chapter] [beforesection={\pageinjection[chapter:start]}, insidesection={\pageinjection[chapter:insert][name={chapter-\namedheadnumber{chapter}}]}] \setuppagenumbering [alternative=doublesided] \setupexternalfigures [location=default] \useexternalfigure [chapter-1] [mill] [factor=max] \useexternalfigure [chapter-2] [hacker] [orientation=90,scale=2000] \useexternalfigure [chapter-3] [cow][orientation=90,height=\framedwidth] \starttext \startchapter [title={Mill}] \dorecurse{7}{\samplefile{lorem}} \stopchapter \startchapter [title={Hacker}] \dorecurse{11}{\samplefile{lorem}} \stopchapter \startchapter [title={cow}] \dorecurse{7}{\samplefile{lorem}} \stopchapter \stoptext \setupbodyfont[termes] \starttext plays \m{\frac{2}{3} A}, \m{\frac{1}{3} D}. \stoptext \definefallbackfamily[story][serif][notoserif][range={greekandcoptic,greekextended},force=yes] \definefontfamily[story][serif][TeX Gyre Schola] \definefontfamily [story] [sans] [Latin Modern Sans] \definefontfamily [story] [mono] [Latin Modern Mono] [features=none] \definetypeface [story] [ss] [sans] [modern] [default] \definetypeface [story] [ss] [mono] [modern] [default] \definetypeface [story] [ss] [sans] [modern-designsize] [default] \definetypeface [story] [ss] [mono] [modern-designsize] [default] \definefontfamily[story][mm][TeX Gyre Pagella Math] \definetypeface [story] [mm] [math] [pagella] [default] \setupbodyfont[story,11pt] \usebodyfont[termes] \showframe \startsetups [blockquote:style] \switchtobodyfont[termes] \setupwhitespace[2pt] \stopsetups
Re: [NTG-context] Metafun, difficulty with graphical element in the margin
Hoi Wolfgang, I tested both variants (bodymatter and bodypart. The compilation runs through, however without the thumb-picture in the margin and the metafun error is in the log. Gruß! Willi > On 20 Mar 2022, at 17:00, Wolfgang Schuster via ntg-context > wrote: > > Willi Egger via ntg-context schrieb am 20.03.2022 um 16:53: >> Hoi Wolfgang! >> >> thank you for your suggestion. Your example indeed works. However if I apply >> this to my situation, which is >> >> \startsectionblockenvironment[bodymatter] > > You use the wrong name for the argument: > > \startsectionblockenvironment[bodypart] > > 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 : 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] Metafun, difficulty with graphical element in the margin
Willi Egger via ntg-context schrieb am 20.03.2022 um 16:53: Hoi Wolfgang! thank you for your suggestion. Your example indeed works. However if I apply this to my situation, which is \startsectionblockenvironment[bodymatter] You use the wrong name for the argument: \startsectionblockenvironment[bodypart] 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 : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun, difficulty with graphical element in the margin
Hoi Wolfgang! thank you for your suggestion. Your example indeed works. However if I apply this to my situation, which is \startsectionblockenvironment[bodymatter] \setups{Thumb-pictures} \stopsectionblockenvironment nothing happens. I.e. I get no error, but also no picture, indicating, that the \setups command is not executed.. Kind regards Willi > On 20 Mar 2022, at 11:28, Wolfgang Schuster via ntg-context > wrote: > > Willi Egger via ntg-context schrieb am 19.03.2022 um 21:42: >> Hello Otared, >> thanks so much for your testing and comments. — Tthe problem is, that this >> thumb-picture should only be placed in the \startboydmatter..\stopbodymatter >> sections. In the case of this book however there are the title pages and >> quite some text including the TOC in the >> \startfrontmatter..\stopfrontmatter. SO I end up with being forced to invoke >> the setups at the beginning of the bodymatter. > > Use sectionblockenvironment to set value which are only applied in the > frontmatter, bodymatter etc. > > begin example > % Global settings for all chapters > \setuphead[chapter][style=\ssc] > > % Local settings for chapter in the bodymatter block > \startsectionblockenvironment[bodypart] > \setuphead[chapter][color=blue] > \stopsectionblockenvironment > > \starttext > > \startfrontmatter > > \title{Table of content} > > \placecontent > > \stopfrontmatter > > \startbodymatter > > \chapter{Knuth} > > \input knuth > > \chapter{Zapf} > > \input zapf > > \stopbodymatter > > \stoptext > end example > > 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 : 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] Metafun, difficulty with graphical element in the margin
Hi Otared, thank you for your help. — I tried your approach aswel on my Mac as also on Linux. Unfortunately neither installation did give me a positive result. The error remains. Kind regards Willi > On 19 Mar 2022, at 23:39, Otared Kavian via ntg-context > wrote: > > Hi Willi, > > How about invoking the command \setups{Thumb-pictures} between a \start \stop > pair as in the following: > > \showframe > > \starttext > > \startfrontmatter > \startchapter[title=Test A] > \samplefile{knuth} > \stopchapter > > \stopfrontmatter > > %\page[yes] > > \start > \setups{Thumb-pictures} > > \startbodymatter > \startchapter[title=Test B] > \samplefile{ward} > \stopchapter > > \startchapter[title=Test C] > \samplefile{ward} > \stopchapter > > \startchapter[title=Test D] > \samplefile{ward} > \stopchapter > > > \stopbodymatter > \stop > > \startbackmatter > \dorecurse{5}{\startchapter[title=Test #1] > \samplefile{thuan} > \stopchapter} > > \stopbackmatter > > \stoptext > > >> On 19 Mar 2022, at 21:42, Willi Egger via ntg-context >> wrote: >> >> Hello Otared, >> >> thanks so much for your testing and comments. — Tthe problem is, that this >> thumb-picture should only be placed in the \startboydmatter..\stopbodymatter >> sections. In the case of this book however there are the title pages and >> quite some text including the TOC in the >> \startfrontmatter..\stopfrontmatter. SO I end up with being forced to invoke >> the setups at the beginning of the bodymatter. >> >> Thanks! >> Kind regards >> >> Willi >> >>> On 19 Mar 2022, at 16:52, Otared Kavian via ntg-context >>> wrote: >>> >>> Hi Willi, >>> >>> Your test file works fine if I place >>> \setups{Thumb-pictures} >>> before \starttext (using version 2022.03.12 17:56 LMTX). >>> However in the file you sent the choice of the command >>> \setups{Thumb-pictures} >>> is between chapter A and B, which seems starnge to me... >>> >>> Best regards: Otared K. >>> On 18 Mar 2022, at 20:29, Willi Egger via ntg-context wrote: Good evening! I have a dictionary where I would like to include thumb-pictures in the margin. — When I use the attached code with a single \startchapter...\stopchapter, it works. However if I add another \startchapter…\stopchapter before loading the setups for the thumb-picture metafun throws an error about not having complete information for performing a transformation. I am currently using the before last version of LMTX-ConTeXT (January 21st 2022). Could someone try to compile? Thanks, kind regards Willi___ 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 > ___ ___ If your question is of interest to others as well, please add an entry
Re: [NTG-context] Metafun, difficulty with graphical element in the margin
Willi Egger via ntg-context schrieb am 19.03.2022 um 21:42: Hello Otared, thanks so much for your testing and comments. — Tthe problem is, that this thumb-picture should only be placed in the \startboydmatter..\stopbodymatter sections. In the case of this book however there are the title pages and quite some text including the TOC in the \startfrontmatter..\stopfrontmatter. SO I end up with being forced to invoke the setups at the beginning of the bodymatter. Use sectionblockenvironment to set value which are only applied in the frontmatter, bodymatter etc. begin example % Global settings for all chapters \setuphead[chapter][style=\ssc] % Local settings for chapter in the bodymatter block \startsectionblockenvironment[bodypart] \setuphead[chapter][color=blue] \stopsectionblockenvironment \starttext \startfrontmatter \title{Table of content} \placecontent \stopfrontmatter \startbodymatter \chapter{Knuth} \input knuth \chapter{Zapf} \input zapf \stopbodymatter \stoptext end example 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 : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] Metafun, difficulty with graphical element in the margin
Hi Willi, How about invoking the command \setups{Thumb-pictures} between a \start \stop pair as in the following: \showframe \starttext \startfrontmatter \startchapter[title=Test A] \samplefile{knuth} \stopchapter \stopfrontmatter %\page[yes] \start \setups{Thumb-pictures} \startbodymatter \startchapter[title=Test B] \samplefile{ward} \stopchapter \startchapter[title=Test C] \samplefile{ward} \stopchapter \startchapter[title=Test D] \samplefile{ward} \stopchapter \stopbodymatter \stop \startbackmatter \dorecurse{5}{\startchapter[title=Test #1] \samplefile{thuan} \stopchapter} \stopbackmatter \stoptext > On 19 Mar 2022, at 21:42, Willi Egger via ntg-context > wrote: > > Hello Otared, > > thanks so much for your testing and comments. — Tthe problem is, that this > thumb-picture should only be placed in the \startboydmatter..\stopbodymatter > sections. In the case of this book however there are the title pages and > quite some text including the TOC in the \startfrontmatter..\stopfrontmatter. > SO I end up with being forced to invoke the setups at the beginning of the > bodymatter. > > Thanks! > Kind regards > > Willi > >> On 19 Mar 2022, at 16:52, Otared Kavian via ntg-context >> wrote: >> >> Hi Willi, >> >> Your test file works fine if I place >> \setups{Thumb-pictures} >> before \starttext (using version 2022.03.12 17:56 LMTX). >> However in the file you sent the choice of the command >> \setups{Thumb-pictures} >> is between chapter A and B, which seems starnge to me... >> >> Best regards: Otared K. >> >>> On 18 Mar 2022, at 20:29, Willi Egger via ntg-context >>> wrote: >>> >>> Good evening! >>> >>> I have a dictionary where I would like to include thumb-pictures in the >>> margin. — When I use the attached code with a single >>> \startchapter...\stopchapter, it works. However if I add another >>> \startchapter…\stopchapter before loading the setups for the thumb-picture >>> metafun throws an error about not having complete information for >>> performing a transformation. >>> >>> I am currently using the before last version of LMTX-ConTeXT (January 21st >>> 2022). >>> >>> Could someone try to compile? >>> >>> Thanks, kind regards >>> >>> Willi___ >>> 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 ___
[NTG-context] Metafun, difficulty with graphical element in the margin, again.
Hello, I am a little desperate… I have installed in a new directory the latest version of ConTeXt. I run the sample file I provided before. After enabling a second chapter-section before the \setups{Thumb-picture} the metafun error reoccurs. — Looking at the log I do net get really wiser, lacking the background of the implementation… So here follows the section of the log with the error: metafun > log > metafun > log > error: Transform components aren't all known metafun > log > metapost> trace > (0,0,mfun_page_hsize[-4],0,0,1) metapost> trace > yscaled metapost> trace > mfun_page_field [ (EXPR 0) ] [ (-40) ] := unitsquare xscaled mfun_page_hsize [ (EXPR 0) ] yscaled mfun_page_vsize [ (-40) ] shifted ( mfun_page_hstep [ (EXPR 0) ] , mfun_page_vstep [ (-40) ] ) ; mfun_page_field [ (-40) ] [ (EXPR 0) ] := mfun_page_field [ (EXPR 0) ] [ (-40) ] ; ENDFOR metapost> trace > for HorPos = LeftEdge step 1 until RightEdge : mfun_page_field [ HorPos ] [ (EXPR 0) ] := unitsquare xscaled mfun_page_hsize [ HorPos ] yscaled mfun_page_vsize [ (EXPR 0) ] shifted ( mfun_page_hstep [ HorPos ] , mfun_page_vstep [ (EXPR 0) ] ) ; mfun_page_field [ (EXPR 0) ] [ HorPos ] := mfun_page_field [ HorPos ] [ (EXPR 0) ] ; endfor ; ENDFOR metapost> trace > mfun_check_page_field -> -> mfun_check_page_dimensions;for.VerPos=Top.step10until.Bottom:for.HorPos=LeftEdge.step1until.RightEdge:mfun_page_field[HorPos][VerPos]:=unitsquare.xscaled.mfun_page_hsize[HorPos]yscaled.mfun_page_vsize[VerPos]shifted(mfun_page_hstep[HorPos],mfun_page_vstep[VerPos]);mfun_page_field[VerPos][HorPos]:=mfun_page_field[HorPos][VerPos];endfor;endfor; metapost> trace > mfun_check_page_field ; metapost> trace > hide -> (TEXT0)-> exitif.numeric.begingroup(TEXT0);endgroup; metapost> trace > Field -> -> hide(mfun_check_page_field;)mfun_page_field metafun > log > metafun > log > I'm unable to apply a partially specified transformation except to a fully known pair or transform. Proceed, and I'll omit the transformation. metafun > log > How to interprete, wha tto try next? Kind regards Willi ___ 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, difficulty with graphical element in the margin
Hello Otared, thanks so much for your testing and comments. — Tthe problem is, that this thumb-picture should only be placed in the \startboydmatter..\stopbodymatter sections. In the case of this book however there are the title pages and quite some text including the TOC in the \startfrontmatter..\stopfrontmatter. SO I end up with being forced to invoke the setups at the beginning of the bodymatter. Thanks! Kind regards Willi > On 19 Mar 2022, at 16:52, Otared Kavian via ntg-context > wrote: > > Hi Willi, > > Your test file works fine if I place > \setups{Thumb-pictures} > before \starttext (using version 2022.03.12 17:56 LMTX). > However in the file you sent the choice of the command > \setups{Thumb-pictures} > is between chapter A and B, which seems starnge to me... > > Best regards: Otared K. > >> On 18 Mar 2022, at 20:29, Willi Egger via ntg-context >> wrote: >> >> Good evening! >> >> I have a dictionary where I would like to include thumb-pictures in the >> margin. — When I use the attached code with a single >> \startchapter...\stopchapter, it works. However if I add another >> \startchapter…\stopchapter before loading the setups for the thumb-picture >> metafun throws an error about not having complete information for performing >> a transformation. >> >> I am currently using the before last version of LMTX-ConTeXT (January 21st >> 2022). >> >> Could someone try to compile? >> >> Thanks, kind regards >> >> Willi___ >> 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] Metafun, difficulty with graphical element in the margin
Hi Willi, Your test file works fine if I place \setups{Thumb-pictures} before \starttext (using version 2022.03.12 17:56 LMTX). However in the file you sent the choice of the command \setups{Thumb-pictures} is between chapter A and B, which seems starnge to me... Best regards: Otared K. > On 18 Mar 2022, at 20:29, Willi Egger via ntg-context > wrote: > > Good evening! > > I have a dictionary where I would like to include thumb-pictures in the > margin. — When I use the attached code with a single > \startchapter...\stopchapter, it works. However if I add another > \startchapter…\stopchapter before loading the setups for the thumb-picture > metafun throws an error about not having complete information for performing > a transformation. > > I am currently using the before last version of LMTX-ConTeXT (January 21st > 2022). > > Could someone try to compile? > > Thanks, kind regards > > Willi___ > 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] Metafun, difficulty with graphical element in the margin
On 3/18/2022 8:29 PM, Willi Egger via ntg-context wrote: Good evening! I have a dictionary where I would like to include thumb-pictures in the margin. — When I use the attached code with a single \startchapter...\stopchapter, it works. However if I add another \startchapter…\stopchapter before loading the setups for the thumb-picture metafun throws an error about not having complete information for performing a transformation. I am currently using the before last version of LMTX-ConTeXT (January 21st 2022). Could someone try to compile? works here (with the latest) 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] Metafun, difficulty with graphical element in the margin
On Saturday, March 19, 2022 12:59 AM Willi Egger via ntg-context wrote: > Could someone try to compile? I have compiled your test file with both the below versions : • mtx-context | current version: 2022.01.21 20:13 • mtx-context | current version: 2022.03.12 17:56 In both cases, no errors were emitted by MetaFun; the output also seems to be as expected (thumb pictures progressively moving downward with every chapter). 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] Metafun, difficulty with graphical element in the margin
Good evening! I have a dictionary where I would like to include thumb-pictures in the margin. — When I use the attached code with a single \startchapter...\stopchapter, it works. However if I add another \startchapter…\stopchapter before loading the setups for the thumb-picture metafun throws an error about not having complete information for performing a transformation. I am currently using the before last version of LMTX-ConTeXT (January 21st 2022). Could someone try to compile? Thanks, kind regards Willi test-thumb-picture.tex Description: Binary data test-thumb-picture.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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
[NTG-context] MetaFun: textext.origin, thelabel.origin not positioned on baseline
Hello again List, Now I’m making diagrams using MetaFun. The MetaFun manual describes an “origin” option for positioning textext’s and label’s on the baseline. However, this dose not appear to be happening with the code in the manual (below). In fact, the diagram in the manual dose not show the textext’s and label’s on the baseline. This is on page 144 of metafun-p.pdf. Maybe I misunderstand what is supposed to be happening here. Thanks! Gavin \startMPcode picture p ; p := \MPbetex {1} ; picture q ; q := textext.origin( \MPstring{2}) ; picture r ; r := thelabel.origin("\MPtext {3}",origin) ; for i=p, boundingbox p : draw i withcolor .625red; endfor ; for i=q, boundingbox q : draw i withcolor .625yellow ; endfor ; for i=r, boundingbox r : draw i withcolor .625white ; endfor ; currentpicture := currentpicture scaled 2 ; draw origin withpen pencircle scaled 5.0mm withcolor white ; draw origin withpen pencircle scaled 2.5mm withcolor black ; draw boundingbox currentpicture withpen pencircle scaled .1mm dashed evenly ; \stopMPcode ___ 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] Trying to understand outlinetext, 'stretch' effect and \kerncharacters
On Saturday, January 1, 2022 3:45:36 PM IST Hans Hagen wrote: > \starteffect is kind of old (comes from mkii), but you could use the > pseudo font feature effect in mkiv / lmtx which then makes a real font > instance instead of mixing in some pdf magic Thanks for the explanations Hans! Happy new year wishes to you! kauśika ___ 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] Trying to understand outlinetext, 'stretch' effect and \kerncharacters
On 12/31/2021 3:13 AM, kauśika via ntg-context wrote: Dear list, I have the following graphic \startuseMPgraphic{TitleGraphic} draw outlinetext.b (\MPstring{TitleText}) (withcolor "titlefg") (withcolor "titleoutline"); \stopuseMPgraphic which I tried to use as follows to produce a stylized 'title' head: \setupMPtext{TitleText}{% \starteffect[stretch]\bfc\namedstructurevariable{title}{title}\stopeffect} \useMPgraphic{TitleGraphic} low level pdf magic ... so not done in mp [colors "titlefg" and "titleoutline" are set using \definecolor] But, the 'stretch' effect caused by \starteffect[stretch]…\stopeffect does not work with 'outlinetext' method in the MPgraphic. I have verified that the desired effect is produced using 'textext' method instead. But in that case I have to cheat (i.e draw twice; once with blownup) to get the text outline. Now, if I write instead \setupMPtext{TitleText}{% \kerncharacters[0.15]\bfc\namedstructurevariable{title}{title}} \useMPgraphic{TitleGraphic} tex magic so done in tex then the desired effect is produced. As such, my purpose is served well by using \kerncharacters. Nonetheless, I request your kind help in understanding why this is happening and/or if I am doing something wrong. \starteffect is kind of old (comes from mkii), but you could use the pseudo font feature effect in mkiv / lmtx which then makes a real font instance instead of mixing in some pdf magic 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] [MetaFun] Trying to understand outlinetext, 'stretch' effect and \kerncharacters
On Friday, December 31, 2021 7:43:21 AM IST kauśika wrote: > Dear list, > > I have the following graphic > > \startuseMPgraphic{TitleGraphic} > draw outlinetext.b (\MPstring{TitleText}) > (withcolor "titlefg") > (withcolor "titleoutline"); > \stopuseMPgraphic > > which I tried to use as follows to produce a stylized 'title' head: > > \setupMPtext{TitleText}{% > \starteffect[stretch]\bfc\namedstructurevariable{title}{title}\stopeffect} > \useMPgraphic{TitleGraphic} > > [colors "titlefg" and "titleoutline" are set using \definecolor] > > But, the 'stretch' effect caused by \starteffect[stretch]…\stopeffect does > not work with 'outlinetext' method in the MPgraphic. I have verified that > the desired effect is produced using 'textext' method instead. But in that > case I have to cheat (i.e draw twice; once with blownup) to get the text > outline. > > Now, if I write instead > > \setupMPtext{TitleText}{% > \kerncharacters[0.15]\bfc\namedstructurevariable{title}{title}} > \useMPgraphic{TitleGraphic} > > then the desired effect is produced. As such, my purpose is served well by > using \kerncharacters. > > Nonetheless, I request your kind help in understanding why this is happening > and/or if I am doing something wrong. > > Thanks, > kauśika Please read '\setupMPtext' as '\setMPtext' in the above. Apologies for the typos. kauśika ___ 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] Trying to understand outlinetext, 'stretch' effect and \kerncharacters
Dear list, I have the following graphic \startuseMPgraphic{TitleGraphic} draw outlinetext.b (\MPstring{TitleText}) (withcolor "titlefg") (withcolor "titleoutline"); \stopuseMPgraphic which I tried to use as follows to produce a stylized 'title' head: \setupMPtext{TitleText}{% \starteffect[stretch]\bfc\namedstructurevariable{title}{title}\stopeffect} \useMPgraphic{TitleGraphic} [colors "titlefg" and "titleoutline" are set using \definecolor] But, the 'stretch' effect caused by \starteffect[stretch]…\stopeffect does not work with 'outlinetext' method in the MPgraphic. I have verified that the desired effect is produced using 'textext' method instead. But in that case I have to cheat (i.e draw twice; once with blownup) to get the text outline. Now, if I write instead \setupMPtext{TitleText}{% \kerncharacters[0.15]\bfc\namedstructurevariable{title}{title}} \useMPgraphic{TitleGraphic} then the desired effect is produced. As such, my purpose is served well by using \kerncharacters. Nonetheless, I request your kind help in understanding why this is happening and/or if I am doing something wrong. Thanks, kauśika ___ 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: circular arc
In the example the text is drawn as: draw followtext(q, "\strut TEXT ONE") it looks as if the \strut generates a space before the text. e.g. if you omit the \strut, the text will align at the start point. In my perception, the \strut is a zero width box, so it should not generate the space before. But I might be wrong here (most likely ;-) .F On 05/10/2021 23:32, Thomas A. Schmitz via ntg-context wrote: \startuseMPgraphic{empedocless} path p, q, r ; pair a ; p := fullcircle scaled 10cm ; drawarrow p withpen pencircle scaled 1mm withcolor red ; draw point 0 of p withpen pencircle scaled 1mm withcolor blue ; q := p cutafter (point .4 along p) ; drawarrow q withpen pencircle scaled .5mm withcolor green ; draw followtext(q, "\strut TEXT ONE") ; p := fullcircle scaled 8cm ; drawarrow p withpen pencircle scaled 1mm withcolor cyan ; draw point 0 of p withpen pencircle scaled 1mm withcolor magenta ; q := p cutafter (point .3 along p) ; q := q rotated 120 ; drawarrow q withpen pencircle scaled .5mm withcolor yellow ; draw followtext(q, "\strut TEXT TWO") ; % the real deal: best make a macro for this p := fullcircle scaled 6cm ; draw point 0 of p withpen pencircle scaled 5mm withcolor blue ; drawarrow p withpen pencircle scaled 1mm withcolor red ; a := (point eps of p) rotated 45 ; draw a withpen pencircle scaled 2mm; q := p cutafter a ; q := q rotated 20 ; drawarrow q withpen pencircle scaled .5mm withcolor green ; draw followtext(q, "\strut TEXT TWO") ; \stopuseMPgraphic \useMPgraphic{empedocless} ___ 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: circular arc
Thank you so much, Hans, that's a neat solution! I was banging my head against the wall, but this makes sense. On 10/5/21 6:38 PM, Hans Hagen wrote: Because you know how to rotate and scale: \startuseMPgraphic{empedocless} path p, q, r ; pair a ; p := fullcircle scaled 10cm ; drawarrow p withpen pencircle scaled 1mm withcolor red ; draw point 0 of p withpen pencircle scaled 1mm withcolor blue ; q := p cutafter (point .4 along p) ; drawarrow q withpen pencircle scaled .5mm withcolor green ; draw followtext(q, "\strut TEXT ONE") ; p := fullcircle scaled 8cm ; drawarrow p withpen pencircle scaled 1mm withcolor cyan ; draw point 0 of p withpen pencircle scaled 1mm withcolor magenta ; q := p cutafter (point .3 along p) ; q := q rotated 120 ; drawarrow q withpen pencircle scaled .5mm withcolor yellow ; draw followtext(q, "\strut TEXT TWO") ; % the real deal: best make a macro for this p := fullcircle scaled 6cm ; draw point 0 of p withpen pencircle scaled 5mm withcolor blue ; drawarrow p withpen pencircle scaled 1mm withcolor red ; a := (point eps of p) rotated 45 ; draw a withpen pencircle scaled 2mm; q := p cutafter a ; q := q rotated 20 ; drawarrow q withpen pencircle scaled .5mm withcolor green ; draw followtext(q, "\strut TEXT TWO") ; \stopuseMPgraphic \useMPgraphic{empedocless} So, just always start at point 0 and then just rotate the cutof piece over the angle that you want. The eps in the last case makes that we actually have a cut off piece (zero fails here). So ... solution 4. best suits non math gurus (like you and me). This is the part of your reply that fails to convince. You don't even know how bad I am at math... Thanks, and all best Thomas ___ 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: circular arc
On 10/5/2021 4:58 PM, Thomas A. Schmitz via ntg-context wrote: Hi all, I hope the following example is not too convoluted: \useMPlibrary [txt] \define\EmpArrow{\getscaledglyph{1.6}{name:dejavumath}{\char"2B05}} \setupbodyfont [ss,9pt] \starttext \startuseMPgraphic{empedocles} %numeric a ; a = 6.56cm ; %numeric b ; b = 1.1 ; save S; path S[] ; S[1] = fullcircle scaled 8cm rotated 306 ; S[2] = S[1] scaled 1.1 ; S[3] = S[1] scaled 1.23 ; S[4] = S[1] scaled 1.3 ; S[5] = S[1] scaled 1.43 ; S[6] = S[1] scaled 1.5 ; S[7] = S[1] scaled 1.6 ; z[1] = point 1 along S[7] ; z[2] = point 1 along S[1] ; z[3] = point 0.1 along S[7] ; z[4] = point 0.1 along S[1] ; z[5] = point 0.2 along S[7] ; z[6] = point 0.2 along S[1] ; z[7] = point 0.3 along S[7] ; z[8] = point 0.3 along S[1] ; z[9] = point 0.4 along S[7] ; z[10] = point 0.4 along S[1] ; z[11] = point 0.5 along S[7] ; z[12] = point 0.5 along S[1] ; z[13] = point 0.6 along S[7] ; z[14] = point 0.6 along S[1] ; z[15] = point 0.7 along S[7] ; z[16] = point 0.7 along S[1] ; z[17] = point 0.8 along S[7] ; z[18] = point 0.8 along S[1] ; S[8] = z[1] -- z[2] ; S[9] = z[3] -- z[4] ; S[10] = z[5] -- z[6] ; S[11] = z[7] -- z[8] ; S[12] = z[9] -- z[10] ; S[13] = z[11] -- z[12] ; S[14] = z[13] -- z[14] ; S[15] = z[15] -- z[16] ; S[16] = z[17] -- z[18] ; z[19] = S[3] intersection_point S[8] ; z[20] = S[3] intersection_point S[16] ; S[18] = S[3] cutbefore z[20] cutafter z[19] ; z[21] = S[5] intersection_point S[8] ; z[22] = S[5] intersection_point S[16] ; S[19] = S[5] cutbefore z[22] cutafter z[21] ; z[23] = S[12] intersection_point S[3] ; S[20] = S[3] cutbefore z[20] cutafter z[23] ; for i = 1 upto 16: draw S[i] withcolor 0.7white ; endfor ; draw z[23] -- z[20] withcolor red ; draw S[20] withcolor blue ; label.bot(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 20.000 = 0}"), z[10]) ; label.llft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 2.000}"), z[8]) ; label.lft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 4.000}"), z[6]) ; label.lft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 6.000}"), z[4]) ; label.ulft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 8.000}"), z[2]) ; label.urt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 12.000}"), z[18]) ; label.rt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 14.000}"), z[16]) ; label.rt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 16.000}"), z[14]) ; label.lrt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 18.000}"), z[12]) ; draw followtext(S[18], "\strut\hbox to 2em{\EmpArrow}\hskip2em RUHEPAUSE\hskip4em\strut") ; draw followtext(S[19], "\strut\hbox to 2em{\EmpArrow}EINHEIT (SPHAIROS)\hskip2em\strut") ; \stopuseMPgraphic \useMPgraphic{empedocles} \stoptext I have a big problem and some smaller questions, for those who are better at math and at metafun than I am: 1. The big problem: for the next followtext, I need the circular arc between points z[23] and z[20]. But however I place the cutbefore and cutafter, I don't get the proper part of the circle. I'm looking at the right intersection points, as the red line shows, but the blue line shows that I'm not getting the right section of the circle. How can I get this section into the path S[20]? 2. Math... :-) Is there a better way to define three circles that are at exactly the same distance than my naive "scaled 1.3" and "scaled 1.5"? 3. TeX and metafun: is there a better way to have the followtext exactly centered between the two circles rather than just fiddle with the scale factor? 4. Or is there a better approach to my problem altogether? I'm trying to reproduce an illustration from a book, so I'm very open to suggestions here. I looked at the example in the metafun manual chapter 10.4, but I'm not sure if using an overlay and multiple \followtokens would be easier. Especially since there is the scary remark "This definition is not the right one!" in this chapter without any further explanation. I hope you all had a wonderful meeting last week. I was sad I couldn't come, I was in Paris for a conference, the first after 18 months, so I couldn't skip this one. Because you know how to rotate and scale: \startuseMPgraphic{empedocless} path p, q, r ; pair a ; p := fullcircle scaled 10cm ; drawarrow p withpen pencircle scaled 1mm withcolor red ; drawpoint 0 of p withpen pencircle scaled 1mm withcolor blue ; q := p cutafter (point .4 along p) ; drawarrow q withpen pencircle scaled .5mm withcolor green ; draw followtext(q, "\strut TEXT ONE") ; p := fullcircle scaled 8cm ; drawarrow p withpen pencircle scaled 1mm withcolor cyan ; drawpoint 0 of p withpen pencircle scaled 1mm withcolor magenta ; q := p cutafter (point .3 along p) ; q := q rotated 120 ; drawarrow q withpen pencircle scaled .5mm withcolor yellow ; draw followtext(q,
[NTG-context] metafun: circular arc
Hi all, I hope the following example is not too convoluted: \useMPlibrary [txt] \define\EmpArrow{\getscaledglyph{1.6}{name:dejavumath}{\char"2B05}} \setupbodyfont [ss,9pt] \starttext \startuseMPgraphic{empedocles} %numeric a ; a = 6.56cm ; %numeric b ; b = 1.1 ; save S; path S[] ; S[1] = fullcircle scaled 8cm rotated 306 ; S[2] = S[1] scaled 1.1 ; S[3] = S[1] scaled 1.23 ; S[4] = S[1] scaled 1.3 ; S[5] = S[1] scaled 1.43 ; S[6] = S[1] scaled 1.5 ; S[7] = S[1] scaled 1.6 ; z[1] = point 1 along S[7] ; z[2] = point 1 along S[1] ; z[3] = point 0.1 along S[7] ; z[4] = point 0.1 along S[1] ; z[5] = point 0.2 along S[7] ; z[6] = point 0.2 along S[1] ; z[7] = point 0.3 along S[7] ; z[8] = point 0.3 along S[1] ; z[9] = point 0.4 along S[7] ; z[10] = point 0.4 along S[1] ; z[11] = point 0.5 along S[7] ; z[12] = point 0.5 along S[1] ; z[13] = point 0.6 along S[7] ; z[14] = point 0.6 along S[1] ; z[15] = point 0.7 along S[7] ; z[16] = point 0.7 along S[1] ; z[17] = point 0.8 along S[7] ; z[18] = point 0.8 along S[1] ; S[8] = z[1] -- z[2] ; S[9] = z[3] -- z[4] ; S[10] = z[5] -- z[6] ; S[11] = z[7] -- z[8] ; S[12] = z[9] -- z[10] ; S[13] = z[11] -- z[12] ; S[14] = z[13] -- z[14] ; S[15] = z[15] -- z[16] ; S[16] = z[17] -- z[18] ; z[19] = S[3] intersection_point S[8] ; z[20] = S[3] intersection_point S[16] ; S[18] = S[3] cutbefore z[20] cutafter z[19] ; z[21] = S[5] intersection_point S[8] ; z[22] = S[5] intersection_point S[16] ; S[19] = S[5] cutbefore z[22] cutafter z[21] ; z[23] = S[12] intersection_point S[3] ; S[20] = S[3] cutbefore z[20] cutafter z[23] ; for i = 1 upto 16: draw S[i] withcolor 0.7white ; endfor ; draw z[23] -- z[20] withcolor red ; draw S[20] withcolor blue ; label.bot(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 20.000 = 0}"), z[10]) ; label.llft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 2.000}"), z[8]) ; label.lft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 4.000}"), z[6]) ; label.lft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 6.000}"), z[4]) ; label.ulft(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 8.000}"), z[2]) ; label.urt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 12.000}"), z[18]) ; label.rt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 14.000}"), z[16]) ; label.rt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 16.000}"), z[14]) ; label.lrt(textext("\noexpand\framed[align=middle,frame=off]{Jahr \crlf 18.000}"), z[12]) ; draw followtext(S[18], "\strut\hbox to 2em{\EmpArrow}\hskip2em RUHEPAUSE\hskip4em\strut") ; draw followtext(S[19], "\strut\hbox to 2em{\EmpArrow}EINHEIT (SPHAIROS)\hskip2em\strut") ; \stopuseMPgraphic \useMPgraphic{empedocles} \stoptext I have a big problem and some smaller questions, for those who are better at math and at metafun than I am: 1. The big problem: for the next followtext, I need the circular arc between points z[23] and z[20]. But however I place the cutbefore and cutafter, I don't get the proper part of the circle. I'm looking at the right intersection points, as the red line shows, but the blue line shows that I'm not getting the right section of the circle. How can I get this section into the path S[20]? 2. Math... :-) Is there a better way to define three circles that are at exactly the same distance than my naive "scaled 1.3" and "scaled 1.5"? 3. TeX and metafun: is there a better way to have the followtext exactly centered between the two circles rather than just fiddle with the scale factor? 4. Or is there a better approach to my problem altogether? I'm trying to reproduce an illustration from a book, so I'm very open to suggestions here. I looked at the example in the metafun manual chapter 10.4, but I'm not sure if using an overlay and multiple \followtokens would be easier. Especially since there is the scary remark "This definition is not the right one!" in this chapter without any further explanation. I hope you all had a wonderful meeting last week. I was sad I couldn't come, I was in Paris for a conference, the first after 18 months, so I couldn't skip this one. Thanks and best wishes Thomas ___ 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 : textext.dflt / textext.dlft and MkIV / LMTX
Hi, After https://mailman.ntg.nl/pipermail/ntg-context/2021/102052.html It seems that there is no backward compatibility between MkIV and LMTX for textext.dflt (MVE below) | MkIV | LMTX | -|---|--| textext.dflt | OK | KO | as DefauLT (unlike ulft and llft) textext.dlft | KO | OK | as Default + LeFT (like ulft and llft) For backward compatibility, would it be possible to add textext.dflt to LMTX as a synonym of textext.dlft ? % \startuseMPgraphic{MonGraphique} StartPage ; picture Pict ; % Pict := textext.dlft("Brouillon DLFT") xsized (.5PaperWidth); % OK with LMTX 2021.09.03 18:49 % KO with MkIV 2020.03.10 14:44 Pict := textext.dflt("Brouillon DFLT") xsized (.5PaperWidth); % KO with LMTX 2021.09.03 18:49 % OK with MkIV 2020.03.10 14:44 Pict := Pict shifted (bbwidth Pict /2 , (bbheight Pict / -2) ) ; Pict := Pict rotated 45; Pict := Pict shifted (.5PaperWidth, .5PaperHeight) ; draw Pict withcolor darkyellow ; StopPage ; \stopuseMPgraphic %- \defineoverlay[MonOverlay][\useMPgraphic{MonGraphique}] \setupbackgrounds[page][background=MonOverlay] \starttext \input knuth \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] metafun doesn't compile \root 3 \of 2
On 9/3/2021 11:48 AM, fv leung via ntg-context wrote: \starttext \m{\root3\of2} \stoptext works. But \starttext \startMPcode label("\m{\root3\of2}", origin); \stopMPcode \stoptext doesn't. draw thetextext("\m{\root3\of2}",origin); labels are done in the default (normally monospace) font - 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] metafun doesn't compile \root 3 \of 2
\starttext \m{\root3\of2} \stoptext works. But \starttext \startMPcode label("\m{\root3\of2}", origin); \stopMPcode \stoptext doesn't. Running `LuaMetaTeX' on `trial' with ``/home/fvleung/ConTeXt/tex/texmf-linux-64/bin/mtxrun --autogenerate --script context trial.tex'' resolvers | formats | executing runner 'run luametatex format': /home/fvleung/ConTeXt/tex/texmf-linux-64/bin/luametatex --jobname="trial" --fmt=/home/fvleung/ConTeXt/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.fmt --lua=/home/fvleung/ConTeXt/tex/texmf-cache/luatex-cache/context/5fe67e0bfe781ce0dde776fb1556f32e/formats/luametatex/cont-en.lui cont-yes.mkiv --c:currentrun=1 --c:fulljobname="./trial.tex" --c:input="./trial.tex" --c:kindofrun=1 --c:maxnofruns=9 --c:texmfbinpath="/home/fvleung/ConTeXt/tex/texmf-linux-64/bin" open source > level 1, order 1, name 'cont-yes.mkiv' fonts > beware: no fonts are loaded yet, using 'lm mono' in box system > system > ConTeXt ver: 2021.07.27 19:27 LMTX fmt: 2021.7.28 int: english/english system > system > 'cont-new.mkxl' loaded open source > level 2, order 2, name '/home/fvleung/ConTeXt/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl' system > beware: some patches loaded from cont-new.mkiv close source> level 2, order 2, name '/home/fvleung/ConTeXt/tex/texmf-context/tex/context/base/mkxl/cont-new.mkxl' system > files > jobname './trial', input './trial.tex', result './trial' fonts > latin modern fonts are not preloaded languages > language 'en' is active open source > level 2, order 3, name './trial.tex' fonts > preloading latin modern fonts (second stage) fonts > 'fallback modern-designsize rm 12pt' is loaded metapost> initializing instance 'metafun:1' using format 'metafun' and method 'default' metapost> loading 'metafun' as 'metafun.mpxl' using method 'default' metapost> initializing number mode 'scaled' metapost> trace > This is MPLIB for LuaMetaTeX, version 3.11, running in scaled mode. metapost> trace > metapost> trace > loading metafun for lmtx, including the plain 1.004 base definitions metapost> trace > tex error > tex error on line 7 in file ./trial.tex: Argument of \root has an extra } 32\normalstopimath \fi \par } } \global \setbox \mptextbox \hbox {\clf_mptexttoks } [[special cmd: end local call]] \relax ... \stopMPcode 1 \starttext 2 3 \startMPcode 4 label("\m{\root3\of2}", origin); 5 \stopMPcode 6 7 >> \stoptext 8 I've run across a '}' that doesn't seem to match anything. For example, '\def\a#1{...}' and '\a}' would produce this error. The '\par' that I've just inserted will cause me to report a runaway argument that might be the root of the problem. mtx-context | fatal error: return code: 256 TeX Output exited abnormally with code 1 at Fri Sep 3 17:44:19 ___ 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 transformation error
Hi, > here a ; is missing after the q That was a silly mistake while making the MWE. When I corrected it, the MWE compiled correctly. However, the original code didn't have that error and wouldn't compile. So, I tried another MWE and found out what was causing the error. In the array I defined, there were two elements with empty string as their value. Once I changed those empty strings to some valid string, there was no error and the file compiled as expected. Here is the new MWE with one array element defined as empty string \starttext \switchtobodyfont[30pt] \startMPpage StartPage ; unit := 2 * cm ; %numeric lm, row, col, bm; pair middle; row := 1; col := 1; picture p, q ; p := nullpicture; q := nullpicture; string l[], lbl; l[0] := "" ; l[1]:= "2"; for i= 0 upto row: middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) ))]; lbl := l[i]; p := thelabel(lbl, middle); q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); draw q; endfor StopPage ; \stopMPpage \stoptext This will throw an error. If l[0] is defined as, say, "hi", there is no error I suppose, my work around would be to use a non empty string and then fill that cell dark. Is there another way? Anyway, thanks for your prompt replies and patience. Thanks a ton for sharing your efforts with the world ajith \starttext \switchtobodyfont[30pt] \startMPpage StartPage ; unit := 2 * cm ; %numeric lm, row, col, bm; pair middle; row := 1; col := 1; picture p, q ; p := nullpicture; q := nullpicture; string l[], lbl; l[0] := "" ; l[1]:= "2"; for i= 0 upto row: middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) ))]; lbl := l[i]; p := thelabel(lbl, middle); q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); draw q; endfor StopPage ; \stopMPpage \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] metafun transformation error
On 6/4/2021 5:08 PM, Ajith R wrote: Hi, here a ; is missing after the q That was a silly mistake while making the MWE. When I corrected it, the MWE compiled correctly. However, the original code didn't have that error and wouldn't compile. So, I tried another MWE and found out what was causing the error. In the array I defined, there were two elements with empty string as their value. Once I changed those empty strings to some valid string, there was no error and the file compiled as expected. Here is the new MWE with one array element defined as empty string \starttext \switchtobodyfont[30pt] \startMPpage StartPage ; unit := 2 * cm ; %numeric lm, row, col, bm; pair middle; row := 1; col := 1; picture p, q ; p := nullpicture; q := nullpicture; string l[], lbl; l[0] := "" ; l[1]:= "2"; for i= 0 upto row: middle := 0.5[((( i * unit) ), ((2 * unit))), i+1) * unit) ), ((2 * unit) ))]; lbl := l[i]; p := thelabel(lbl, middle); q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); draw q; endfor StopPage ; \stopMPpage \stoptext This will throw an error. If l[0] is defined as, say, "hi", there is no error I suppose, my work around would be to use a non empty string and then fill that cell dark. Is there another way? Anyway, thanks for your prompt replies and patience. Thanks a ton for sharing your efforts with the world you canot reflect about zero dimensions: p := thetextext(lbl, middle); message(0.5[urcorner p, ulcorner p]); if llcorner p <> urcorner p : q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); draw q; fi - 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] metafun transformation error
Hi, > In order answer that you have to make a MWE that we can run without the > need to edit a file. > Hans Sorry for having assumed that sharing the code was sufficient as MWE. Here is the trimmed version that still throws the error \startMPpage StartPage ; numeric row, col, unit; pair middle; row := 1; col := 1; unit := 2 * cm ; picture p, q ; p := nullpicture; q := nullpicture; string l[]; l[0] := "2" ; l[1] := " 4"; for i= 0 upto row : middle := (i * unit, 5cm); p := thelabel( l[i], middle); draw p; %q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); %draw q endfor StopPage ; \stopMPpage \stoptext The file is also attached. As I told earlier, an error is thrown if I uncomment the line that assigns q and then draws it. Thanks for your help, ajith \startMPpage StartPage ; numeric row, col, unit; pair middle; row := 1; col := 1; unit := 2 * cm ; picture p, q ; p := nullpicture; q := nullpicture; string l[]; l[0] := "2" ; l[1] := " 4"; for i= 0 upto row : middle := (i * unit, 5cm); p := thelabel( l[i], middle); draw p; %q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); %draw q endfor StopPage ; \stopMPpage \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] metafun transformation error
On 6/4/2021 1:25 PM, Ajith R wrote: Hi, In order answer that you have to make a MWE that we can run without the need to edit a file. Hans Sorry for having assumed that sharing the code was sufficient as MWE. Here is the trimmed version that still throws the error \startMPpage StartPage ; numeric row, col, unit; pair middle; row := 1; col := 1; unit := 2 * cm ; picture p, q ; p := nullpicture; q := nullpicture; string l[]; l[0] := "2" ; l[1] := " 4"; for i= 0 upto row : middle := (i * unit, 5cm); p := thelabel( l[i], middle); draw p; %q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); %draw q here a ; is missing after the q endfor StopPage ; \stopMPpage \stoptext The file is also attached. As I told earlier, an error is thrown if I uncomment the line that assigns q and then draws it. Thanks for your help, ajith ___ 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 ___ -- - 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] metafun transformation error
Hi all, I am new to context and need help in solving an error. I am trying to print some numbers in a grid onto a transparent sheet as mirror images so that the numbers are correctly displayed when I view it from the non printed side. The numbers have a particular sequence which cannot be obtained from calculations. So, they are stored in an array of strings : l[0][0] := "38"; ... I place them at the centre of the grid squares using the code below: for i= 0 upto (row - 1): for j= 0 upto (col - 1): middle := 0.5[((( i * unit) + lm), ((j * unit) + bm)), i+1) * unit) + lm), (((j +1) * unit) + bm))]; p := thelabel(l[j][i], middle); draw p; % q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); % draw q; endfor endfor This works as expected. But, when I try to reflect the label by means of the commented code, I get an error : tex error > mp error on line 643 in file /home/ajith/Desktop/PlayGround/numgrid.tex: >> (xpart T_,ypart T_,-0.00581xpart T_+0.00497ypart T_+0.15294,-0.00497xpart T_ -0.00581ypart T_+0.98824,-0.00497xpart T_-0.00581ypart T_+0.98825,0.00581xpart T_-0.00497ypart T_-0.15294) ! Transform components aren't all known. ; ...lcorner.p];q:=p.reflectedabout(uq,lq); draw.p; ENDFOR ...=p.reflectedabout(uq,lq);draw.p;endfor ENDFOR <*> ...lectedabout (uq, lq); draw p; endfor endfor StopPage ; ; I'm unable to apply a partially specified transformation except to a fully known pair or transform. Proceed, and I'll omit the transformation. I tried a mock example without the loops and that didn't throw an error. How can I make it work within the loops? Thanks, ajith ___ 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 transformation error
On 6/4/2021 10:15 AM, Ajith R wrote: Hi all, I am new to context and need help in solving an error. I am trying to print some numbers in a grid onto a transparent sheet as mirror images so that the numbers are correctly displayed when I view it from the non printed side. The numbers have a particular sequence which cannot be obtained from calculations. So, they are stored in an array of strings : l[0][0] := "38"; ... I place them at the centre of the grid squares using the code below: for i= 0 upto (row - 1): for j= 0 upto (col - 1): middle := 0.5[((( i * unit) + lm), ((j * unit) + bm)), i+1) * unit) + lm), (((j +1) * unit) + bm))]; p := thelabel(l[j][i], middle); draw p; % q := p reflectedabout (0.5[urcorner p, ulcorner p], 0.5[lrcorner p, llcorner p]); % draw q; endfor endfor This works as expected. But, when I try to reflect the label by means of the commented code, I get an error : tex error > mp error on line 643 in file /home/ajith/Desktop/PlayGround/numgrid.tex: (xpart T_,ypart T_,-0.00581xpart T_+0.00497ypart T_+0.15294,-0.00497xpart T_ -0.00581ypart T_+0.98824,-0.00497xpart T_-0.00581ypart T_+0.98825,0.00581xpart T_-0.00497ypart T_-0.15294) ! Transform components aren't all known. ; ...lcorner.p];q:=p.reflectedabout(uq,lq); draw.p; ENDFOR ...=p.reflectedabout(uq,lq);draw.p;endfor ENDFOR <*> ...lectedabout (uq, lq); draw p; endfor endfor StopPage ; ; I'm unable to apply a partially specified transformation except to a fully known pair or transform. Proceed, and I'll omit the transformation. I tried a mock example without the loops and that didn't throw an error. How can I make it work within the loops? In order answer that you have to make a MWE that we can run without the need to edit a file. 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] [metafun example does not compile]
On 21/05/2021 14:14, Taco Hoekwater wrote: It looks like textext.dflt is undefined in the latest lmtx because it is now renamed to textext.dlft :) As we say in dutch: een kniesoor die daar op let ;-) ___ 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 example does not compile]
the line preventing the output from showing uo seems to be be: draw textext.dflt("DFLT-" & MonTexte) shifted PB; If I remove that, I'll get output. ___ 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 example does not compile]
Hi, It looks like textext.dflt is undefined in the latest lmtx because it is now renamed to textext.dlft :) > On 21 May 2021, at 14:03, Floris van Manen wrote: > > Using the example from the wiki > https://wiki.contextgarden.net/textext_positioning > > then using the latest version of lmtx > > $ context --version > mtx-context | ConTeXt Process Management 1.04 > mtx-context | > mtx-context | main context file: > /home/vm/context/tex/texmf-context/tex/context/base/mkiv/context.mkiv > mtx-context | current version: 2021.05.20 16:06 > mtx-context | main context file: > /home/vm/context/tex/texmf-context/tex/context/base/mkxl/context.mkxl > mtx-context | current version: 2021.05.20 16:06 > > > it will produce an error (and an empty page) > > > metapost> initializing instance 'metafun:1' using format 'metafun' > and method 'default' > metapost> loading 'metafun' as 'metafun.mpxl' using method 'default' > metapost> initializing number mode 'scaled' > metafun > log > > metafun > log > error: Unknown relation will be considered false > metafun > log > > metapost> log > > metapost> log > > metapost> log >) > metapost> log > > thetextext->...FIX2)(rawtextext(ddecimal(EXPR3)),(EXPR4))else:if.anchortextexts>0:image(draw(EXPR3)withprescript"tx_anchor="(EXPR4))else:(EXPR3)fi.if(mfun_labtype(SUFFIX2)>=10) > metapost> log > :shifted(0,y... > metapost> log > > thetextext->begingroup.if.string(EXPR3):thetextext(SUFFIX2)(rawtextext((EXPR3)),(EXPR4)) > metapost> log > > elseif.numeric(EXPR3):thetextext(SUFFIX2)(rawtextext(decimal(EXPR3)),(EXPR4))elseif.pair(EXPR3):thetextext(SU... > metapost> log > > textext->begingroup.thetextext(SUFFIX2)((EXPR3),origin) > metapost> log > endgroup > metapost> log > <*> ...A; draw PA withpen pencircle scaled 1.5mm > withcolor red; pair PB ; PB := PA shifted decal ; draw textext.drt ("DRT-" & > MonTexte) shifted PB; draw textext.dflt("DFLT-" & MonTexte) > metafun > log > > metafun > log > Oh dear. I can't decide if the expression above is > positive, negative, or zero. > So this comparison test won't be 'true'. > > > > > As in most of the cases with software, there is (probably) a reason to it ;-) > > > .F > ___ > 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 > ___ — Taco Hoekwater E: t...@bittext.nl genderfluid (all pronouns) ___ 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 example does not compile]
Using the example from the wiki https://wiki.contextgarden.net/textext_positioning then using the latest version of lmtx $ context --version mtx-context | ConTeXt Process Management 1.04 mtx-context | mtx-context | main context file: /home/vm/context/tex/texmf-context/tex/context/base/mkiv/context.mkiv mtx-context | current version: 2021.05.20 16:06 mtx-context | main context file: /home/vm/context/tex/texmf-context/tex/context/base/mkxl/context.mkxl mtx-context | current version: 2021.05.20 16:06 it will produce an error (and an empty page) metapost> initializing instance 'metafun:1' using format 'metafun' and method 'default' metapost> loading 'metafun' as 'metafun.mpxl' using method 'default' metapost> initializing number mode 'scaled' metafun > log > metafun > log > error: Unknown relation will be considered false metafun > log > metapost> log > metapost> log > metapost> log >) metapost> log > thetextext->...FIX2)(rawtextext(ddecimal(EXPR3)),(EXPR4))else:if.anchortextexts>0:image(draw(EXPR3)withprescript"tx_anchor="(EXPR4))else:(EXPR3)fi.if(mfun_labtype(SUFFIX2)>=10) metapost> log > :shifted(0,y... metapost> log > thetextext->begingroup.if.string(EXPR3):thetextext(SUFFIX2)(rawtextext((EXPR3)),(EXPR4)) metapost> log > elseif.numeric(EXPR3):thetextext(SUFFIX2)(rawtextext(decimal(EXPR3)),(EXPR4))elseif.pair(EXPR3):thetextext(SU... metapost> log > textext->begingroup.thetextext(SUFFIX2)((EXPR3),origin) metapost> log > endgroup metapost> log > <*> ...A; draw PA withpen pencircle scaled 1.5mm withcolor red; pair PB ; PB := PA shifted decal ; draw textext.drt ("DRT-" & MonTexte) shifted PB; draw textext.dflt("DFLT-" & MonTexte) metafun > log > metafun > log > Oh dear. I can't decide if the expression above is positive, negative, or zero. So this comparison test won't be 'true'. As in most of the cases with software, there is (probably) a reason to it ;-) .F ___ 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 / patterns
On Thu, 25 Mar 2021, Hans Hagen wrote: > Hi, > > As I'm still in metafun (and svg) mode I decided to support patterns > (that are already supported at the tex end) also in metafun. As there > has never been demands I suppose it's not that interesting but it sort > of fits in. > > There are some tricky aspectx involved so the interface might evolve a > bit (some more control options) but here are some examples anyway: This is nice! I have used something like this in the past (but with "manual clipping", which is always cumbersome for irregular shapes). 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] metafun / patterns
Sorry for the noise, my fault: Thunderbird replaced some semicolon combinations with emojis, so they were missing when I copied and pasted them in a source file. Massi Il 25/03/21 15:14, mf ha scritto: Il 25/03/21 14:11, Hans Hagen ha scritto: \startMPpage[offset=1cm] draw (fullcircle scaled 5cm shifted (0cm,0cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) withpatternscale (1/10,1/10) ; draw (fullcircle scaled 5cm shifted (5cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkred" ;) withpatternscale (1/20,1/20) ; draw (fullcircle scaled 5cm shifted (10cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkgreen" ;) withpatternscale (1/40,1/40) ; draw (fullcircle scaled 5cm shifted (0cm,5cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkcyan" ;) withpatternscale (1/10,1/20) ; draw (fullcircle scaled 5cm shifted (5cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkmagenta" ;) withpatternscale (1/20,1/40) ; draw (fullcircle scaled 5cm shifted (10cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkyellow" ;) withpatternscale (1/40,1/80) ; \stopMPpage \startMPpage[offset=1cm] fill fullcircle scaled 11cm withcolor "darkyellow" ; draw fullcircle scaled 10cm withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) ; draw fulldiamond scaled 8cm withpattern image (fill fulldiamond scaled 4mm withcolor "darkgreen" ;) rotated 15 ; draw fulltriangle scaled 9cm withpattern image (fill fulltriangle scaled 3mm withcolor "white" ;) rotated 45 ; draw fullcircle scaled 10cm withpattern image (draw textext("!") withcolor "middlegray" ;) rotated 45 ; draw fullcircle scaled 10cm withpen pencircle scaled 1mm withcolor "darkgray" ; \stopMPpage Those first two pages appear 20x20mm and blank. Page 3 and 4 show patterns instead. Massi ___ 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] metafun / patterns
Il 25/03/21 14:11, Hans Hagen ha scritto: \startMPpage[offset=1cm] draw (fullcircle scaled 5cm shifted (0cm,0cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) withpatternscale (1/10,1/10) ; draw (fullcircle scaled 5cm shifted (5cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkred" ;) withpatternscale (1/20,1/20) ; draw (fullcircle scaled 5cm shifted (10cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkgreen" ;) withpatternscale (1/40,1/40) ; draw (fullcircle scaled 5cm shifted (0cm,5cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkcyan" ;) withpatternscale (1/10,1/20) ; draw (fullcircle scaled 5cm shifted (5cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkmagenta" ;) withpatternscale (1/20,1/40) ; draw (fullcircle scaled 5cm shifted (10cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkyellow" ;) withpatternscale (1/40,1/80) ; \stopMPpage \startMPpage[offset=1cm] fill fullcircle scaled 11cm withcolor "darkyellow" ; draw fullcircle scaled 10cm withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) ; draw fulldiamond scaled 8cm withpattern image (fill fulldiamond scaled 4mm withcolor "darkgreen" ;) rotated 15 ; draw fulltriangle scaled 9cm withpattern image (fill fulltriangle scaled 3mm withcolor "white" ;) rotated 45 ; draw fullcircle scaled 10cm withpattern image (draw textext("!") withcolor "middlegray" ;) rotated 45 ; draw fullcircle scaled 10cm withpen pencircle scaled 1mm withcolor "darkgray" ; \stopMPpage Those first two pages appear 20x20mm and blank. Page 3 and 4 show patterns instead. Massi ___ 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 / patterns
Hi, As I'm still in metafun (and svg) mode I decided to support patterns (that are already supported at the tex end) also in metafun. As there has never been demands I suppose it's not that interesting but it sort of fits in. There are some tricky aspectx involved so the interface might evolve a bit (some more control options) but here are some examples anyway: \starttext \startMPpage[offset=1cm] draw (fullcircle scaled 5cm shifted (0cm,0cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) withpatternscale (1/10,1/10) ; draw (fullcircle scaled 5cm shifted (5cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkred" ;) withpatternscale (1/20,1/20) ; draw (fullcircle scaled 5cm shifted (10cm,0cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkgreen" ;) withpatternscale (1/40,1/40) ; draw (fullcircle scaled 5cm shifted (0cm,5cm)) withpattern image (fill fullcircle scaled 1cm withcolor "darkcyan" ;) withpatternscale (1/10,1/20) ; draw (fullcircle scaled 5cm shifted (5cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkmagenta" ;) withpatternscale (1/20,1/40) ; draw (fullcircle scaled 5cm shifted (10cm,5cm)) withpattern image (fill fullcircle scaled 5mm withcolor "darkyellow" ;) withpatternscale (1/40,1/80) ; \stopMPpage \startMPpage[offset=1cm] fill fullcircle scaled 11cm withcolor "darkyellow" ; draw fullcircle scaled 10cm withpattern image (fill fullcircle scaled 1cm withcolor "darkblue" ;) ; draw fulldiamond scaled 8cm withpattern image (fill fulldiamond scaled 4mm withcolor "darkgreen" ;) rotated 15 ; draw fulltriangle scaled 9cm withpattern image (fill fulltriangle scaled 3mm withcolor "white" ;) rotated 45 ; draw fullcircle scaled 10cm withpattern image (draw textext("!") withcolor "middlegray" ;) rotated 45 ; draw fullcircle scaled 10cm withpen pencircle scaled 1mm withcolor "darkgray" ; \stopMPpage \startMPpage[instance=doublefun] draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25))) withcolor "darkgray" withopacity .5) withpatternscale (1,1) ; draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25))) withcolor "darkred" withopacity .5) withpatternscale (1/2,1/2) ; draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25))) withcolor "darkgreen" withopacity .5) withpatternscale (1/3,1/3) ; draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25))) withcolor "darkblue" withopacity .5) withpatternscale (1/4,1/4) ; \stopMPpage % \startTEXpage \page \startMPcode{doublefun} draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25 withpatternscale (1/8,1/8) ; \stopMPcode \blank \startMPcode{doublefun} draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-400)) withpattern image (fill closedcurve((fullcircle scaled 40 shifted (25,-25 withpatternfloat true withpatternscale (1/8,1/8) ; \stopMPcode \page % \stopTEXpage % \startMPpage[instance=doublefun] % draw closedcurve(unitsquare xyscaled (200,200) shifted (0,-200)) % withpattern image ( fill closedcurve(unitsquare xyscaled (50,50) shifted (0,-50)) withcolor svgcolor(0.529,0.808,0.922) ; fill closedcurve(unitsquare xyscaled (25,25) shifted (0,-25)) withshademethod "linear" % withshadecenteronefraction (0,1) % withshadecentertwofraction (0,0) % withshadestep ( withshadefraction 0.05 withshadecolors (svgcolor(1,0,0),svgcolor(1,0,0)) ) % withshadestep ( withshadefraction 0.95 withshadecolors (svgcolor(1,0,0),svgcolor(1,0.5,0)) ) ; fill closedcurve((fullcircle scaled 40 shifted (25,-25))) withshademethod "linear" % withshadestep ( withshadefraction 0.05 withshadecolors (svggray(1),svggray(1)) ) % withshadestep ( withshadefraction 0.95 withshadecolors (svggray(1),svgcolor(0,0,1)) ) withopacity 0.5 ; ) % withpatternscale(1/4,1/4) % ; % \stopMPpage % \startTEXpage % \externalfigure[test.svg][conversion=mp,xobject=no] % \stopTEXpage \stoptext - Hans Hagen | PRAGMA
Re: [NTG-context] metafun
On 2/20/2021 6:43 PM, Otared Kavian wrote: Thanks for the new upload. For your information, I would like to report that the metafun.tex file typesets almost corretly (actually I often typeset it for testing a new upload…) but I get a PDF with 400 pages instead the 448 you are mentionning… The issues are typically some figures not showing up (for instance figures 13.1 upto 13.13 in chapter 13). If you think this may be useful for you, I can send you off list the PDF I get on MacOS 10.14.6 and today's release of LMTX. Did you check the log? Does some graphic fail? The missing pages can be the summary chapter (due to just one run). 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] metafun
Hi Hans, Thanks for the new upload. For your information, I would like to report that the metafun.tex file typesets almost corretly (actually I often typeset it for testing a new upload…) but I get a PDF with 400 pages instead the 448 you are mentionning… The issues are typically some figures not showing up (for instance figures 13.1 upto 13.13 in chapter 13). If you think this may be useful for you, I can send you off list the PDF I get on MacOS 10.14.6 and today's release of LMTX. Best regards: Otared > On 20 Feb 2021, at 17:27, Hans Hagen wrote: > > Hi, > > When making sure that the metafun manual processes with lmtx (where we have > sometimes different implementations of macros) I also checked performance. > > When we started with this manual, it was still MKII time so we either had > direct calls or inbetween calls. Especially multiple runs could take a while > (many minutes, iir some 15 depending on how it was run). That was no fun. > > In mkiv with luatex and the built in mp library this dramatically went down > to 18.1 seconds for one run and 14.2 seconds for luajittex, for 428 > pages. > > This not bad considering that a lots of features are used: thousands of mp > images, a bunch of external images, many fonts, plenty of buffers, > positioning, color, hyperlinks, backgrounds etc. This document uses plenty of > lua so that is why we gain a lot with luajittex. > > In lmtx where we dropped jit and have a less performing backend we expect to > need more runtime but in the meantime we're quite okay. Not only the engine > is faster, but also some low level macros benefit a bit from new features. I > don't know how much lua speedup plays a role but probably not that much. For > 448 pages (some 20 more than we had before) we now need 16.5 seconds and 15.7 > when we use the compact font mode. So we're halfway between luatex and > luajittex now. More than 3 seconds of the runtime is for metapost. (I use the > machine as before.) > > Hans > > PS. If all the stories are true is should be 1 second on a modern apple at > which point differences in measurements become noise but I cannot check that. > Some day I might check it on a rpi 4. > > - > 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 > ___ ___ 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
Hi, When making sure that the metafun manual processes with lmtx (where we have sometimes different implementations of macros) I also checked performance. When we started with this manual, it was still MKII time so we either had direct calls or inbetween calls. Especially multiple runs could take a while (many minutes, iir some 15 depending on how it was run). That was no fun. In mkiv with luatex and the built in mp library this dramatically went down to 18.1 seconds for one run and 14.2 seconds for luajittex, for 428 pages. This not bad considering that a lots of features are used: thousands of mp images, a bunch of external images, many fonts, plenty of buffers, positioning, color, hyperlinks, backgrounds etc. This document uses plenty of lua so that is why we gain a lot with luajittex. In lmtx where we dropped jit and have a less performing backend we expect to need more runtime but in the meantime we're quite okay. Not only the engine is faster, but also some low level macros benefit a bit from new features. I don't know how much lua speedup plays a role but probably not that much. For 448 pages (some 20 more than we had before) we now need 16.5 seconds and 15.7 when we use the compact font mode. So we're halfway between luatex and luajittex now. More than 3 seconds of the runtime is for metapost. (I use the machine as before.) Hans PS. If all the stories are true is should be 1 second on a modern apple at which point differences in measurements become noise but I cannot check that. Some day I might check it on a rpi 4. - 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] Metafun: dotlabel issue in latest LMTX
Hi Hans, The following (due to you and Aditya, discussed a few days ago) used to work with LMTX until version 2020-12-10, but it does not work anymore with LMTX version 2020-12-24 17:30. I wonder whether this is due to some changes you have made recently. %% begin squaredot-test.tex \startMPdefinitions newpath mydotlabelshape ; mydotlabelshape := fullcircle ; mydotlabeldiam := 12 pt ; vardef mydotlabel@#(expr s,z) text t_ = label@#(s,z) t_ ; fill (mydotlabelshape scaled 2mydotlabeldiam) shifted z t_; enddef ; \stopMPdefinitions \starttext \startMPcode newpath p ; p := (2cm, 3cm) -- (3cm, 5cm); mydotlabeldiam := 15pt; mydotlabelshape := fullsquare ; draw p ; mydotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) withcolor transparent("exclusion",.5,red) ; mydotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) withcolor transparent("exclusion",.5,red) ; \stopMPcode \stoptext %% end squaredot-test.tex I get an error message, which is obscure to me, saying: %-- begin error message excerpt metafun > log > error: Isolated expression metafun > log > metapost> log > metapost> log > metapost> log >; metapost> log > <*> newpath mydotlabelshape ; metafun > log > metafun > log > I couldn't find an '=' or ':=' after the expression that is shown above this error message, so I guess I'll just ignore it and carry on. metafun > log > metapost> log > mydotlabelshape := fullcircle ; mydotlabeldiam := 12 pt ; vardef mydotlabel@##(expr s,z) text t_ = label@##(s,z) t_ ; fill (mydotlabelshape scaled 2mydotlabeldiam) shi... %-- end error message excerpt Best regards: Otared ___ 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 labels and xsized
On 12/25/20 10:09 PM, Hans Hagen wrote: >> [...] > \startMPcode > path p ; p := ( > ( 1, 1) -- > ( 1, 5) -- > (10, 10) -- > (14, 4) -- > cycle) xsized .75TextWidth; > > draw p ; > > freelabel("\strut α",point 0 of p,center p) ; > freelabel("\strut β",point 1 of p,center p) ; > freelabel("\strut γ",point 2 of p,center p) ; > freelabel("\strut δ",point 3 of p,center p) ; > \stopMPcode Many thanks for your code, Hans. This is exactly what I need. Pablo -- http://www.ousia.tk ___ 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 labels and xsized
On 12/25/2020 6:36 PM, Fabrice L wrote: Hi, Le 25 déc. 2020 à 12:30, Pablo Rodriguez a écrit : Dear list, I have this minimal MetaFun sample (the only one in my real document): \setupbodyfont[pagella] \starttext \startMPcode pair a ; a := (1, 1) ; pair b ; b := (1, 10) ; pair c ; c := (10, 10) ; pair d ; d := (10, 1) ; draw (a--b--c--d--a) xsized .75TextWidth; draw thelabel.lft("α",a) ; draw thelabel.lft("β",b) ; draw thelabel.top("γ",c) ; draw thelabel.rt("δ",d) ; \stopMPcode \stoptext Is there a way to relate adapt the labels to the xsized positions used? I’m sure somebody could find a more elegant solution, but here is a simple one: \setupbodyfont[pagella] \starttext \startMPcode pair a ; a := (1, 1) ; pair b ; b := (1, 10) ; pair c ; c := (10, 10) ; pair d ; d := (10, 1) ; path square ; square := (a--b--c--d--cycle) xsized .75TextWidth ; draw square xsized .75TextWidth; draw thelabel.lft("α",point 0 of square) ; draw thelabel.lft("β",point 1 of square) ; draw thelabel.top("γ",point 2 of square) ; draw thelabel.rt("δ",point 3 of square) ; \stopMPcode \stoptext Fabrice. \startMPcode path p ; p := ( ( 1, 1) -- ( 1, 5) -- (10, 10) -- (14, 4) -- cycle) xsized .75TextWidth; draw p ; freelabel("\strut α",point 0 of p,center p) ; freelabel("\strut β",point 1 of p,center p) ; freelabel("\strut γ",point 2 of p,center p) ; freelabel("\strut δ",point 3 of p,center p) ; \stopMPcode - 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] MetaFun labels and xsized
On 12/25/20 6:36 PM, Fabrice L wrote: >> I have this minimal MetaFun sample (the only one in my real document): >> [...] >> Is there a way to relate adapt the labels to the xsized positions used? > > I’m sure somebody could find a more elegant solution, but here is a simple > one: > > \setupbodyfont[pagella] > \starttext > \startMPcode > pair a ; a := (1, 1) ; > pair b ; b := (1, 10) ; > pair c ; c := (10, 10) ; > pair d ; d := (10, 1) ; > path square ; > square := (a--b--c--d--cycle) xsized .75TextWidth ; > > draw square xsized .75TextWidth; > > draw thelabel.lft("α",point 0 of square) ; > draw thelabel.lft("β",point 1 of square) ; > draw thelabel.top("γ",point 2 of square) ; > draw thelabel.rt("δ",point 3 of square) ; > \stopMPcode > \stoptext Many thanks for your ultra-fast reply, Fabrice. I didn’t know that paths could be also defined (MP is all Greek to me). I realized that drawing doesn’t require resizing again (once the path definition contains resizing). Many thanks for your help, Pablo -- http://www.ousia.tk ___ 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 labels and xsized
Hi, > Le 25 déc. 2020 à 12:30, Pablo Rodriguez a écrit : > > Dear list, > > I have this minimal MetaFun sample (the only one in my real document): > > \setupbodyfont[pagella] > \starttext > \startMPcode > pair a ; a := (1, 1) ; > pair b ; b := (1, 10) ; > pair c ; c := (10, 10) ; > pair d ; d := (10, 1) ; > draw (a--b--c--d--a) xsized .75TextWidth; > > draw thelabel.lft("α",a) ; > draw thelabel.lft("β",b) ; > draw thelabel.top("γ",c) ; > draw thelabel.rt("δ",d) ; > \stopMPcode > \stoptext > > Is there a way to relate adapt the labels to the xsized positions used? I’m sure somebody could find a more elegant solution, but here is a simple one: \setupbodyfont[pagella] \starttext \startMPcode pair a ; a := (1, 1) ; pair b ; b := (1, 10) ; pair c ; c := (10, 10) ; pair d ; d := (10, 1) ; path square ; square := (a--b--c--d--cycle) xsized .75TextWidth ; draw square xsized .75TextWidth; draw thelabel.lft("α",point 0 of square) ; draw thelabel.lft("β",point 1 of square) ; draw thelabel.top("γ",point 2 of square) ; draw thelabel.rt("δ",point 3 of square) ; \stopMPcode \stoptext Fabrice. > > Many thanks for your help, > > Pablo > -- > http://www.ousia.tk > ___ > 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 labels and xsized
Dear list, I have this minimal MetaFun sample (the only one in my real document): \setupbodyfont[pagella] \starttext \startMPcode pair a ; a := (1, 1) ; pair b ; b := (1, 10) ; pair c ; c := (10, 10) ; pair d ; d := (10, 1) ; draw (a--b--c--d--a) xsized .75TextWidth; draw thelabel.lft("α",a) ; draw thelabel.lft("β",b) ; draw thelabel.top("γ",c) ; draw thelabel.rt("δ",d) ; \stopMPcode \stoptext Is there a way to relate adapt the labels to the xsized positions used? Many thanks for your help, Pablo -- http://www.ousia.tk ___ 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 - "remove the paths of text" from a rectangle to let the background visible
Much more lean now thanks to your feedbacks. I prefered to "remove the shapes of the letter" rather than doubling the shading. Wikified https://wiki.contextgarden.net/Cover_Pages#.22Empty.22_letters \definecolor [ColorHighA] [h=c4a000] \definecolor [ColorHighB] [h=602217] \definecolor [ColorLow] [0.8(white)] \startMPpage %-- picture tt ; tt := lmt_outline [ kind = "fillup", text = "\definedfont[name:texgyrepagellabold*default]% \framed[frame=off,offset=3mm,align=middle,strut=none] {MetaPost\\is Fun !\\Aujourd'hui\\Today\\*§ 2020 §*}", ] xsized 12cm ; path bb ; bb := boundingbox tt; %-- path pp ; pp := bb enlarged 2cm ; fill pp withshademethod "linear" withshadedirection (2.,0.) withshadecolors (\MPcolor{ColorHighA}, \MPcolor{ColorHighB}); %-- picture Paddmissing; Paddmissing := nullpicture; picture Pwoletters; Pwoletters := nullpicture; numeric testwithin ; %-- for i within tt : if stroked i or filled i : testwithin :=0; for j within tt : if stroked j or filled j: if (((xpart llcorner i) > (xpart llcorner j)) and ((ypart llcorner i) > (ypart llcorner j)) and ((xpart urcorner i) < (xpart urcorner j)) and ((ypart urcorner i) < (ypart urcorner j))) : testwithin :=1; fi; fi; endfor; if testwithin == 1: addto Paddmissing contour (pathpart i) withcolor \MPcolor{ColorLow}; else: addto Pwoletters contour (pathpart i) withpostscript "collect"; fi; fi ; endfor ; %-- addto Pwoletters contour bb withpostscript "evenodd" withcolor \MPcolor{ColorLow}; draw Pwoletters ; draw Paddmissing ; \stopMPpage ___ 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 - "remove the paths of text" from a rectangle to let the background visible
> On 24 Dec 2020, at 00:14, Garulfo wrote: > > Thanks Taco, > > I made some progress : > https://wiki.contextgarden.net/Talk:Cover_Pages > > I now have two additional questions ... ;-) > > - How can I deal with "space" characters (because current solution > requires to explicitly add the ~ character) Here’s what I would do (which is probably not the nicest way of doing it). Just enable \obeyspaces while reading the argument to \EmptyLetters, then disable it again immediately (that is needed if you have to go back to TeX from Lua): \def\EmptyLetters {\obeyspaces\doEmptyLetters} \def\doEmptyLetters#1% {\normalspaces ... } and in \whatever you then need \doifinstringelse{ }{#1} 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___
Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible
On 12/24/2020 12:46 AM, Otared Kavian wrote: Hi Garulfo, Thank you for sharing your nice example: it typesets correctly with mkiv, but it seems to me that with LMTX the text does not appear (at least on my installation of the latest LMTX). I admit that I had to trial and error this: \startMPpage picture tt ; tt := lmt_outline [ kind = "fillup", text = "\strut foo f o o", drawcolor = "white", rulethickness = .2 ] ysized 5cm ; path bb ; bb := boundingbox tt; path pp ; pp := bb enlarged 3cm ; fill pp withshademethod "linear" withshadedirection down withshadecolors (red, blue) ; fill bb withcolor "darkgray" ; for i within tt : if stroked i : nofill (pathpart i) ; fi ; dofill bb withshademethod "linear" withshadedirection down withshadecolors (red, blue) ; endfor ; \stopMPpage - 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] MetaFun - "remove the paths of text" from a rectangle to let the background visible
On 12/24/2020 12:14 AM, Garulfo wrote: Thanks Taco, I made some progress : https://wiki.contextgarden.net/Talk:Cover_Pages I now have two additional questions ... ;-) - How can I deal with "space" characters (because current solution requires to explicitly add the ~ character) - What would be the work to do in order to make this mechanism directly usable in metapost / metafun, within \startMPpage \stopMPpage, - to avoid switching between \start\stopMPdrawing and TeX - to have something like "draw followtext" in mp-blob.mpiv ? Maybe pickup some tricks from this: \starttext \startMPpage StartPage; fill Page withshademethod "linear" withshadedirection(0,1) withshadecolors (red, blue) ; picture p ; p := lmt_outline [ text = "\strut foo f o o", drawcolor = "white", rulethickness = .2 ] ysized 5cm ; draw (p shifted - center p) shifted center Page; StopPage; \stopMPpage \startuseMPgraphic{MyShade} fill OverlayBox withshademethod "linear" withshadedirection(0,1) withshadecolors (red, blue) ; \stopuseMPgraphic \defineoverlay[MyShade][\useMPgraphic{MyShade}] \setupbackgrounds[page][background=MyShade] \startmakeup \definedfont[SerifBold*default @ 50pt] \setupinterlinespace \defineeffect[MyOutline][alternative=outer,rulethickness=1pt] \startcolor[white] \starteffect[MyOutline] \input jojomayer \stopeffect \stopcolor \stopmakeup \stoptext %-- \setuppapersize [A4] %-- \def\MyFont{\definedfont[name:% texgyrepagellabold% %exo2black% %agaramondprobold% *default at 55pt]} %-- \startluacode function document.outlinepaths(character) local chardata = fonts.hashes.characters[true] -- by unicode local shapedata = fonts.hashes.shapes[true] -- by index local c = chardata[character] if c and c.index and shapedata then local shapeglyphs = shapedata.glyphs or { } local glyph = shapeglyphs[c.index] if glyph and (glyph.segments or glyph.sequence) then local units = shapedata.units or 1000 local factor = 100/units return fonts.metapost.paths(glyph,factor) end end return { } end function document.defineoutline(char,target) local outlines = document.outlinepaths(char) local nofpaths = #outlines context("\\startMPdrawing") -- ADDED by garulfo context("path %s[] ;",target) context("numeric %sn ; %sn := %s ;",target,target,nofpaths) for i=1,nofpaths do context("%s[%i] := %s ; ",target,i,outlines[i]) end context("\\stopMPdrawing") -- ADDED by garulfo end \stopluacode %-- \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} %-- \def\EmptyLetters#1% {% \resetMPdrawing \MPtoks={} % \startMPdrawing picture pic[], pictA ; numeric wid[], len[], pos[], n ; wid[0] := len[0] := pos[0] := n := 0 ; numeric scaling; path pictB , frame ; pair shiftB ; picture monImageA; monImageA := nullpicture; picture monImageB; monImageB := nullpicture; color colorframe; colorframe := 0.6white; % \stopMPdrawing % \MyFont\handletokens#1\with\whatever % \startMPdrawing frame := unitsquare xscaled ( (xpart urcorner monImageB - xpart llcorner monImageB) + 5mm ) yscaled ( (ypart urcorner monImageB - ypart llcorner monImageB) + 5mm ); frame := frame shifted (center monImageB - center frame); addto monImageB contour frame withpostscript "evenodd" withcolor transparent (1,1.,colorframe); draw monImageB ; draw monImageA ; \stopMPdrawing % \MPdrawingdonetrue \getMPdrawing} %-- \def\whatever#1% {\appendtoks#1\to\MPtoks \setbox\MPbox=\hbox{\MyFont\the\MPtoks}% % \startMPdrawing n := n + 1 ; len[n] := \the\wd\MPbox ; \stopMPdrawing % \mpdefineoutlines{M}{MaLettre} % \startMPdrawing pictA := textext.drt("\MyFont M") ; pictB := MaLettre[1]; scaling := bbheight pictA / bbheight pictB; \stopMPdrawing % \doifinstringelse{~}{#1}{}{% HOW TO PROPERLY COPE WITH SPACES ? \mpdefineoutlines{#1}{MyGlyph} % \startMPdrawing string sb; sb := "i"; pic[n] := textext.drt("\MyFont\setstrut\strut#1") ; % shiftB := - llcorner pic[n];
Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible
Hi Garulfo, Thank you for sharing your nice example: it typesets correctly with mkiv, but it seems to me that with LMTX the text does not appear (at least on my installation of the latest LMTX). Best regards: Otared > On 24 Dec 2020, at 00:14, Garulfo wrote: > > Thanks Taco, > > I made some progress : > https://wiki.contextgarden.net/Talk:Cover_Pages > > I now have two additional questions ... ;-) > > - How can I deal with "space" characters (because current solution > requires to explicitly add the ~ character) > > - What would be the work to do in order to make this mechanism directly > usable in metapost / metafun, within \startMPpage \stopMPpage, > - to avoid switching between \start\stopMPdrawing and TeX > - to have something like "draw followtext" in mp-blob.mpiv ? > > > > %-- > > \setuppapersize [A4] > > %-- > > \def\MyFont{\definedfont[name:% > texgyrepagellabold% > %exo2black% > %agaramondprobold% > *default at 55pt]} > > %-- > > \startluacode > > function document.outlinepaths(character) >local chardata = fonts.hashes.characters[true] -- by unicode >local shapedata = fonts.hashes.shapes[true] -- by index >local c = chardata[character] >if c and c.index and shapedata then >local shapeglyphs = shapedata.glyphs or { } >local glyph = shapeglyphs[c.index] >if glyph and (glyph.segments or glyph.sequence) then >local units = shapedata.units or 1000 >local factor = 100/units >return fonts.metapost.paths(glyph,factor) >end >end >return { } > end > > function document.defineoutline(char,target) >local outlines = document.outlinepaths(char) >local nofpaths = #outlines >context("\\startMPdrawing") -- ADDED by garulfo >context("path %s[] ;",target) >context("numeric %sn ; %sn := %s ;",target,target,nofpaths) >for i=1,nofpaths do >context("%s[%i] := %s ; ",target,i,outlines[i]) >end >context("\\stopMPdrawing") -- ADDED by garulfo > end > > \stopluacode > > %-- > > \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} > > %-- > > \def\EmptyLetters#1% > {% > \resetMPdrawing > \MPtoks={} > % > \startMPdrawing > picture pic[], pictA ; > numeric wid[], len[], pos[], n ; > wid[0] := len[0] := pos[0] := n := 0 ; > numeric scaling; > path pictB , frame ; > pair shiftB ; > picture monImageA; monImageA := nullpicture; > picture monImageB; monImageB := nullpicture; > color colorframe; colorframe := 0.6white; > % > \stopMPdrawing > % > \MyFont\handletokens#1\with\whatever > % > \startMPdrawing > frame := unitsquare > xscaled ( (xpart urcorner monImageB - xpart llcorner monImageB) + > 5mm ) > yscaled ( (ypart urcorner monImageB - ypart llcorner monImageB) + > 5mm ); > frame := frame shifted (center monImageB - center frame); > addto monImageB contour >frame >withpostscript "evenodd" >withcolor transparent (1,1.,colorframe); > draw monImageB ; > draw monImageA ; > \stopMPdrawing > % > \MPdrawingdonetrue > \getMPdrawing} > > %-- > > \def\whatever#1% > {\appendtoks#1\to\MPtoks > \setbox\MPbox=\hbox{\MyFont\the\MPtoks}% > % > \startMPdrawing > n := n + 1 ; len[n] := \the\wd\MPbox ; > \stopMPdrawing > % > \mpdefineoutlines{M}{MaLettre} > % > \startMPdrawing > pictA := textext.drt("\MyFont M") ; > pictB := MaLettre[1]; > scaling := bbheight pictA / bbheight pictB; > \stopMPdrawing > % > \doifinstringelse{~}{#1}{}{%HOW TO PROPERLY COPE WITH > SPACES ? > \mpdefineoutlines{#1}{MyGlyph} > % > \startMPdrawing > string sb; sb := "i"; > pic[n] := textext.drt("\MyFont\setstrut\strut#1") ; > % > shiftB := - llcorner pic[n]; > pic[n] := pic[n] shifted shiftB ; > % > wid[n] := abs(xpart urcorner pic[n] - xpart llcorner pic[n]) ; > pos[n] := len[n]-wid[n] ; > % > addto monImageB contour > ((MyGlyph[1] scaled scaling) > shifted ( (pos[n],0) + shiftB)) > withpostscript "collect"; > % > if MyGlyphn > 1 : >for ind=2 upto MyGlyphn : >if (((xpart llcorner MyGlyph[ind]) > (xpart llcorner MyGlyph[1])) > and >((ypart llcorner MyGlyph[ind]) > (ypart llcorner MyGlyph[1])) > and >((xpart urcorner MyGlyph[ind]) < (xpart urcorner MyGlyph[1])) > and >((ypart urcorner MyGlyph[ind]) < (ypart
Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible
Thanks Taco, I made some progress : https://wiki.contextgarden.net/Talk:Cover_Pages I now have two additional questions ... ;-) - How can I deal with "space" characters (because current solution requires to explicitly add the ~ character) - What would be the work to do in order to make this mechanism directly usable in metapost / metafun, within \startMPpage \stopMPpage, - to avoid switching between \start\stopMPdrawing and TeX - to have something like "draw followtext" in mp-blob.mpiv ? %-- \setuppapersize [A4] %-- \def\MyFont{\definedfont[name:% texgyrepagellabold% %exo2black% %agaramondprobold% *default at 55pt]} %-- \startluacode function document.outlinepaths(character) local chardata = fonts.hashes.characters[true] -- by unicode local shapedata = fonts.hashes.shapes[true] -- by index local c = chardata[character] if c and c.index and shapedata then local shapeglyphs = shapedata.glyphs or { } local glyph = shapeglyphs[c.index] if glyph and (glyph.segments or glyph.sequence) then local units = shapedata.units or 1000 local factor = 100/units return fonts.metapost.paths(glyph,factor) end end return { } end function document.defineoutline(char,target) local outlines = document.outlinepaths(char) local nofpaths = #outlines context("\\startMPdrawing") -- ADDED by garulfo context("path %s[] ;",target) context("numeric %sn ; %sn := %s ;",target,target,nofpaths) for i=1,nofpaths do context("%s[%i] := %s ; ",target,i,outlines[i]) end context("\\stopMPdrawing") -- ADDED by garulfo end \stopluacode %-- \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} %-- \def\EmptyLetters#1% {% \resetMPdrawing \MPtoks={} % \startMPdrawing picture pic[], pictA ; numeric wid[], len[], pos[], n ; wid[0] := len[0] := pos[0] := n := 0 ; numeric scaling; path pictB , frame ; pair shiftB ; picture monImageA; monImageA := nullpicture; picture monImageB; monImageB := nullpicture; color colorframe; colorframe := 0.6white; % \stopMPdrawing % \MyFont\handletokens#1\with\whatever % \startMPdrawing frame := unitsquare xscaled ( (xpart urcorner monImageB - xpart llcorner monImageB) + 5mm ) yscaled ( (ypart urcorner monImageB - ypart llcorner monImageB) + 5mm ); frame := frame shifted (center monImageB - center frame); addto monImageB contour frame withpostscript "evenodd" withcolor transparent (1,1.,colorframe); draw monImageB ; draw monImageA ; \stopMPdrawing % \MPdrawingdonetrue \getMPdrawing} %-- \def\whatever#1% {\appendtoks#1\to\MPtoks \setbox\MPbox=\hbox{\MyFont\the\MPtoks}% % \startMPdrawing n := n + 1 ; len[n] := \the\wd\MPbox ; \stopMPdrawing % \mpdefineoutlines{M}{MaLettre} % \startMPdrawing pictA := textext.drt("\MyFont M") ; pictB := MaLettre[1]; scaling := bbheight pictA / bbheight pictB; \stopMPdrawing % \doifinstringelse{~}{#1}{}{%HOW TO PROPERLY COPE WITH SPACES ? \mpdefineoutlines{#1}{MyGlyph} % \startMPdrawing string sb; sb := "i"; pic[n] := textext.drt("\MyFont\setstrut\strut#1") ; % shiftB := - llcorner pic[n]; pic[n] := pic[n] shifted shiftB ; % wid[n] := abs(xpart urcorner pic[n] - xpart llcorner pic[n]) ; pos[n] := len[n]-wid[n] ; % addto monImageB contour ((MyGlyph[1] scaled scaling) shifted ( (pos[n],0) + shiftB)) withpostscript "collect"; % if MyGlyphn > 1 : for ind=2 upto MyGlyphn : if (((xpart llcorner MyGlyph[ind]) > (xpart llcorner MyGlyph[1])) and ((ypart llcorner MyGlyph[ind]) > (ypart llcorner MyGlyph[1])) and ((xpart urcorner MyGlyph[ind]) < (xpart urcorner MyGlyph[1])) and ((ypart urcorner MyGlyph[ind]) < (ypart urcorner MyGlyph[1]))) : % addto monImageA contour (MyGlyph[ind] scaled scaling) shifted ( (pos[n],0) + shiftB) withcolor transparent (1,1.,colorframe); else : addto monImageB contour (MyGlyph[ind] scaled scaling) shifted ( (pos[n],0) + shiftB) withpostscript "collect"; fi;
Re: [NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible
> On 21 Dec 2020, at 16:09, Garulfo wrote: > > Hi, > > > * I try to "remove the paths of text" from a metapost pictures to let > the background visible. > > * Using > https://mailman.ntg.nl/pipermail/ntg-context/2018/thread.html#92725 > > * I was able to get the following with one glyph (MVE code below) > > https://wiki.contextgarden.net/images/d/d2/test_extract_glyphs.pdf > > > 2 questions: > > 1/ for some fonts (e.g. dejavu vs latin modern) the "encompassing" path > of the B glyph can switch from B[1] to B[Bn]. Is there a trick to > identify which id match with "the encompassing" path ? What you get is the order of the paths as defined in the font, which is arbitrary, as you discovered. A quick trick (that will not always work, but should work quite well for font variations of alphabetics) is to check the actual arclength of the paths. The longest one will typically be the outer one. But much depends on the font, so a generic solution is likely quite complicated. Consider an outline font’s colon glyph ;) > > 2/ now, I would like to do the same, but for text... a kind of > derivative of "textext" or "outlinetext". > Would you please give me some guidelines ? > does it already exist ? > should I use something like \handletokens, \scantokens ? > do you have examples where I can get inspiration ? > > > Thanks again for your help, > Garulfo > > > %== > > > > > \starttext > > %-- > > \startluacode > > function document.outlinepaths(character) >local chardata = fonts.hashes.characters[true] -- by unicode >local shapedata = fonts.hashes.shapes[true] -- by index >local c = chardata[character] >if c and c.index and shapedata then >local shapeglyphs = shapedata.glyphs or { } >local glyph = shapeglyphs[c.index] >if glyph and (glyph.segments or glyph.sequence) then >local units = shapedata.units or 1000 >local factor = 100/units >return fonts.metapost.paths(glyph,factor) >end >end >return { } > end > > function document.defineoutline(char,target) >local outlines = document.outlinepaths(char) >local nofpaths = #outlines >context("path %s[] ;",target) >context("numeric %sn ; %sn := %s ;",target,target,nofpaths) >for i=1,nofpaths do >context("%s[%i] := %s ; ",target,i,outlines[i]) >end > end > > \stopluacode > > %-- > > \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} > > %-- > > \startMPpage > > numeric dimA ; dimA := 20cm; > > path pathbackground ; > pathbackground := unitsquare scaled dimA ; > fill pathbackground withshademethod "linear" withshadedirection(0,1) > withshadecolors (red,blue); > > %-- > > \mpdefineoutlines{B}{B} > > %-- > > numeric dimB ; dimB := 2cm; > numeric vratio ; vratio := 2; > > path frame ; > frame := unitsquare > xscaled (dimA - 2 * dimB) > yscaled (dimA / vratio) > shifted (dimB , (dimA - (dimA / vratio))/2 ); > > %-- > > pair shift ; shift := center frame; > numeric scal ; scal := (0.9) * (10cm / (bbheight B[1])) ; > > picture monImageB; monImageB := nullpicture; > addto monImageB contour > (B[1] shifted (- center B[1]) scaled scal) > shifted shift > withpostscript "collect"; > > addto monImageB contour > frame > withpostscript "evenodd"; > > for i=2 upto Bn : > addto monImageB contour >(B[i] shifted (- center B[1]) scaled scal) >shifted shift; > endfor ; > > %-- > > draw monImageB withcolor white; > > \stopMPpage > > \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 > ___ Taco Hoekwater Elvenkind BV ___ 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/
[NTG-context] MetaFun - "remove the paths of text" from a rectangle to let the background visible
Hi, * I try to "remove the paths of text" from a metapost pictures to let the background visible. * Using https://mailman.ntg.nl/pipermail/ntg-context/2018/thread.html#92725 * I was able to get the following with one glyph (MVE code below) https://wiki.contextgarden.net/images/d/d2/test_extract_glyphs.pdf 2 questions: 1/ for some fonts (e.g. dejavu vs latin modern) the "encompassing" path of the B glyph can switch from B[1] to B[Bn]. Is there a trick to identify which id match with "the encompassing" path ? 2/ now, I would like to do the same, but for text... a kind of derivative of "textext" or "outlinetext". Would you please give me some guidelines ? does it already exist ? should I use something like \handletokens, \scantokens ? do you have examples where I can get inspiration ? Thanks again for your help, Garulfo %== \starttext %-- \startluacode function document.outlinepaths(character) local chardata = fonts.hashes.characters[true] -- by unicode local shapedata = fonts.hashes.shapes[true] -- by index local c = chardata[character] if c and c.index and shapedata then local shapeglyphs = shapedata.glyphs or { } local glyph = shapeglyphs[c.index] if glyph and (glyph.segments or glyph.sequence) then local units = shapedata.units or 1000 local factor = 100/units return fonts.metapost.paths(glyph,factor) end end return { } end function document.defineoutline(char,target) local outlines = document.outlinepaths(char) local nofpaths = #outlines context("path %s[] ;",target) context("numeric %sn ; %sn := %s ;",target,target,nofpaths) for i=1,nofpaths do context("%s[%i] := %s ; ",target,i,outlines[i]) end end \stopluacode %-- \def\mpdefineoutlines#1#2{\ctxlua{document.defineoutline(\number`#1,"#2")}} %-- \startMPpage numeric dimA ; dimA := 20cm; path pathbackground ; pathbackground := unitsquare scaled dimA ; fill pathbackground withshademethod "linear" withshadedirection(0,1) withshadecolors (red,blue); %-- \mpdefineoutlines{B}{B} %-- numeric dimB ; dimB := 2cm; numeric vratio ; vratio := 2; path frame ; frame := unitsquare xscaled (dimA - 2 * dimB) yscaled (dimA / vratio) shifted (dimB , (dimA - (dimA / vratio))/2 ); %-- pair shift ; shift := center frame; numeric scal ; scal := (0.9) * (10cm / (bbheight B[1])) ; picture monImageB; monImageB := nullpicture; addto monImageB contour (B[1] shifted (- center B[1]) scaled scal) shifted shift withpostscript "collect"; addto monImageB contour frame withpostscript "evenodd"; for i=2 upto Bn : addto monImageB contour (B[i] shifted (- center B[1]) scaled scal) shifted shift; endfor ; %-- draw monImageB withcolor white; \stopMPpage \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] Metafun: is it possible to redefine dotlabel to draw a square ?
On 12/10/2020 8:37 PM, Aditya Mahajan wrote: On Thu, 10 Dec 2020, Hans Hagen wrote: dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather than a path. Here is a (to me) simpler definition, where you can change the shape: just look in the pdf ... in your case the dot is a n point path while otherwise it uses the default postscript pen (which is a dot) Ah, that makes sense. it surprised me that a math guru like you doesn't do this: vardef dotlabel@#(expr s,z) text t_ = % draw textext("$\bullet$") scaled (1/2) shifted z ; % draw textext("$\blacktriangle$") scaled (1/4) shifted z ; draw textext("$\blacksquare$") scaled (1/4) shifted z ; label@#(s,z) t_ ; enddef ; \stopMPdefinitions Ha! I know that you said this as a joke, but as someone who did try to use the old font-based picture environment in LaTeX back in the day, I would never try to use fonts for "drawing". Especially, math fonts, where every designer has a different idea of what the shape should look like. ah pictex memories ... drawing lines with cmr5 periods ... but actually, we can define a stable font with symbols in metafun and use that (quite efficient too) and then one can even cut'n'paste those tiny symbols (don't worry ... not much of a challenge so low on my list) 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] Metafun: is it possible to redefine dotlabel to draw a square ?
On Thu, 10 Dec 2020, Hans Hagen wrote: > > dotlabel uses a pen to draw the dot, and I am not sure why it uses that > > rather > > than a path. Here is a (to me) simpler definition, where you can change the > > shape: > > just look in the pdf ... in your case the dot is a n point path while > otherwise > it uses the default postscript pen (which is a dot) Ah, that makes sense. > it surprised me that a math guru like you doesn't do this: > > vardef dotlabel@#(expr s,z) text t_ = > % draw textext("$\bullet$") scaled (1/2) shifted z ; > % draw textext("$\blacktriangle$") scaled (1/4) shifted z ; > draw textext("$\blacksquare$") scaled (1/4) shifted z ; > label@#(s,z) t_ ; > enddef ; > \stopMPdefinitions Ha! I know that you said this as a joke, but as someone who did try to use the old font-based picture environment in LaTeX back in the day, I would never try to use fonts for "drawing". Especially, math fonts, where every designer has a different idea of what the shape should look like. 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] Metafun: is it possible to redefine dotlabel to draw a square ?
On 12/10/2020 7:04 PM, Aditya Mahajan wrote: On Thu, 10 Dec 2020, Otared Kavian wrote: Hi Aditya, Thank you very much ! That's great indeed, you gave me an elegant solution. One more question, in order for me to understand a little more: when defining a new dotlabel as you do, might it not conflict with the internal definitions of dotlabel in Metafun in some other place? Maybe it is safer for me to call it something like « dotshapelabel » ? In general, I agree. Redefining internal macros has the advantage that your code doesn't have to change. See, for example: it depends a bit ... redefing dotlabel in a compatible way is kind of ok, but using/redefining \foo_bar_something_internal is a real bad idea as that is not part of the interface (okay, i know that there are macro packages out there where it's part of the concept to redefine low level stuff for styles but in context we should try to avoid it ... we should then adapt the high level interface to suport something) it also depends who does it ... i know that aditya knows the internals well enough to deal with it (one of my concerns is always that while we try to come up with efficient solutions it's easy to make things inefficient but that's not the case here ... unless of course we want to nurture the 'context is slow' meme) 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] Metafun: is it possible to redefine dotlabel to draw a square ?
On 12/10/2020 6:44 PM, Aditya Mahajan wrote: On Thu, 10 Dec 2020, Otared Kavian wrote: Hi all, In Metafun when representing a point I woul dlike to have some dots represented by a square (or even by another scalable symbol): for instance in the following I would like the dot at the point B to be a square: \starttext \startMPcode draw (2cm,3cm) -- (3cm,5cm) ; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) withpen pencircle scaled 12pt withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) withpen pencircle scaled 12pt withcolor transparent("exclusion",.5,red) ; \stopMPcode \stoptext I wonder whether it is possible to define something like « drawsquaredot » or « squaredotlabel » in order to do this. dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather than a path. Here is a (to me) simpler definition, where you can change the shape: just look in the pdf ... in your case the dot is a n point path while otherwise it uses the default postscript pen (which is a dot) actually fullcircle is pencircle so you can ponder why that is the case -) \startMPdefinitions newpath dotlabelshape; dotlabelshape := fullcircle; vardef dotlabel@#(expr s,z) text t_ = label@#(s,z) t_ ; fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_; enddef ; \stopMPdefinitions \starttext \startMPcode newpath p ; p := (2cm, 3cm) -- (3cm, 5cm); dotlabeldiam := 12pt; % Default draw p; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) withcolor transparent("exclusion",.5,red) ; % Using a square "dot" p := p shifted (5cm, 0); dotlabelshape := fullsquare; draw p; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) withcolor transparent("exclusion",.5,red) ; \stopMPcode \stoptext These types of macros are also a good candidate for the new LMTX syntax, where we can make all components configurable via a key-value interface (labeldistance etc. as well). it surprised me that a math guru like you doesn't do this: vardef dotlabel@#(expr s,z) text t_ = % draw textext("$\bullet$") scaled (1/2) shifted z ; % draw textext("$\blacktriangle$") scaled (1/4) shifted z ; draw textext("$\blacksquare$") scaled (1/4) shifted z ; label@#(s,z) t_ ; enddef ; \stopMPdefinitions - 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] Metafun: is it possible to redefine dotlabel to draw a square ?
On Thu, 10 Dec 2020, Otared Kavian wrote: > Hi Aditya, > Thank you very much ! > That's great indeed, you gave me an elegant solution. > > One more question, in order for me to understand a little more: when defining > a new dotlabel as you do, might it not conflict with the internal definitions > of dotlabel in Metafun in some other place? > Maybe it is safer for me to call it something like « dotshapelabel » ? In general, I agree. Redefining internal macros has the advantage that your code doesn't have to change. See, for example: https://github.com/adityam/mp-sketch/blob/master/mp-sketch.mp 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] Metafun: is it possible to redefine dotlabel to draw a square ?
Hi Aditya, Thank you very much ! That's great indeed, you gave me an elegant solution. One more question, in order for me to understand a little more: when defining a new dotlabel as you do, might it not conflict with the internal definitions of dotlabel in Metafun in some other place? Maybe it is safer for me to call it something like « dotshapelabel » ? Best regards and agin many thanks: Otared > On 10 Dec 2020, at 18:44, Aditya Mahajan wrote: > > On Thu, 10 Dec 2020, Otared Kavian wrote: > >> Hi all, >> >> In Metafun when representing a point I woul dlike to have some dots >> represented by a square (or even by another scalable symbol): for instance >> in the following I would like the dot at the point B to be a square: >> >> \starttext >> \startMPcode >> draw (2cm,3cm) -- (3cm,5cm) ; >> dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) >> withpen pencircle scaled 12pt >> withcolor transparent("exclusion",.5,red) ; >> >> dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) >> withpen pencircle scaled 12pt >> withcolor transparent("exclusion",.5,red) ; >> \stopMPcode >> \stoptext >> >> I wonder whether it is possible to define something like « drawsquaredot » >> or « squaredotlabel » in order to do this. > > dotlabel uses a pen to draw the dot, and I am not sure why it uses that > rather than a path. Here is a (to me) simpler definition, where you can > change the shape: > > \startMPdefinitions > newpath dotlabelshape; > > dotlabelshape := fullcircle; > > vardef dotlabel@#(expr s,z) text t_ = >label@#(s,z) t_ ; >fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_; > enddef ; > \stopMPdefinitions > > \starttext > \startMPcode > newpath p ; > p := (2cm, 3cm) -- (3cm, 5cm); > dotlabeldiam := 12pt; > > % Default > draw p; > dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) >withcolor transparent("exclusion",.5,red) ; > > dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) >withcolor transparent("exclusion",.5,red) ; > > % Using a square "dot" > p := p shifted (5cm, 0); > dotlabelshape := fullsquare; > > draw p; > dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) >withcolor transparent("exclusion",.5,red) ; > > dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) >withcolor transparent("exclusion",.5,red) ; > \stopMPcode > \stoptext > > These types of macros are also a good candidate for the new LMTX syntax, > where we can make all components configurable via a key-value interface > (labeldistance etc. as well). > > 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] Metafun: is it possible to redefine dotlabel to draw a square ?
On Thu, 10 Dec 2020, Otared Kavian wrote: > Hi all, > > In Metafun when representing a point I woul dlike to have some dots > represented by a square (or even by another scalable symbol): for instance in > the following I would like the dot at the point B to be a square: > > \starttext > \startMPcode > draw (2cm,3cm) -- (3cm,5cm) ; > dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) > withpen pencircle scaled 12pt > withcolor transparent("exclusion",.5,red) ; > > dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) > withpen pencircle scaled 12pt > withcolor transparent("exclusion",.5,red) ; > \stopMPcode > \stoptext > > I wonder whether it is possible to define something like « drawsquaredot » or > « squaredotlabel » in order to do this. dotlabel uses a pen to draw the dot, and I am not sure why it uses that rather than a path. Here is a (to me) simpler definition, where you can change the shape: \startMPdefinitions newpath dotlabelshape; dotlabelshape := fullcircle; vardef dotlabel@#(expr s,z) text t_ = label@#(s,z) t_ ; fill (dotlabelshape scaled 2dotlabeldiam) shifted z t_; enddef ; \stopMPdefinitions \starttext \startMPcode newpath p ; p := (2cm, 3cm) -- (3cm, 5cm); dotlabeldiam := 12pt; % Default draw p; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) withcolor transparent("exclusion",.5,red) ; % Using a square "dot" p := p shifted (5cm, 0); dotlabelshape := fullsquare; draw p; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), point 0 of p) withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), point 1 of p) withcolor transparent("exclusion",.5,red) ; \stopMPcode \stoptext These types of macros are also a good candidate for the new LMTX syntax, where we can make all components configurable via a key-value interface (labeldistance etc. as well). 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 ___
[NTG-context] Metafun: is it possible to redefine dotlabel to draw a square ?
Hi all, In Metafun when representing a point I woul dlike to have some dots represented by a square (or even by another scalable symbol): for instance in the following I would like the dot at the point B to be a square: \starttext \startMPcode draw (2cm,3cm) -- (3cm,5cm) ; dotlabel(textext("\switchtobodyfont[8pt]" & "A"), (2cm,3cm)) withpen pencircle scaled 12pt withcolor transparent("exclusion",.5,red) ; dotlabel(textext("\switchtobodyfont[8pt]" & "B"), (3cm,5cm)) withpen pencircle scaled 12pt withcolor transparent("exclusion",.5,red) ; \stopMPcode \stoptext I wonder whether it is possible to define something like « drawsquaredot » or « squaredotlabel » in order to do this. If I use for B the command withpen pensquare scaled 12pt then the dot is a square, but the label B is drawn in a strange way. Thanks for any help: Otared ___ 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 draw a straight line past the end points
On 12/9/2020 9:38 PM, Aditya Mahajan wrote: Or just redefine shortened to accept a pair! \startMPdefinitions primarydef p shortened d = reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart paired(d) ) enddef ; \stopMPdefinitions patched but then also: primarydef p enlonged len = begingroup if len == 0 : p elseif pair p : ... in order to save some energy when one is zero 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] Metafun: how to draw a straight line past the end points
Thanks Aditya! One can learn a lot with your answers ! In the Metafun manual I see enlonged but I did not know to use it. Best regards: Otared > On 9 Dec 2020, at 21:38, Aditya Mahajan wrote: > > On Wed, 9 Dec 2020, Otared Kavian wrote: > >> Hi Aditya, >> >> Thanks for the alternative method, which comes handy if one wishes to extend >> the straight line by a different amount at either end: >> >> \starttext >> \startMPcode >> z1 = (1cm,3cm) ; >> z2 = (5cm, 9cm) ; >> z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ; >> z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ; >> draw z1 -- z3 ; >> draw z4 -- z1 ; >> draw z1 -- z2 withcolor red ; >> \stopMPcode >> \stoptext > > Or just redefine shortened to accept a pair! > > \startMPdefinitions > primarydef p shortened d = >reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart > paired(d) ) > enddef ; > \stopMPdefinitions > > > > \starttext > \startMPpage > z1 = (1cm,3cm) ; > z2 = (5cm, 9cm) ; > draw (z1--z2) shortened (-1cm,-2cm) withcolor blue ; > draw (z1--z2) withcolor red ; > > \stopMPpage > \stoptext > > Now that if you really want to shorten a path, then cutends works better than > shortened > > \startMPdefinitions > primarydef p shortened d = >reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart > paired(d) ) > enddef ; > \stopMPdefinitions > > > \starttext > \startMPpage > z1 = (1cm,3cm) ; > z2 = (5cm, 9cm) ; > path p, q; > p := z1 {up} .. {right} z2; > q := p shifted (6cm, 0); > > draw p withcolor red ; > draw p shortened (1cm,2cm) withcolor blue ; > > draw q withcolor green ; > draw q cutends (1cm,2cm) withcolor blue ; > > \stopMPpage > \stoptext > > 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] Metafun: how to draw a straight line past the end points
On Wed, 9 Dec 2020, Otared Kavian wrote: > Hi Aditya, > > Thanks for the alternative method, which comes handy if one wishes to extend > the straight line by a different amount at either end: > > \starttext > \startMPcode >z1 = (1cm,3cm) ; >z2 = (5cm, 9cm) ; >z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ; >z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ; >draw z1 -- z3 ; >draw z4 -- z1 ; >draw z1 -- z2 withcolor red ; > \stopMPcode > \stoptext Or just redefine shortened to accept a pair! \startMPdefinitions primarydef p shortened d = reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart paired(d) ) enddef ; \stopMPdefinitions \starttext \startMPpage z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; draw (z1--z2) shortened (-1cm,-2cm) withcolor blue ; draw (z1--z2) withcolor red ; \stopMPpage \stoptext Now that if you really want to shorten a path, then cutends works better than shortened \startMPdefinitions primarydef p shortened d = reverse ( ( reverse (p enlonged -xpart paired(d)) ) enlonged -ypart paired(d) ) enddef ; \stopMPdefinitions \starttext \startMPpage z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; path p, q; p := z1 {up} .. {right} z2; q := p shifted (6cm, 0); draw p withcolor red ; draw p shortened (1cm,2cm) withcolor blue ; draw q withcolor green ; draw q cutends (1cm,2cm) withcolor blue ; \stopMPpage \stoptext 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] Metafun: how to draw a straight line past the end points
Hi Aditya, Thanks for the alternative method, which comes handy if one wishes to extend the straight line by a different amount at either end: \starttext \startMPcode z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; z3 = 1cm * dir(angle (z2 - z1)) shifted z2 ; z4 = -.5cm*dir(angle(z2 - z1)) shifted z1 ; draw z1 -- z3 ; draw z4 -- z1 ; draw z1 -- z2 withcolor red ; \stopMPcode \stoptext Best regards: Otared > On 9 Dec 2020, at 18:37, Aditya Mahajan wrote: > > On Wed, 9 Dec 2020, Otared Kavian wrote: > >> Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun >> is ! > > Or, if you want to use high school algebra: > > \starttext > \startMPcode >z1 = (1cm,3cm) ; >z2 = (5cm, 9cm) ; >z3 = 1cm * dir(angle (z2 - z1)) shifted z2; >draw z1 -- z3 ; >draw z1 -- z2 withcolor red; > \stopMPcode > \stoptext > > 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] Metafun: how to draw a straight line past the end points
On Wed, 9 Dec 2020, Otared Kavian wrote: > Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun is > ! Or, if you want to use high school algebra: \starttext \startMPcode z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; z3 = 1cm * dir(angle (z2 - z1)) shifted z2; draw z1 -- z3 ; draw z1 -- z2 withcolor red; \stopMPcode \stoptext 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] Metafun: how to draw a straight line past the end points
Hi Fabrice, Thanks a lot ! Indeed that does the job, which shows how wonderful Metafun is ! Best regards: Otared > On 9 Dec 2020, at 17:19, Fabrice L wrote: > > Hi, > >> Le 9 déc. 2020 à 10:57, Otared Kavian a écrit : >> >> Hi, >> >> I have a silly question: given two points in the plane >> z1 = (1cm,3cm) ; >> z2 = (5cm, 9cm) ; >> the command >> draw z1 -- z2 withpen pencircle scaled .5pt ; >> draws the line segment joining z1 and z2. How could I draw the line segment >> which goes a little further (say 1cm) than both the end points of this >> segment (that is in this example, a point before z1 and a point after z2 on >> the straight line) . >> Indeed it is possible to write the equation of the line and then compute by >> hand the coordinates of the new end points, but I think there is a simpler >> way in Metafun to do this. > > The shortened operation is the solution ! See MetaFun manual section 1.18 > > \starttext > \startMPpage > z1 = (1cm,3cm) ; > z2 = (5cm, 9cm) ; > draw (z1--z2) shortened -1cm withcolor blue ; > draw (z1--z2) withcolor red ; > > \stopMPpage > \stoptext > > Fabrice. > >> >> Thanks for any help: Otared >> >> >> ___ >> 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] Metafun: how to draw a straight line past the end points
Hi, > Le 9 déc. 2020 à 10:57, Otared Kavian a écrit : > > Hi, > > I have a silly question: given two points in the plane > z1 = (1cm,3cm) ; > z2 = (5cm, 9cm) ; > the command > draw z1 -- z2 withpen pencircle scaled .5pt ; > draws the line segment joining z1 and z2. How could I draw the line segment > which goes a little further (say 1cm) than both the end points of this > segment (that is in this example, a point before z1 and a point after z2 on > the straight line) . > Indeed it is possible to write the equation of the line and then compute by > hand the coordinates of the new end points, but I think there is a simpler > way in Metafun to do this. The shortened operation is the solution ! See MetaFun manual section 1.18 \starttext \startMPpage z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; draw (z1--z2) shortened -1cm withcolor blue ; draw (z1--z2) withcolor red ; \stopMPpage \stoptext Fabrice. > > Thanks for any help: Otared > > > ___ > 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: how to draw a straight line past the end points
Hi, I have a silly question: given two points in the plane z1 = (1cm,3cm) ; z2 = (5cm, 9cm) ; the command draw z1 -- z2 withpen pencircle scaled .5pt ; draws the line segment joining z1 and z2. How could I draw the line segment which goes a little further (say 1cm) than both the end points of this segment (that is in this example, a point before z1 and a point after z2 on the straight line) . Indeed it is possible to write the equation of the line and then compute by hand the coordinates of the new end points, but I think there is a simpler way in Metafun to do this. Thanks for any help: Otared ___ 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 2
On Sun, 8 Sep 2019, Otared Kavian wrote: Hi Aditya, I wanted also to point out a typo on that page (two occurrences), namely "ploles" instead of "poles", in the explanations before the actual code. Thanks. Fixed. 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] metafun 2
Hi Aditya, As usual you show us a very nice and very clear example to taech nice features of ConTeXt: thank you so much! I wanted also to point out a typo on that page (two occurrences), namely "ploles" instead of "poles", in the explanations before the actual code. Best regard: > On 8 Sep 2019, at 10:42, Aditya Mahajan wrote: > > On Wed, 14 Aug 2019, Hans Hagen wrote: > >> Hi, >> >> In the process of providing an additional (more abstract) interface to some >> of the old and also new MetaFun code we wonder what kind of features users >> would like to see. >> >> http://www.pragma-ade.com/general/magazines/mag-1104-mkiv.pdf > > Finally got around to playing around with the new interface. Here is an > example of how to define new key-value driven macros in metapost: > > https://adityam.github.io/context-blog/post/new-metafun-interface/ > > 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] metafun 2
On Wed, 14 Aug 2019, Hans Hagen wrote: Hi, In the process of providing an additional (more abstract) interface to some of the old and also new MetaFun code we wonder what kind of features users would like to see. http://www.pragma-ade.com/general/magazines/mag-1104-mkiv.pdf Finally got around to playing around with the new interface. Here is an example of how to define new key-value driven macros in metapost: https://adityam.github.io/context-blog/post/new-metafun-interface/ 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] metafun 2
Thanks a lot for the new features. In my system this code don’t work. macOS Mojave This is LuaMetaTeX, Version 2.00.0 open source > level 1, order 1, name 'cont-yes.mkiv' system > system > ConTeXt ver: 2019.08.17 12:16 MKIV beta fmt: 2019.8.19 int: English/English \startMPcode{doublefun} draw lmt_function [ xmin = 0, xmax = 10, xstep = .05, ymin = -2, ymax = 2, xticks = "bottom", xsmall = 80, xlarge = 20, yticks = "left", ysmall = 40, ylarge = 4, code = "1.5 * math.cosd(240 * math.sqrt(x))", xlabels = "yes", ylabels = "yes", ycaption = "\strut\tfd \rotate[rotation=90]{vertical}", xcaption = "\strut\tfd horizontal", pointsymbol = "dot", pointsize = 4, pointcolor = "orange", sx = 2mm, sy = 4mm, linewidth = .025mm, offset = .1mm, ] xsized 8cm ; \stopMPcode The output error: loading metafun, including plain.mp version 1.004 for metafun iv and xl pages > flushing realpage 9, userpage 8, subpage 9 metapost log> ! Missing ':' has been inserted. metapost log> metapost log>addto metapost log> draw->addto metapost log> .currentpicture.if.picture(EXPR0):also(EXPR0)else:doublepath(EXPR… ___ 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 2
Hi Hans, Alan, This is really cool! Not sure how I missed this feature, works exactly for my use-case. Thanks a lot for pointing this out, I was able to find it in the MAPS as well. Cheers, Adam On Sat, Aug 17, 2019 at 9:52 AM Hans Hagen wrote: > On 8/17/2019 3:27 AM, Alan Braslau wrote: > > We have eofill in MP (in pdf/ps in fact) and that likely will do what > you need. > You forgot the MWD (Minimal Working Demo): > > \starttext > > \startMPpage > path p ; p := fullcircle scaled 1cm ; > path q ; q := fullcircle scaled .5cm ; > > nofill p ; > eofill q ; > \stopMPpage > > \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] metafun 2
On 8/17/2019 3:27 AM, Alan Braslau wrote: We have eofill in MP (in pdf/ps in fact) and that likely will do what you need. You forgot the MWD (Minimal Working Demo): \starttext \startMPpage path p ; p := fullcircle scaled 1cm ; path q ; q := fullcircle scaled .5cm ; nofill p ; eofill q ; \stopMPpage \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] metafun 2
We have eofill in MP (in pdf/ps in fact) and that likely will do what you need. Alan On Sat, 17 Aug 2019 00:31:38 +0100 Adam Reviczky wrote: > Hi Hans, > > One MetaPost feature that I was looking forward to is the ability to create > a fill between two shapes. > Something like a difference function of two path's. > > For logos I use the workaround with creating a path alongside the excluded > areas but it is always cumbersome. > > I have briefly mentioned it back here: > https://mailman.ntg.nl/pipermail/ntg-context/2011/056910.html > > Just for illustration purposes, if I wanted to fill the area in between two > circles: > > *path p ; > **p := fullcircle scaled 1cm ; > **path q ; > **q := fullcircle scaled .5cm ; > * > > Instead of creating a new path along both circles with: > > > *r := p -- reverse q -- cycle ;* > > It would be nice to have something like: > > *fill p excluding q ;* > > or something like that. > > I mainly have use-cases for differences in shapes, but filling the > intersection of two shapes would be the same idea. > > Thanks, > Adam > > > On Wed, Aug 14, 2019 at 10:57 AM Hans Hagen wrote: > > > Hi, > > > > In the process of providing an additional (more abstract) interface to > > some of the old and also new MetaFun code we wonder what kind of > > features users would like to see. > > > > http://www.pragma-ade.com/general/magazines/mag-1104-mkiv.pdf > > > > As a teaser I uploaded a MyWay document that shows some of what is > > coming. All is experimental but it shows the direction. We're talking > > ConTeXt LMTX here. For instance, > > > > draw lmt_outline [ > > content = "hello", > > kind = "reverse", > > fillcolor = "darkred", > > drawcolor = "darkblue", > > rulethickness = 1/2, > > ] ysized h shifted (3.75h,-1.25h) ; > > > > Wraps all the outline drawing in one macro with a set of options (there > > will be xml interface definitions for that). Or take: > > > > draw lmt_followtext [ > > content = "How well does it work {\bf 1}! ", > > path= (fullcircle scaled 4cm), > > trace = true, > > spread = true, > > ] ysized 5cm ; > > > > which is an easier interface to text along a curve. Arrows can be drawn > > with > > > > draw lmt_arrow [ > > kind= "draw", > > location= "middle", > > alternative = "curved", > > path= fullcircle > > scaled 3cm > > shifted (3.5cm,0cm), > > ] withcolor "darkblue" ; > > > > but of course the low level interface with its many variables for > > tweaking stays around. Other examples are shown in the mentioned document. > > > > So the question is: What do you miss in metapost support? Of course it > > should fit within the concept, so 'artistic freehand drawings' is not > > something that is likely to get interfaced. We are particularly > > interested in educational applications, if only because ConTeXt started > > out that way. > > > > 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 > > > > ___ > > ___ 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 2
Hi Hans, One MetaPost feature that I was looking forward to is the ability to create a fill between two shapes. Something like a difference function of two path's. For logos I use the workaround with creating a path alongside the excluded areas but it is always cumbersome. I have briefly mentioned it back here: https://mailman.ntg.nl/pipermail/ntg-context/2011/056910.html Just for illustration purposes, if I wanted to fill the area in between two circles: *path p ; **p := fullcircle scaled 1cm ; **path q ; **q := fullcircle scaled .5cm ; * Instead of creating a new path along both circles with: *r := p -- reverse q -- cycle ;* It would be nice to have something like: *fill p excluding q ;* or something like that. I mainly have use-cases for differences in shapes, but filling the intersection of two shapes would be the same idea. Thanks, Adam On Wed, Aug 14, 2019 at 10:57 AM Hans Hagen wrote: > Hi, > > In the process of providing an additional (more abstract) interface to > some of the old and also new MetaFun code we wonder what kind of > features users would like to see. > > http://www.pragma-ade.com/general/magazines/mag-1104-mkiv.pdf > > As a teaser I uploaded a MyWay document that shows some of what is > coming. All is experimental but it shows the direction. We're talking > ConTeXt LMTX here. For instance, > > draw lmt_outline [ > content = "hello", > kind = "reverse", > fillcolor = "darkred", > drawcolor = "darkblue", > rulethickness = 1/2, > ] ysized h shifted (3.75h,-1.25h) ; > > Wraps all the outline drawing in one macro with a set of options (there > will be xml interface definitions for that). Or take: > > draw lmt_followtext [ > content = "How well does it work {\bf 1}! ", > path= (fullcircle scaled 4cm), > trace = true, > spread = true, > ] ysized 5cm ; > > which is an easier interface to text along a curve. Arrows can be drawn > with > > draw lmt_arrow [ > kind= "draw", > location= "middle", > alternative = "curved", > path= fullcircle > scaled 3cm > shifted (3.5cm,0cm), > ] withcolor "darkblue" ; > > but of course the low level interface with its many variables for > tweaking stays around. Other examples are shown in the mentioned document. > > So the question is: What do you miss in metapost support? Of course it > should fit within the concept, so 'artistic freehand drawings' is not > something that is likely to get interfaced. We are particularly > interested in educational applications, if only because ConTeXt started > out that way. > > 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 > > ___ > ___ 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 ___