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 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] Sudoku module

2022-07-18 Thread Otared Kavian via ntg-context
Hi Wolfgang,

Thank you for your reply and the explanations about the function « 
interfaces.implement ».

Regarding the examples given by Jairo, you are correct: those examples can be 
typeset with LMTX. I did a mistake when in TeXShop I saved the file « 
t-sudoku.mkvi » under the name « t-sudoku.tex »: indeed this creates an error 
in LMTX as well in earlier versions of ConTeXt… (maybe a colateral consequence 
of the heat wave in France :-)

I apologize to you and Jairo for having caused any trouble.

Best regards: Otared

> On 18 Jul 2022, at 22:10, Wolfgang Schuster via ntg-context 
>  wrote:
> 
> Otared Kavian via ntg-context schrieb am 18.07.2022 um 18:53:
>> Hi Wolfgang,
>> 
>> Thank you for your attention and the explanation regarding the « hash option 
>> » and why the sudoku module written by Jairo does not work. However I was 
>> reporting the issue when I tried to typeset the example file with LMTX 
>> (version 2022.07.06 21:42).
> 
> I have no problems with the examples at the end of the module and LMTX, only 
> when I use LuaTeX a error appears.
> 
>> As a matter of fact I am far from understanding what the « arguments = { « 
>> hash » } » is supposed to do in interfaces.implement in the code you sent…
> 
> The 'interfaces.implement' functions creates the command \test and 
> 'arguments={"hash"}' creates the argument which accepts key-val lists 
> ([text=Hello]).
> 
> Wolfgang
> 
> ___
> 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] Count (and limit) glyphs per line?

2022-07-18 Thread Benjamin Buchmuller via ntg-context
Dear Hans,

This is the friendly reminder you requested for the "crappyspecs" parbuilder as 
per your example in early July.

With 

ConTeXt  ver: 2022.07.06 21:42 LMTX  fmt: 2022.7.8

I get 

tex error > tex error on line 12 in file ./test-wrapping2.tex: Undefined 
control sequence \crappyspeccount

potentially as there is no crappyspec parbuilder yet?

\defineparbuilder [crappyspec] % implemented in the builder namespace 
\defineparbuilder [default] % implemented in the builder namespace
\setmainparbuilder[crappyspec]
\setuptolerance[verytolerant,stretch] \dontcomplain
\protected\def\CrappyTraced
{\par \strut \rlap \bgroup\infofont
(\enspace
max = \the\crappyspeccount \quad step = \the\crappyspecstep \quad hsize = 
\the\hsize \quad used = \the\crappyspecdimen \enspace
)
\egroup \par}
\starttext
\crappyspeccount60 \samplefile{tufte} \CrappyTraced \par
\crappyspeccount40 \samplefile{tufte} \CrappyTraced \par % \crappyspecstep 2pt 
\samplefile{tufte} \CrappyTraced \par
\samplefile{tufte} \CrappyTraced \startitemize
\startitem
\samplefile{tufte} \CrappyTraced
\stopitem
\startitem
\samplefile{ward} \CrappyTraced \stopitem
\stopitemize
\startnarrower[6*left,right] \samplefile{tufte} \CrappyTraced
\stopnarrower
\starthanging [distance=4em,n=2] {test} \samplefile{tufte} \CrappyTraced
\stophanging
\page % \stoptext \setuppapersize[landscape,letter]
\samplefile{knuth} \CrappyTraced \startitemize[width=5em]
\startitem
\samplefile{knuth} \CrappyTraced
\stopitem
\startitem
{\smallcaps \darkblue \samplefile{knuth}} \CrappyTraced \stopitem
\stopitemize
\crappyspeccount60 \startitemize[width=5em]
\startitem
\samplefile{knuth} \CrappyTraced
\stopitem
\startitem
{\smallcaps \darkgreen \samplefile{knuth}} \CrappyTraced \stopitem
\stopitemize
\page



Thank you once again for your help!


Benjamin

--

The problem with these thing is that there is more involved than just counting, 
like font features, hyphenation, current paragrph properties, etc. and you 
don't want interference with other features. You also want the paragraphs to 
look somewhat ok. Folks who enforce such demands on authors never wonder where 
the tools do do that come from (publishers and probably most designers are not 
interested in that anyway: thinking probably stops at the number '120').
Attached a proof of concept that gives an idea. No upload as first we need to 
do some wrapping up of math. Not that we needed something in the engine other 
than the linebreak helper to accept direct modes (no need to go back and forth 
then and i only want write this crap once). Could be a module although it's 
only some 70 lines of code in the end. Maybe it makes a nice (lmtx) demo for 
the ctx meeting too.
Here we work per paragraph not per line which looks better on the average. One 
could mess with parshapes but why bother.
(The todo in the name refers to the fact that it might do into a th elow level 
paragraph manual.)
(No more time now but we can add later; remind me if I forget.)

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
-

