Changes

Jump to navigation Jump to search
no edit summary
path TheFrame ;
TheFrame := fullsquare scaled 80 ;
% the code... setbounds currentpicture to TheFrame ;
\stopMPpage
</texcode>
 
It is a good idea to perform declarations and calculations only once, and therefore, to place them in `MPinclusions` before the drawings are actually done. Since we intend to move a particle along a path, the position of the particle depends on the current frame. This information will be stored in the variable `currentframe`. In the simplest case, the current frame corresponds to the value of the loop `dorecurse`, which can be accessed using `currentframe := #1;`. The position of the object will be determined by `currentframe/TotalNbFrames` along the path. Now, we are ready for the complete code :
<texcode>
\starttext
\startMPinclusions
path TheFrame ; TheFrame := fullsquare scaled 80 ;
path ThePath , TheObject , ObjectInMovement ;
ThePath := fullcircle scaled 50 ;
TheObject := fullcircle scaled 8 ;
TotalNbFrames := 300 ;
\stopMPinclusions
 
\dorecurse{300}{
\startMPpage
currentframe := #1;
ObjectInMovement := TheObject shifted
(point (currentframe/TotalNbFrames) along ThePath );
draw ThePath withcolor blue ;
fill ObjectInMovement withcolor red ;
setbounds currentpicture to TheFrame ;
 
\stopMPpage }
\stoptext
</texcode>
36

edits

Navigation menu