Re: [NTG-context] metafun paralleled does not give a parallel path

2022-08-25 Thread Fabrice L via ntg-context
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  \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
___


Re: [NTG-context] Metafun : save memory content ?

2022-07-19 Thread Fabrice L via ntg-context
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 ?

2022-07-18 Thread Fabrice L via ntg-context

> 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 exter

[NTG-context] Metafun : save memory content ?

2022-07-18 Thread 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).

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
___


Re: [NTG-context] MetaPost label font size

2022-07-06 Thread Fabrice L via ntg-context


> Le 5 juill. 2022 à 19:00, Henning Hraban Ramm via ntg-context 
>  a écrit :
> 
> How can I change the font size of labels within one picture?
> 
> Hraban
> 
> \startMPpage
> defaultfont := "\truefontname{Sans}";
> defaultfontsize := \the\bodyfontsize;
> 
> label.top(defaultfontsize, (0,0));
> 
> defaultfontsize := 4bp;
> 
> label.top(defaultfontsize, (50,0));
> % shows that the variable changed,
> % but font size is the same
> 
> \stopMPpage

Here are slightly different syntax that could be useful perhaps ? In the second 
one, the scaled parameter can be replaced easily with a variable, so you can 
decide and change the size of the label during the course of a picture.

\starttext

\startMPpage
defaultfont := "\truefontname{Sans}";
defaultfontsize := \the\bodyfontsize;

defaultscale := 0.5;
label.top("small label", (-10,0));

defaultscale := 1.0;
label.top("normal label", (50,5));
label.top("another normal label", (50,-5));

defaultscale := 2.0;
label.top("Huge label", (10,-25));

\stopMPpage

\startMPpage

 draw textext.top("small label") scaled 0.5 
shifted (-10,0) ;
 draw textext.top("normal label") scaled 1 
shifted (50,5) ;
 draw textext.top("second normal label") scaled 1 
shifted (50,-5) ;
 draw textext.top("Huge label") scaled 2 
shifted (10,-25) ;

\stopMPpage

\stoptext

Fabrice.


___
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] Importing pdf into MPpage

2022-06-11 Thread Fabrice L via ntg-context


> Le 11 juin 2022 à 11:30, Stefan Nedeljkovic  a écrit :
> 
> That's it, but how do I center it on (0, 0)?

Sorry, I misunderstood the question. Here is a solution (perhaps there is a 
simpler solution !):

\startMPpage
picture TheImage ; 
TheImage := image(
draw externalfigure "cow.pdf";
);
TheImage := TheImage shifted -center(TheImage);
draw TheImage ;
draw (0,0) withpen pencircle scaled .2in withcolor magenta ;
\stopMPpage

Fabrice.

> 
> On Sat, Jun 11, 2022 at 4:46 PM Fabrice L  > wrote:
> Dear Stephan,
> 
>> Le 11 juin 2022 à 08:57, Stefan Nedeljkovic via ntg-context 
>> mailto:ntg-context@ntg.nl>> a écrit :
>> 
>> Dear list,
>> 
>> I would like to place a pdf file at (0, 0), centered at original size on a 
>> MPpage, and draw over it. But using the input command doesn't work. How 
>> should I approach this?
> 
> Like this ?
> 
> \startMPpage
>draw externalfigure "thefile.pdf";
>(… other commands…) 
> \stopMPpage
> 
> 
>> 
>> Sincerely,
>> Stefan
> 
> Fabrice.
> 
>> ___
>> 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] Importing pdf into MPpage

2022-06-11 Thread Fabrice L via ntg-context
Dear Stephan,

> Le 11 juin 2022 à 08:57, Stefan Nedeljkovic via ntg-context 
>  a écrit :
> 
> Dear list,
> 
> I would like to place a pdf file at (0, 0), centered at original size on a 
> MPpage, and draw over it. But using the input command doesn't work. How 
> should I approach this?

Like this ?

\startMPpage
   draw externalfigure "thefile.pdf";
   (… other commands…) 
\stopMPpage


> 
> Sincerely,
> Stefan

Fabrice.

> ___
> 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] Problem with a defined colour in MetaFun

2022-04-28 Thread Fabrice L via ntg-context
Sorry, I was a little too enthusiastic, here here is the code :