> On Jun 26, 2022, at 18:32, Max Chernoff  wrote:
> 
> On 2022-06-26 9:59 a.m., Benjamin Buchmuller wrote:
>> Hi Max,
>> Thank you so much for your help and pointing me to the documents; always a 
>> lot of things to learn in TeX!
> 
> No problem :)
> 
>> I'm afraid that including the hyphen width doesn't solve the issue yet. It 
>> seems to move the problem to other parts of the text.
> 
> Ah, too bad. My next step would have been to insert \penalty1's (prevent 
> breaks) at the potential breaks before/after the "selected" break, but Hans 
> provided a _much_ better solution that you should use instead.
> 
>> My guess is that one could equivalently have said "local max_length = 111", 
>> right?
> 
> Not really; the hyphen is added to the accumulated width, not the accumulated 
> character count.
> 
>> I made the following MWE (reproducible also online) to illustrate what I see:
> 
> My code assumes that each line has _roughly_ "max_length" characters before 
> it runs. These lines each only have ~60 characters, so I'm not entirely 
> surprised that there are issues. Just use Hans's solution, which is much less 
> of a total hack than this is :)
> 
>> * Running with hsize only makes the problem worse in itemizations, so I 
>> think localhsize is the way to go. My guess, localhsize is the width of the 
>> "text" part of a paragraph, for example, excluding the symbols in the 
>> itemization.
> 
> I forgot about \leftskip. Replace "tex.hsize" with "tex.hsize - 
> tex.leftskip.width" and everything should work properly. Using localhsize 
> would also work, whenever it's non-zero.
> 

Re: [NTG-context] Set up external figure for particular image type

2022-07-18 Thread Wolfgang Schuster via ntg-context

Thangalin via ntg-context schrieb am 18.07.2022 um 19:10:

Thank you, Wolfgang.

That looks promising.

SVG files are converted using MetaPost. I thought the following would 
work:


