ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metafun : save memory content ?
@ 2022-07-18 13:20 Fabrice L via ntg-context
  2022-07-18 14:39 ` Henning Hraban Ramm via ntg-context
  2022-07-18 16:31 ` Hans Hagen via ntg-context
  0 siblings, 2 replies; 8+ messages in thread
From: Fabrice L via ntg-context @ 2022-07-18 13:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Fabrice L

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-07-20  3:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 13:20 Metafun : save memory content ? Fabrice L via ntg-context
2022-07-18 14:39 ` Henning Hraban Ramm via ntg-context
2022-07-18 15:45   ` Hans Hagen via ntg-context
2022-07-18 16:31 ` Hans Hagen via ntg-context
2022-07-18 17:53   ` Hans van der Meer via ntg-context
2022-07-19  3:28   ` Fabrice L via ntg-context
2022-07-19 11:42     ` Bruce Horrocks via ntg-context
2022-07-20  3:01       ` Fabrice L via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).