> Le 28 avr. 2022 à 08:41, Fabrice L  a écrit :
> 
> Hi Keith,
> 
>> Le 28 avr. 2022 à 06:05, Keith McKay via ntg-context > > a écrit :
>> 
>> Hi,
>> 
>> In the MWE below I define an rgb colour, myColor1, using random numbers for 
>> the r, g and b components. I then use it to fill a unitsquare the size of 
>> the page, which works as expected. In the loop that follows I then use the 
>> defined colour, myColor1, along with white and the variable r to create 
>> shades of myColor1 as in the MWE below. However, myColor1 is not recognised 
>> in the loop and seems to be replaced by black, although if I use a 
>> predefined colour, in this case BurntSienna from the crayola collection, it 
>> works as expected.  I have tried a number of ways to get this to work as 
>> shown in the code but without success. I would be grateful for any 
>> suggestions.
>> 
>> Best Wishes
>> 
>> Keith McKay
>> 
>> MWE%
>> \setuppapersize[A4,portrait]
>> \usecolors[crayola]
>> \starttext
>> \dorecurse{10}{
>> \startMPpage
>> StartPage;
>> \definecolor[name="myColor1", r =  uniformdeviate(1), g = uniformdeviate(1), 
>> b = uniformdeviate(1) ] ;
>> fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor  "myColor1";
>> for i =2 step 2 until 10:
>> r := i/10;
>> fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) 
>> withcolor(r[\MPcolor{BurntSienna},white]);
>> fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
>> withcolor(r[\MPcolor{myColor1}, white]);
>> fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
>> withcolor(r[\MPcolor{"myColor1"}, white]);
>> %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
>> withcolor(r[myColor1 ,  white]); This line causes an error.
>> endfor;
>> StopPage;
>> \stopMPpage
>> }
>> 
>> \stoptext
>> %%%end MWE%%%
>> 
> 
> Here is a solution, with works here, defining in another way the color «  
> myColor »:
> 
> \setuppapersize[A4,portrait]
> \usecolors[crayola]
> \starttext
> \dorecurse{2}{
> \startMPpage
> StartPage;
> color myColor ;
> myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
> fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor;
> for i =2 step 2 until 10:
> r := i/10;
> fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) 
> withcolor(r[\MPcolor{BurntSienna},white]);
> fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
> withcolor(r[\MPcolor{myColor1}, white]);
> fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
> withcolor(r[\MPcolor{"myColor1"}, white]);
> %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
> withcolor(r[myColor1 ,  white]); This line causes an error.
> endfor;
> StopPage;
> \stopMPpage
> }
> 
> \stoptext