svg=>{\externalfigure[#1][svg][conversion=mp]}


You can probably remove the second argument ([svg]) which was used in my 
example to pass the default values with \defineexternalfigure. Just 
using \externalfigure[#1][conversion=mp] where you pass the default 
values with the second argument is enough.


Wolfgang

___
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] Sudoku module

2022-07-18 Thread Wolfgang Schuster via ntg-context

Otared Kavian via ntg-context schrieb am 18.07.2022 um 18:53:

Hi Wolfgang,

Thank you for your attention and the explanation regarding the « hash option » 
and why the sudoku module written by Jairo does not work. However I was 
reporting the issue when I tried to typeset the example file with LMTX (version 
2022.07.06 21:42).


I have no problems with the examples at the end of the module and LMTX, 
only when I use LuaTeX a error appears.



As a matter of fact I am far from understanding what the « arguments = { « hash 
» } » is supposed to do in interfaces.implement in the code you sent…


The 'interfaces.implement' functions creates the command \test and 
'arguments={"hash"}' creates the argument which accepts key-val lists 
([text=Hello]).


Wolfgang

___
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] How to setup a headertext in a doublesided document in a cld?

2022-07-18 Thread Wolfgang Schuster via ntg-context

Willi Egger via ntg-context schrieb am 16.07.2022 um 17:03:

Hello!

I tried to setup a headertext in a context-lua-document. — No problem for the 
singlesided version, however hoe to pass the info for a double sided version?
Unfortunately the cld-mkiv manual contains an example for a singlesided 
document.

It ried

context.setupheadertexts({
  function()
context("\\bf”)
context.labeltext(monthname)
context("\\hfill”)
context(year)
   end},
   {function()
 context("\\bf”)
 context.labeltext(monthname)
 context("\\hfill”)
 context(year)
  end})

but this is apparently not the good approach.

Does someone of you have experience how to do this correctly?


What is the desired layout/content for the header?

You're using monthname and year in your example but do they come from, a 
proper minimal example can help here.


Is it even necessary to set the header with Lua or can't you use a 
regular TeX file and load it afterwards as environment file when you 
process your document (context --environment=mystyle.tex mydocument.cld).


Wolfgang

___
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] How to switch off the numbering of a float in a CLDocument?

2022-07-18 Thread Henning Hraban Ramm via ntg-context

Am 18.07.22 um 20:31 schrieb Willi Egger via ntg-context:

Hi all,

I wanted to place a figure in a cld. The example in the cld manual does not 
reveal how to influence bahavior except for the caption.

context.placefigure(
  “caption”,
 function() context.externalfigure({i}, { width = "\\textwidth" } ) end )

Can anybody enlighten me?


Just use

context.startplacefigure({ option = "some", otheroption = "thing" })
...
context.stopplacefigure()

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] How to switch off the numbering of a float in a CLDocument?

2022-07-18 Thread Willi Egger via ntg-context
Hi all,

I wanted to place a figure in a cld. The example in the cld manual does not 
reveal how to influence bahavior except for the caption.

context.placefigure(
 “caption”,
function() context.externalfigure({i}, { width = "\\textwidth" } ) end )

Can anybody enlighten me?

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 / 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 Hans van der Meer via ntg-context
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] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Thank you, Wolfgang.

That looks promising.

SVG files are converted using MetaPost. I thought the following would work:

svg=>{\externalfigure[#1][svg][conversion=mp]}

Is there anything else that needs to happen to ensure SVG files are piped
through MetaPost?

Thanks again!



> \setupexternalfigures [location={local,global,default}]
>
> \defineexternalfigure [jpg] [width=4cm]
> \defineexternalfigure [png] [width=8cm]
>
> \starttexdefinition includegraphics #1
>
> \splitfilename{#1}
>
> \processaction
> [\splitofftype]
> [jpg=>{\externalfigure[#1][jpg]},
>  png=>{\externalfigure[#1][png]},
>  default=>{\externalfigure[#1]},
>  unknown=>{\externalfigure[#1]}]
>
> \stoptexdefinition
>
> \starttext
>
> \includegraphics{hacker.jpg}
>
> \includegraphics{mill.png}
>
> \includegraphics{cow.pdf}
>
> \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
___


Re: [NTG-context] Sudoku module

2022-07-18 Thread Otared Kavian via ntg-context
Hi Wolfgang,

Thank you for your attention and the explanation regarding the « hash option » 
and why the sudoku module written by Jairo does not work. However I was 
reporting the issue when I tried to typeset the example file with LMTX (version 
2022.07.06 21:42). 
As a matter of fact I am far from understanding what the « arguments = { « hash 
» } » is supposed to do in interfaces.implement in the code you sent…

Best regards: Otared

> On 18 Jul 2022, at 17:39, Wolfgang Schuster via ntg-context 
>  wrote:
> 
> Otared Kavian via ntg-context schrieb am 18.07.2022 um 17:00:
>> Hi Jairo,
>> 
>> You sent a message last year about your Sudoku module, and today, out of 
>> curiosity, I wanted to test it. Unfortunately it stops with an error message 
>> at line 76 of the file t-sudoku.mkiv, where you have:
>> 
>> \def\sudokufunction_direct[#name][#parameters]#content
>> 
>> I would appreciate if you could tell me whether you have a working version 
>> of you module, or what one has to change in order to typeset your examples.
> 
> The error is unrelated to the sudoku module and when you use LMTX the error 
> disappears.
> 
> The real problem can be seen in the following minimal example and is related 
> to the "hash" option for the argument key.
> 
>  begin example
> \starttext
> 
> \startluacode
> interfaces.implement {
> name  = "test",
> public= true,
> arguments = { "hash" },
> actions   = function(t)
> print(table.serialize(t))
> end,
> }
> \stopluacode
> 
> \test[text=Hello]
> 
> \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 / 
> 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 ?

2022-07-18 Thread Hans Hagen via ntg-context

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] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Of course, you could also use pandoc to go directly to ConTeXt; that is
> currently my preferred way of producing PDF from Markdown.
>

Thanks Albert!

I'm going to stick with my desktop text editor, KeenWrite
, rather than use shell scripts
 and
pandoc.

Cheers!
___
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] Set up external figure for particular image type

2022-07-18 Thread Thangalin via ntg-context
Thanks, Rik.

Not using Pandoc. I was using Pandoc up until 2020:

https://dave.autonoma.ca/blog/2019/05/22/typesetting-markdown-part-1/

I've since authored KeenWrite ,
which uses flexmark-java  to
generate XHTML documents from Markdown. The only additions I've made to the
library is to add support for Pandoc's annotation syntax (:::).

That said, I'm also a firm believer in not duplicating information. The
information (file name extension) is already available in the documents, so
adding a classification on top of the extension feels redundant.

Thanks for the suggestion!

On Tue, Jul 12, 2022 at 12:18 PM Rik Kabel via ntg-context <
ntg-context@ntg.nl> wrote:

>
> On 2022-07-12 14:11, Thangalin via ntg-context wrote:
>
> Thank you for the suggestion Hraban.
>
> The source comes from Markdown, which is converted to XML, then typeset
> using ConTeXt. There's no Markdown-specific mechanism to relate images to a
> particular external figure definition, unfortunately. All images use the
> same syntax and are treated the same way. The only part that differs is the
> file name extension (and header within the file).
>
> One possibility would be something like:
>
> \setupexternalfigure[
> width=1em,
> height=1em,
> order={svg,pdf,png,jpg},
> location={local,default,global},
> ]
> \defineexternalfigure[png][
> width=\textwidth,
> height=\textheight,
> ]
> \unprotect
> \let\old_externalfigure=\externalfigure
> \tolerant\def\externalfigure[#1]#,[#2]#,[#3]{%
> \doifelseinstring{.png}{#1}{%
> \old_externalfigure[#1][png][#2]%
> }{%
> \doifelsefileexists{#1.png}{%
> \old_externalfigure[#1.png][png][#2]%
> }{%
> \old_externalfigure[#1][#2][#3]%
> }%
> }%
> }\protect
>
> See: https://tex.stackexchange.com/a/650221/2148
>
> I was wondering if there was a simpler or a solution that's more the
> ConTeXt-way?
>
> Thanks again!
>
>
> Assuming that Pandoc markdown is being used, you should be able to set
> class attributes on each image. You can then associate external figure
> definitions with specific classes, and process each individually. (Pandoc
> user guide, link_attributes
> )
>
> --
> Rik
>
>
> ___
> 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] Sudoku module

2022-07-18 Thread Jairo A. del Rio via ntg-context
Hi. Sorry. I didn't see your message and I had forgotten the very existence
of the module. I'll check it later (final exam weeks for me) so that it
works with MkIV and LMTX properly again. By the way, thanks for the
interest.

Best regards

Jairo

El lun., 18 de jul. de 2022 10:00 a. m., Otared Kavian 
escribió:

> Hi Jairo,
>
> You sent a message last year about your Sudoku module, and today, out of
> curiosity, I wanted to test it. Unfortunately it stops with an error
> message at line 76 of the file t-sudoku.mkiv, where you have:
>
> \def\sudokufunction_direct[#name][#parameters]#content
>
> I would appreciate if you could tell me whether you have a working version
> of you module, or what one has to change in order to typeset your examples.
>
> 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 / 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 Hans Hagen via ntg-context

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] Sudoku module

2022-07-18 Thread Wolfgang Schuster via ntg-context

Otared Kavian via ntg-context schrieb am 18.07.2022 um 17:00:

Hi Jairo,

You sent a message last year about your Sudoku module, and today, out of 
curiosity, I wanted to test it. Unfortunately it stops with an error message at 
line 76 of the file t-sudoku.mkiv, where you have:

\def\sudokufunction_direct[#name][#parameters]#content

I would appreciate if you could tell me whether you have a working version of 
you module, or what one has to change in order to typeset your examples.


The error is unrelated to the sudoku module and when you use LMTX the 
error disappears.


The real problem can be seen in the following minimal example and is 
related to the "hash" option for the argument key.


 begin example
\starttext

\startluacode
interfaces.implement {
    name  = "test",
    public    = true,
    arguments = { "hash" },
    actions   = function(t)
    print(table.serialize(t))
    end,
}
\stopluacode

\test[text=Hello]

\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 / 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] Sudoku module

2022-07-18 Thread Otared Kavian via ntg-context
Hi Jairo,

You sent a message last year about your Sudoku module, and today, out of 
curiosity, I wanted to test it. Unfortunately it stops with an error message at 
line 76 of the file t-sudoku.mkiv, where you have:

\def\sudokufunction_direct[#name][#parameters]#content

I would appreciate if you could tell me whether you have a working version of 
you module, or what one has to change in order to typeset your examples.

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 / 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 Henning Hraban Ramm via ntg-context

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 ?

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
___