I forgot to remove « myColor1 » from the others parts of the code. 
\setuppapersize[A4,portrait]
\usecolors[crayola]
\starttext
\dorecurse{10}{
\startMPpage
StartPage;
color myColor ;
myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor;
for i =2 step 2 until 10:
r := i/10;
fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) 
withcolor(r[\MPcolor{BurntSienna},white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
withcolor(r[myColor, white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
withcolor(r[myColor, white]);
%fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
withcolor(r[myColor1 ,  white]); This line causes an error.
endfor;
StopPage;
\stopMPpage
}

\stoptext


> 
> Fabrice.
>> 
>> 
>> ___
>> 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] Problem with a defined colour in MetaFun

2022-04-28 Thread Fabrice L via ntg-context
Hi Keith,

> Le 28 avr. 2022 à 06:05, Keith McKay via ntg-context  a 
> écrit :
> 
> Hi,
> 
> In the MWE below I define an rgb colour, myColor1, using random numbers for 
> the r, g and b components. I then use it to fill a unitsquare the size of the 
> page, which works as expected. In the loop that follows I then use the 
> defined colour, myColor1, along with white and the variable r to create 
> shades of myColor1 as in the MWE below. However, myColor1 is not recognised 
> in the loop and seems to be replaced by black, although if I use a predefined 
> colour, in this case BurntSienna from the crayola collection, it works as 
> expected.  I have tried a number of ways to get this to work as shown in the 
> code but without success. I would be grateful for any suggestions.
> 
> Best Wishes
> 
> Keith McKay
> 
> MWE%
> \setuppapersize[A4,portrait]
> \usecolors[crayola]
> \starttext
> \dorecurse{10}{
> \startMPpage
> StartPage;
> \definecolor[name="myColor1", r =  uniformdeviate(1), g = uniformdeviate(1), 
> b = uniformdeviate(1) ] ;
> fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor  "myColor1";
> for i =2 step 2 until 10:
> r := i/10;
> fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) 
> withcolor(r[\MPcolor{BurntSienna},white]);
> fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
> withcolor(r[\MPcolor{myColor1}, white]);
> fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
> withcolor(r[\MPcolor{"myColor1"}, white]);
> %fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
> withcolor(r[myColor1 ,  white]); This line causes an error.
> endfor;
> StopPage;
> \stopMPpage
> }
> 
> \stoptext
> %%%end MWE%%%
> 

Here is a solution, with works here, defining in another way the color «  
myColor »:

\setuppapersize[A4,portrait]
\usecolors[crayola]
\starttext
\dorecurse{2}{
\startMPpage
StartPage;
color myColor ;
myColor := (uniformdeviate(1),uniformdeviate(1),uniformdeviate(1));
fill unitsquare xscaled PaperWidth yscaled PaperHeight withcolor myColor;
for i =2 step 2 until 10:
r := i/10;
fill unitsquare xscaled 5cm yscaled .5cm shifted (1cm,i*cm) 
withcolor(r[\MPcolor{BurntSienna},white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (7cm,i*cm) 
withcolor(r[\MPcolor{myColor1}, white]);
fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
withcolor(r[\MPcolor{"myColor1"}, white]);
%fill unitsquare xscaled 5cm yscaled .5cm shifted (13cm,i*cm) 
withcolor(r[myColor1 ,  white]); This line causes an error.
endfor;
StopPage;
\stopMPpage
}

\stoptext

Fabrice.
> 
> 
> ___
> 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] Conditional text appearing in a fixed vertical space

2022-01-11 Thread Fabrice L via ntg-context

> Le 11 janv. 2022 à 17:56, Gavin via ntg-context  a écrit :
> 
> Thanks Hans! This is great. I made a slight change to add an additional 
> feature. By moving the “mysolution” definition out of \startmode[solution], I 
> can now use mysolution in either mode. I’d use this if I want to give my 
> solution to one of the problems, as an example, on the handout.
> 
> -Gavin


I have similar problem for my courses. The solution I use, different than the 
one offered, is to write in a « special » color the text I want to hide from 
the students. This permits me to have hidden texts in figures for exemple. 
Also, I do not calculate space required, this is automated !  Here is MWE :

\enablemode[solution]

\doifmode{solution}{
 \definecolor[solcolor][magenta]
} 
\doifnotmode{solution}{
 \definecolor[solcolor][white]
} 
\definedescription[solution]
[color=solcolor]

\starttext

How many roads? \startcolor[solcolor] Professor note.\stopcolor
 \startsolution
   42 roads.
 \stopsolution

How much wood?
 \startsolution
   Alotta wood!
 \stopsolution

No more questions.

\stoptext

So the color used when solutions are hidden are white on white, we can not see 
the text;  but of course, if you change the background, you see the hidden 
text. So there is another step to the process (I usually do this only once a 
term); open the file in Acrobat, and find the option to delete hidden text. The 
text for which the color is the same as the background is really deleted. You 
can try to select the text in any pdf view/editor, the text is gone !  

Fabrice.


> 
> 
> % \enablemode[solution]
> 
> % Define "mysolution” for use independent of solution mode.
> \definenarrower[mysolution]
>  [before=\blank\it,
>   after=\blank]
> 
> % If in solution mode, define "solution" to use "mysolution"
> \startmode[solution]
>   \tolerant\protected\def\startsolution[#1]%
> {\startmysolution}
>   \protected\def\stopsolution
> {\stopmysolution}
> \stopmode
> 
> % If NOT in solution mode, define "solution" to produce a blank space
> \startnotmode[solution]
>   \tolerant\protected\def\startsolution[#1]%
> {\doifelsenothing{#1}{\blank[1in]}{\blank[#1]}
>  \gobbleuntil\stopsolution}
>   \protected\def\stopsolution
> {}
> \stopnotmode
> 
> 
> \starttext
> 
> How many roads?
>  \startsolution
>42 roads.
>  \stopsolution
> 
> How much wood?
>  \startsolution[1.5in]
>Alotta wood!
>  \stopsolution
> 
> No more questions.
> 
> \stoptext
> 
> 
>> On Jan 11, 2022, at 1:13 PM, Hans Hagen  wrote:
>> 
>> On 1/11/2022 8:50 PM, Gavin via ntg-context wrote:
>>> Hello List,
>>> I am making problem sets for a physics class. Solutions use the style 
>>> defined in the example below, and only appear if the “solution” mode is 
>>> enabled. I am struggling to get a vertical space for the solution which is 
>>> the same whether or not the solution is printed. Different problems require 
>>> different amounts of space, so this should be an argument or key-value.
>>> In the example below, the first solution has the desired behavior. The 
>>> second solution has the syntax I’d like, but it doesn’t make the space 
>>> without a solution.
>>> Any ideas would be welcome! I am still pretty new to ConTeXt, so I struggle 
>>> mixing things like the plain tex \vbox and ConTeXt \start…\stop concepts.
>>> Thanks,
>>> Gavin
>>> \definemode[solution][yes] % yes to enable solutions, no to disable
>>> \definebuffer  [solution] % Captures solution in a buffer that isn't used
>>> \startmode[solution] % If in solution mode, redefine 
>>> \startsolution...\stopsolution
>>> \definedelimitedtext[solution][ % Solution italic and indented
>>>  spacebefore=medium,
>>>  spaceafter=medium,
>>>  style=\rm\it,
>>>  leftmargin=standard, % Indents block on the left
>>>  rightmargin=yes, % Indents block on the right
>>>  indentnext=no,
>>>  before=\vbox to 1in\bgroup,
>>>  after=\egroup,
>>> ]
>>> \stopmode
>>> \starttext
>>> How many roads? (The 1-inch space below appears whether or not it contains 
>>> a solution.)
>>> \vbox to 1in{%
>>>  \startsolution
>>>42 roads.
>>>  \stopsolution
>>> }
>>> How much wood? (I would like to define solution so this to behaves like the 
>>> previous question.)
>>> \startsolution[1in]
>>>  Alotta wood!
>>> \stopsolution
>>> No more questions.
>>> \stoptext
>> a mix between big and low level
>> 
>> % \enablemode[solution]
>> 
>> \startmode[solution] % If in solution mode, redefine 
>> \startsolution...\stopsolution
>> 
>>   \definenarrower
>> [mysolution]
>> [before=\blank,
>>  after=\blank]
>> 
>>   \tolerant\protected\def\startsolution[#1]%
>> {\startmysolution
>>  \it}
>> 
>>   \protected\def\stopsolution
>> {\stopmysolution}
>> 
>> \stopmode
>> 
>> \startnotmode[solution] % If in solution mode, redefine 
>> \startsolution...\stopsolution
>> 
>>   \tolerant\protected\def\startsolution[#1]%
>> {\doifelsenothing{#1}{\blank[2.5cm]}{\blank[#1]}
>>  \gobbleuntil\stopsolution}
>> 
>>   

Re: [NTG-context] Documentation about CTX installation on MacOS X

2022-01-02 Thread Fabrice L via ntg-context
Hi,

> Le 2 janv. 2022 à 21:26, Jean-Pierre Delange via ntg-context 
>  a écrit :
> 
> First of all : Happy New Year everybody (despite some difficulties due to 
> public policies against the epidemic !
> 
> Now my question : I want to try CTX (ConTeXt  ver: 2021.12.30) on MacOS X 
> (currently 10.13  High Sierra), while I was formerly working with old 
> versions on Linux and Windows based systems. Among other difficulties (like 
> how to export OSFONDIR permanently), I don’t find the clever command . 
> setuptex, which made possible a bunch of other commands (like context —make 
> and context —generate). Even if a lot of things on MacOS X seem to share with 
> Unix-like systems, I am looking for detailed documentation concerning a well 
> done installation of CTX on MacOS X. 
> Thank you very much for your help !
> JP  

On MacOS, I usually follow with success this page of the wiki :
https://wiki.contextgarden.net/Installing_ConTeXt_LMTX_on_MacOS

Regarding modules, on MacOS, the script described here (again on the wiki) 
works well for me:
https://wiki.contextgarden.net/Modules#ConTeXt_LMTX

Finally, I use TexPad as my context/metafun editor, and if you need some help 
to set it up, I can describe my setup in details. 
Fabrice.



> 
> ___
> 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] MP: problem connecting paths.

2021-12-20 Thread Fabrice L via ntg-context
Dear Mikael,

> Le 20 déc. 2021 à 12:14, Mikael Sundqvist  a écrit :
> 
> Hi,
> 
> I will try again. What if you do
> 
> newcircleA := newcircleA scrutinized 2;
> 
> after your definition of newcircleA?

Once I understood I had to compile with LMTX, this works like magic ! I spent 
hours to find a solution… but here is a solution ! 
Thanks a lot ! 
> 
> /Mikael

Fabrice.
> 
> 
> On Mon, Dec 20, 2021 at 3:45 PM Fabrice L  wrote:
>> 
>> Thanks Mikael,
>> 
>> Le 20 déc. 2021 à 02:21, Mikael Sundqvist via ntg-context 
>>  a écrit :
>> 
>> Hi,
>> 
>> would it be an option for you to do
>> 
>> newcircleA := circleA cutbefore P1 cutafter P2 -- cycle ;
>> 
>> In that case you avoid extra points.
>> 
>> 
>> You are right, in this simple case, your solution avoid the problem, and is 
>> applicable in some of my cases (I have to rethink the code). Thanks for the 
>> proposition !
>> But in others cases this is not possible (I think). Imagine I wish to do a « 
>> partial moon » from the two circles in my minimal example (see bottom right 
>> of the attached pdf):
>> 
>> 
>> newcircleA := circleA cutbefore P1 cutafter P2 .. reverse(circleB cutbefore 
>> P1 cutafter P2)  .. cycle;
>> 
>> I need 10 points to define the shape, but as my connections are duplicated, 
>> I have 12 points.
>> 
>> The solution (I thought) would be to use the « & » operator :
>> newcircleA := circleA cutbefore P1 cutafter P2 & reverse(circleB cutbefore 
>> P1 cutafter P2) & cycle ;
>> 
>> But this does not work (same reason as before: "! Paths don't touch; `&' 
>> will be changed to `..'.").
>> 
>> The compete minimal code (if somebody wants to plus with it) is here :
>> 
>> % ———
>> \startMPpage
>> path circleA , circleB ;
>> pair P[];
>> defaultscale := 0.4 ;
>> 
>> circleA := fullcircle scaled 1in randomized 3 ;
>> circleB := fullcircle scaled 1in randomized 3 shifted(0.3in,0.3in) ;
>> 
>> draw circleA withcolor blue ;
>> draw circleB withcolor red ;
>> 
>> P[1] := circleA intersectionpoint circleB ;
>> dotlabel.lft("$P_1$",P[1]) ;
>> dotlabel.rt("$\blue\tfx P_0^A$",point 0 of circleA) ;
>> P[2] := reverse(circleA) intersectionpoint circleB ;
>> dotlabel.rt("$P_2$",P[2]) ;
>> dotlabel.rt("$\red\tfx P_0^B$",point 0 of circleB) ;
>> 
>> path newcircleA , newcircleB ;
>> % newcircleA := (circleA cutbefore P1 cutafter P2 ) & (P2 -- P1) & cycle  ;
>> % previous line gives an error :
>> % "! Paths don't touch; `&' will be changed to `..'."
>> newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle  ;
>> newcircleA := newcircleA xshifted 2in ;
>> draw newcircleA  withcolor darkgreen ;
>> 
>> newcircleB := (circleB cutafter P1)  -- (P1 -- P2) -- (circleB cutbefore P2 
>> ) & cycle ;
>> newcircleB := newcircleB xshifted 2in ;
>> draw newcircleB withcolor black ;
>> drawpoints newcircleA ; drawpointlabels newcircleA ;
>> 
>> % Mikael solution
>> newcircleA := circleA cutbefore P1 cutafter P2 -- cycle ;
>> newcircleA := newcircleA yshifted -1.5in ;
>> draw newcircleA  withcolor darkgreen ;
>> drawpoints newcircleA ; drawpointlabels newcircleA ;
>> 
>> % partial moon
>> newcircleA := circleA cutbefore P1 cutafter P2
>> .. reverse(circleB cutbefore P1 cutafter P2) .. cycle;
>> % & (reverse(circleB) cutbefore P2 cutafter P1) & cycle;
>> newcircleA := newcircleA shifted(2in,-1.5in) ;
>> draw newcircleA  withcolor magenta ;
>> drawpoints newcircleA ; drawpointlabels newcircleA ;
>> 
>> \stopMPpage
>> % ———
>> 
>> Thanks for any help !
>> Fabrice.
>> 
>> 
>> /Mikael
>> 
>> On Mon, Dec 20, 2021 at 5:30 AM Fabrice L via ntg-context
>>  wrote:
>> 
>> 
>> Dear list,
>> 
>> I have a problem connecting path with the operator « & » (page 16 Metafun 
>> manual). The problem is illustrated by the code (and the joined PDF) which 
>> follows.
>> 
>> I draw random cycled  forms (left part of the figure) and when they 
>> interact, they are modified to « fit together » (right part of the figure) . 
>> When building these new forms, I connect paths (usually two or three 
>> depending on position 0 of the path); the last point a path is the same as 
>> the first point of the next path ; for exemple, to modify the blue circle, 
>

Re: [NTG-context] MP: problem connecting paths.

2021-12-20 Thread Fabrice L via ntg-context
Thanks Mikael,Le 20 déc. 2021 à 02:21, Mikael Sundqvist via ntg-context <ntg-context@ntg.nl> a écrit :Hi,would it be an option for you to donewcircleA := circleA cutbefore P1 cutafter P2 -- cycle ;In that case you avoid extra points.You are right, in this simple case, your solution avoid the problem, and is applicable in some of my cases (I have to rethink the code). Thanks for the proposition ! But in others cases this is not possible (I think). Imagine I wish to do a « partial moon » from the two circles in my minimal example (see bottom right of the attached pdf): 

test.pdf
Description: Adobe PDF document
newcircleA := circleA cutbefore P1 cutafter P2 .. reverse(circleB cutbefore P1 cutafter P2)  .. cycle; I need 10 points to define the shape, but as my connections are duplicated, I have 12 points. The solution (I thought) would be to use the « & » operator :newcircleA := circleA cutbefore P1 cutafter P2 & reverse(circleB cutbefore P1 cutafter P2) & cycle ; But this does not work (same reason as before: "! Paths don't touch; `&' will be changed to `..'."). The compete minimal code (if somebody wants to plus with it) is here :% ———\startMPpagepath circleA , circleB ;pair P[];defaultscale := 0.4 ;circleA := fullcircle scaled 1in randomized 3 ;circleB := fullcircle scaled 1in randomized 3 shifted(0.3in,0.3in) ;draw circleA withcolor blue ;draw circleB withcolor red ;P[1] := circleA intersectionpoint circleB ;dotlabel.lft("$P_1$",P[1]) ;dotlabel.rt("$\blue\tfx P_0^A$",point 0 of circleA) ;P[2] := reverse(circleA) intersectionpoint circleB ;dotlabel.rt("$P_2$",P[2]) ;dotlabel.rt("$\red\tfx P_0^B$",point 0 of circleB) ;path newcircleA , newcircleB ;% newcircleA := (circleA cutbefore P1 cutafter P2 ) & (P2 -- P1) & cycle  ;% previous line gives an error :% "! Paths don't touch; `&' will be changed to `..'."newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle  ;newcircleA := newcircleA xshifted 2in ;draw newcircleA  withcolor darkgreen ;newcircleB := (circleB cutafter P1)  -- (P1 -- P2) -- (circleB cutbefore P2 ) & cycle ; newcircleB := newcircleB xshifted 2in ;draw newcircleB withcolor black ;drawpoints newcircleA ; drawpointlabels newcircleA ;% Mikael solution newcircleA := circleA cutbefore P1 cutafter P2 -- cycle ;newcircleA := newcircleA yshifted -1.5in ;draw newcircleA  withcolor darkgreen ;drawpoints newcircleA ; drawpointlabels newcircleA ;% partial moon newcircleA := circleA cutbefore P1 cutafter P2 	.. reverse(circleB cutbefore P1 cutafter P2) .. cycle; %	& (reverse(circleB) cutbefore P2 cutafter P1) & cycle; newcircleA := newcircleA shifted(2in,-1.5in) ;draw newcircleA  withcolor magenta ;drawpoints newcircleA ; drawpointlabels newcircleA ;\stopMPpage% ———————Thanks for any help ! Fabrice./MikaelOn Mon, Dec 20, 2021 at 5:30 AM Fabrice L via ntg-context<ntg-context@ntg.nl> wrote:Dear list,I have a problem connecting path with the operator « & » (page 16 Metafun manual). The problem is illustrated by the code (and the joined PDF) which follows.I draw random cycled  forms (left part of the figure) and when they interact, they are modified to « fit together » (right part of the figure) . When building these new forms, I connect paths (usually two or three depending on position 0 of the path); the last point a path is the same as the first point of the next path ; for exemple, to modify the blue circle, named « circleA », I take the circle A from P1 to P2, then a segment from P2 to P1 and cycle to have a closed path. So I should be able to do :newcircleA := circleA cutbefore P1 cutafter P2 & (P2 -- P1) & cycle  ;The « & » operator is supposed to work (if I understand correctly) in this case, but I have this error message :"! Paths don't touch; `&' will be changed to `..’."Which I do not understand since the paths « touch ». There was a similar question last year, without a clear answer («METAPOST subpath rounding issue »https://www.mail-archive.com/ntg-context@ntg.nl/msg94294.html).A solution is to ignore the repeating points :newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle  ;but this new shape has 9 points instead of 7. The problem is that I do these operations a number of times, and the length of a path (in the number of points) is increasing and cause trouble when I look for intersections with others shapes.Here is the MWE:\startMPpagepath circleA , circleB ;pair P[];circleA := fullcircle scaled 1in randomized 3 ;circleB := fullcircle scaled 1in randomized 3 shifted(0.3in,0.3in) ;draw circleA withcolor blue ;draw circleB withcolor red ;P[1] := circleA intersectionpoint circleB ;dotlabel.lft("$P_1$",P[1]) ;dotlabel.rt("$\blue\tfx P_0^A$",point 0 of circleA) ;P[2] := reverse(circleA) intersectionpoint circleB ;dotlabel.rt("$P_2$",P[2]) ;dotlabel.rt(

[NTG-context] MP: problem connecting paths.

2021-12-19 Thread Fabrice L via ntg-context
Dear list,

I have a problem connecting path with the operator « & » (page 16 Metafun 
manual). The problem is illustrated by the code (and the joined PDF) which 
follows. 

I draw random cycled  forms (left part of the figure) and when they interact, 
they are modified to « fit together » (right part of the figure) . When 
building these new forms, I connect paths (usually two or three depending on 
position 0 of the path); the last point a path is the same as the first point 
of the next path ; for exemple, to modify the blue circle, named « circleA », I 
take the circle A from P1 to P2, then a segment from P2 to P1 and cycle to have 
a closed path. So I should be able to do :

newcircleA := circleA cutbefore P1 cutafter P2 & (P2 -- P1) & cycle  ;

The « & » operator is supposed to work (if I understand correctly) in this 
case, but I have this error message :

"! Paths don't touch; `&' will be changed to `..’."

Which I do not understand since the paths « touch ». There was a similar 
question last year, without a clear answer (« 
METAPOST subpath rounding issue 
»https://www.mail-archive.com/ntg-context@ntg.nl/msg94294.html). 

A solution is to ignore the repeating points :
newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle  ;
but this new shape has 9 points instead of 7. The problem is that I do these 
operations a number of times, and the length of a path (in the number of 
points) is increasing and cause trouble when I look for intersections with 
others shapes.

Here is the MWE:

\startMPpage
path circleA , circleB ;
pair P[];

circleA := fullcircle scaled 1in randomized 3 ;
circleB := fullcircle scaled 1in randomized 3 shifted(0.3in,0.3in) ;

draw circleA withcolor blue ;
draw circleB withcolor red ;

P[1] := circleA intersectionpoint circleB ;
dotlabel.lft("$P_1$",P[1]) ;
dotlabel.rt("$\blue\tfx P_0^A$",point 0 of circleA) ;
P[2] := reverse(circleA) intersectionpoint circleB ;
dotlabel.rt("$P_2$",P[2]) ;
dotlabel.rt("$\red\tfx P_0^B$",point 0 of circleB) ;

path newcircleA , newcircleB ;
% newcircleA := circleA cutbefore P1 cutafter P2 & (P2 -- P1) & cycle  ;
% previous line gives an error :
% "! Paths don't touch; `&' will be changed to `..'."
newcircleA := circleA cutbefore P1 cutafter P2 -- (P2 -- P1) -- cycle  ;
newcircleA := newcircleA xshifted 2in ;
draw newcircleA  withcolor darkgreen ;

newcircleB := (circleB cutafter P1)  -- (P1 -- P2) -- (circleB cutbefore P2 ) & 
cycle ; 
newcircleB := newcircleB xshifted 2in ;
draw newcircleB withcolor black ;
drawpoints newcircleA ; drawpointlabels newcircleA ;

\stopMPpage



test.pdf
Description: Adobe PDF document



I would appreciate any help ! Thanks ! 
Fabrice. 

___
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] Status of Asymptote

2021-12-06 Thread Fabrice L via ntg-context
Dear Gavin,

> Le 6 déc. 2021 à 10:11, Gavin via ntg-context  a écrit :
> 
> Hi Alex,
> 
> I don’t know the status of Asymptote. I am using TikZ and pgfplots for 3D, 
> with satisfactory results (example below). However, it is slow, so use the 
> buffer mechanism to prevent redrawing with every run.
> 
> TIkZ/pgfplots is the best short term solution for diagrams I need right now. 
> I am concerned that TikZ will eventually not work with ConTeXt, so for a long 
> term solution I am trying to make diagrams with Metapost, using Lua to do the 
> heavy computational work. This is not easy, but the diagrams are super fast, 
> and I think they will always work.

I would be very interested to see an example of a Metafun drawing made with the 
help of LuaTeX to speed up some calculations. 
Thanks ! 

> Hope that helps.
> Gavin

Fabrice.


___
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] Blocks inside a conditional mode.

2021-11-29 Thread Fabrice L via ntg-context
Dear Hans,

> Le 29 nov. 2021 à 03:54, Hans Hagen  a écrit :
> 
> On 11/29/2021 2:54 AM, Fabrice L via ntg-context wrote:
> 
>> The only inconvenient of this solution if that I have to define 15 blocks 
>> (one for each week of the term): ComplementOne, ComplementTwo, 
> \defineblock[example]
> 
> \starttext
> 
>   \beginexample[Two]
>   Last course, we have seen A.
>   \endexample
> 
>   \beginexample[Three]
>   Last course, we have seen B….
>   \endexample
> 
>   \beginexample[Three]
>   Last course, we have seen C….
>   \endexample
> 
>\useblocks[example][Two]
> % \useblocks[example][Three]
> 
> \stoptext
> 
> %


Thanks (again). ConTeXt is always full of ressource ! I did not know we could 
do this, even if I realized now that there is a similar example in the wiki. 

For the list, in case in the future this would be useful for another user, 
below is the complete minimal example using this approach.


% - Minimal working example :

\setuppapersize[S5][S5]
\enablemode[Professor]

\defineblock[Complement]
\setupblock[Complement][

before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]

\starttext

% Let's process the summaries  ;
\beginComplement[Two]
Last course, we have seen A.
\endComplement

\beginComplement[Three]
Last course, we have seen B….
\endComplement

\beginComplement[Three]
Last course, we have seen C….
\endComplementThree

\beginComplement[Four]
Last course, we have seen D….
\endComplementFour
\beginComplement
and E !
\endComplementFour
%  summaries: end   ;

Let's begin course 1. 
This is course 1 : a lot of pages here about A! 
\page[yes]

Let's begin course 2. 
\doifmode{Professor} {
\useblocks[Complement][Two]
}

This is course 2 : a lot of pages here about B and C! 

\page[yes]
Let's begin course 3. 
\doifmode{Professor} {
\useblocks[Complement][Three]
}   

This is course 3 : a lot of pages here about D... ! 
\doifmode{Professor} {
\useblocks[Complement][Four]
}   

The course 4 ! 
\stoptext

% - Minimal working example  : end 


Fabrice.

___
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] Blocks inside a conditional mode.

2021-11-28 Thread Fabrice L via ntg-context
Thanks Hraban for your answer, 

> Le 28 nov. 2021 à 15:42, Henning Hraban Ramm via ntg-context 
>  a écrit :
> 
> Am 28.11.21 um 19:39 schrieb Fabrice L via ntg-context:
>> I have an error when I try to insert a block inside a conditional mode (but 
>> there is two nested conditional mode.. is this the problem ?).
> 
> You can’t nest modes in \startmode ... \stopmode.
> I don’t know what are the limitations of \doifmode.

According to the wiki, we cannot nest several \startmode …\stopmode, but there 
is no limitation with \doifmode.

> 
> Maybe it helps to use additional grouping with {}, \bgroup .. \egroup or 
> \start .. \stop.

Following your advice, I tried with several {}, but no luck. 
> 
>> In my courses notes, I insert some blocks (named «  Complement » in the 
>> minimal exemple below) when in « Professor » mode. This works fine, as shown 
>> in the first «  \beginComplement … \endComplement  » of my example below.
> 
> Maybe you can work with buffers or (ConTeXt) blocks (the latter were recently 
> discussed here, it’s a quite unknown mechanism).

I already use blocks, but following your message, I tried to think differently. 
One solution would be to define a block for each course. Something like this (a 
working minimal example, redone in order this would be more easier to 
understand (I hope!) what I’m trying to do):

% —
\setuppapersize[S5][S5]
\enablemode[Professor]

\defineblock[ComplementTwo]
\defineblock[ComplementThree]

\setupblock[ComplementTwo,ComplementThree][

before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]
\starttext

% Let's process the summaries  ;
\beginComplementTwo
Last course, we have seen A.
\endComplementTwo

\beginComplementThree
Last course, we have seen B….
\endComplementThree

\beginComplementThree
Last course, we have seen C….
\endComplementThree
%  

Let's begin course 1. 
This is course 1 : a lot of pages here about A! 
\page[yes]

Let's begin course 2. 
\doifmode{Professor} {
\useblocks[ComplementTwo]
}

This is course 2 : a lot of pages here about B and C! 

\page[yes]
Let's begin course 3. 
\doifmode{Professor} {
\useblocks[ComplementThree]
}   

This is course 3 : a lot of pages here about D... ! 

\stoptext

%— 

The only inconvenient of this solution if that I have to define 15 blocks (one 
for each week of the term): ComplementOne, ComplementTwo, .., 
ComplementFithteen… Another drawback of this is difficult to move one block 
form one week to another if I change something. Each block here correspond in 
fact to a summary of the previous course. So I have typically around 10 pages 
of summary for each course. The challenge is that the content of each course is 
not exactly the same form one term to another, so I have to move a page to the 
summary from one course to the other one, like in a given term, if teach about 
subject C in course 3 :

\beginComplementThree
Last course, we have seen C….
\endComplementThree

, but next term in course 4:

\beginComplementFour
Last course, we have seen C….
\\beginComplementFour

I have to manually change \beginComplementThree … \endComplementThree to 
\beginComplementFour … \beginComplementFour.

But I will do this if I do not find another solution. 
Thanks again Hraban.
Fabrice. 

> 
> 
> Hraban
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki : http://contextgarden.net
> ___

___
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] Blocks inside a conditional mode.

2021-11-28 Thread Fabrice L via ntg-context
Dear list,

I have an error when I try to insert a block inside a conditional mode (but 
there is two nested conditional mode.. is this the problem ?).  

In my courses notes, I insert some blocks (named «  Complement » in the minimal 
exemple below) when in « Professor » mode. This works fine, as shown in the 
first «  \beginComplement … \endComplement  » of my example below. 

But now I have to use another condition for some blocks, depending of the 
number of the current course. So I insert my block with a condition, here « 
CourseOne » :

\enablemode[CourseOne]
\doifmode{CourseOne}{
\beginComplement
Another complementary slide. 
\endComplement
}

But this does not work :

% 
tex error   > tex error on line 1 in file 
/Users/fabricel/context/tex/texmf-context/tex/context/base/mkiv/cont-yes.mkiv: 
! TeX capacity exceeded, sorry [input stack size=5]
% 

The problem can be summarized in this minimal non working example : 

% — MWE —
\setuppapersize[S5][S5]
\enablemode[Professor]

\defineblock[Complement]
\setupblock[Complement][

before={\page[yes]\setuppagenumber[state=stop]\setupheadertexts[]\setupbackgrounds[page][background=color,backgroundcolor=red]},
after={\page[yes]\setuppagenumber[state=start]}]
\doifallmodes{Professor} {
\keepblocks[Complement]
}

\starttext

page 1

\beginComplement
A complementary slide. 
\endComplement

page 2

\enablemode[CourseOne]
\doifmode{CourseOne}{
\beginComplement
Another complementary slide but only for course number 1. 
\endComplement
}
\disablemode[CourseOne]

page 3

\enablemode[CourseTwo]
\doifmode{CourseTwo}{
\beginComplement
Another complementary slide but only for course number 2. 
\endComplement
}
\disablemode[CourseTwo]

\stoptext
\stoptext

% — MWE —

Blocks and modes usually works fine for me, but here, I do not understand my 
error.
Thanks for any help ! 

Fabrice. 


Note : in case this way of doing things seems a bit silly, here are more 
explanations. I do use mode « CourseOne »  here because in the real life, the 
content in the condition «  \doifmode{CourseOne}{ …} » is read in an external 
file, containing material for « CourseOne », « CourseTwo », etc. The setup is 
then, in the main file :

% Main file : begin 

Bla bla bla ...

\enablemode[CourseOne]
\input ComplementMaterial.tex
\disablemode[CourseOne]

Bla bla bla ...

\enablemode[CourseOne]
\input ComplementMaterial.tex
\disablemode[CourseOne]

% Main file : end 

And in the « ComplementMaterial.tex » there is :

% ComplementMaterial.tex —

\doifmode{CourseOne}{
\beginComplement
A complementary slide but only for course number 1. 
\endComplement

\beginComplement
Another complementary slide but only for course number 1. 
\endComplement
}

\doifmode{CourseTwo}{
\beginComplement
A complementary slide but only for course number 2. 
\endComplement

\beginComplement
Another complementary slide but only for course number 2. 
\endComplement
}
% ComplementMaterial.tex —

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___