Re: [NTG-context] Metapost Animation of Sine

2021-07-22 Thread Otared Kavian
Hi Jeroen,

Unfortunately I am not familiar with Tikz, since all my documents use what is 
built-in ConTeXt and Metapost…
That being said I am sure someone on the list can help you with Tikz module.

Best regards: Otared

> On 22 Jul 2021, at 14:28, Jeroen  wrote:
> 
> Hi, both solutions are great! This is what I had in mind, a rolling sine. Is 
> there a way to get the same result with the Tikz module?
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> 
> \starttext
> 
> \input tufte
> 
> \framed{
> \startanimation[menu=yes,framerate=40]
> \dorecurse{50}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 : 
> .. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> }
> 
> \stoptext
> 
> Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian  >:
> Hi, 
> 
> I wonder whether something like the following is what you are looking for:
> 
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
> \dorecurse{100}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 
> upto 100 : 
> .. 
> (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor 
> darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
> 
> Best regards: OK
> 
> > On 21 Jul 2021, at 19:44, Jeroen  > > wrote:
> > 
> > I am looking for a sine animation as the one file f.pdf on this site
> > 
> > http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> >  
> > 
> > 
> > Jeroen
> > 
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L  > >:
> > Hi,
> > 
> >> Le 21 juill. 2021 à 10:08, Jeroen  >> > a écrit :
> >> 
> >> I use this small animation to enlarge a circle
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := fullcircle scaled n;
> >> draw p;
> >> \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >> 
> >> 
> >> This I use to draw a sine
> >> 
> >> 
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> >> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >> 
> >> 
> >> When I put it together to animate the sine as following, it does not 
> >> entirely create the sine animation I am looking for
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> >> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >> draw p;
> >> \stopMPcode
> >> \stopframe}}
> >> \stopanimation
> >> \stoptext
> >> 
> >> 
> >> What better way can I create a sine animation with Metapost?
> >>  
> >> 
> > 
> > Here is another way to do your animation. This is doing something, but I 
> > guess not what you want. Could you describe what do you have in mind ?
> > 
> > \starttext
> > \dorecurse{7}{ % 3180
> > \startMPpage
> >   myvariable := #1 ;
> >   path p;
> > numeric n, u;
> > u := 1cm;
> > n:=myvariable*u;
> > p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> > (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> > draw p;
> > \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 

Re: [NTG-context] Metapost Animation of Sine

2021-07-22 Thread Jeroen
Hi, both solutions are great! This is what I had in mind, a rolling sine.
Is there a way to get the same result with the Tikz module?

\usemodule[animation]
\setupinteraction[state=start]

\starttext

\input tufte

\framed{
\startanimation[menu=yes,framerate=40]
\dorecurse{50}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel ;
path p ;
p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 :
.. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
}

\stoptext

Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian :

> Hi,
>
> I wonder whether something like the following is what you are looking for:
>
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
> \dorecurse{100}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1
> upto 100 :
> ..
> (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor
> darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
>
> Best regards: OK
>
> > On 21 Jul 2021, at 19:44, Jeroen  wrote:
> >
> > I am looking for a sine animation as the one file f.pdf on this site
> >
> >
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> >
> > Jeroen
> >
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> > Hi,
> >
> >> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
> >>
> >> I use this small animation to enlarge a circle
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := fullcircle scaled n;
> >> draw p;
> >> \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> This I use to draw a sine
> >>
> >>
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >>
> >>
> >> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >> \startMPcode
> >> path p;
> >> numeric n, u;
> >> u := 1cm;
> >> n:=\recurselevel*u;
> >> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >> draw p;
> >> \stopMPcode
> >> \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> What better way can I create a sine animation with Metapost?
> >>
> >>
> >
> > Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
> >
> > \starttext
> > \dorecurse{7}{ % 3180
> > \startMPpage
> >   myvariable := #1 ;
> >   path p;
> > numeric n, u;
> > u := 1cm;
> > n:=myvariable*u;
> > p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> > draw p;
> > \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 / 

Re: [NTG-context] Metapost Animation of Sine

2021-07-21 Thread Otared Kavian
Hi,

Adding to my previous message, if you are looking for an animation of the wave 
equation for a string with fixed endpoints, one has to use something like the 
following:

% begin wave-sine-string.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
\dorecurse{101}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt, N ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel - 1 ;
N := 500 ; % number of steps
path p ;
p := (0u,0u) for i = 1 upto N : 
-- 
(((mylength/N)*i)*u,cos(omega*(mylength/N)*tt)*sin(omega*(mylength/N)*i)*u) 
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine-string.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen  wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := fullcircle scaled n;
>> draw p;
>> \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not 
>> entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>> draw p;
>> \stopMPcode
>> \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I 
> guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
>   myvariable := #1 ;
>   path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \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
> ___

___
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] Metapost Animation of Sine

2021-07-21 Thread Otared Kavian
Hi, 

I wonder whether something like the following is what you are looking for:

% begin wave-sine.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
\dorecurse{100}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel ;
path p ;
p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 
100 : 
.. 
(((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen  wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := fullcircle scaled n;
>> draw p;
>> \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not 
>> entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>> \startMPcode
>> path p;
>> numeric n, u;
>> u := 1cm;
>> n:=\recurselevel*u;
>> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
>> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>> draw p;
>> \stopMPcode
>> \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I 
> guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
>   myvariable := #1 ;
>   path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \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
> ___

___
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] Metapost Animation of Sine

2021-07-21 Thread Jeroen
I am looking for a sine animation as the one file f.pdf on this site

http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm

Jeroen

Op wo 21 jul. 2021 om 17:54 schreef Fabrice L :

> Hi,
>
> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
>
> I use this small animation to enlarge a circle
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := fullcircle scaled n;
> draw p;
> \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
>
>
> This I use to draw a sine
>
>
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
>
>
> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPcode
> \stopframe}}
> \stopanimation
> \stoptext
>
>
> What better way can I create a sine animation with Metapost?
>
>
>
>
> Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
>
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
> myvariable := #1 ;
> path p;
> numeric n, u;
> u := 1cm;
> n:=myvariable*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \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] Metapost Animation of Sine

2021-07-21 Thread Fabrice L
Hi,

> Le 21 juill. 2021 à 10:08, Jeroen  a écrit :
> 
> I use this small animation to enlarge a circle
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := fullcircle scaled n;
> draw p;
> \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> This I use to draw a sine
> 
> 
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
> 
> 
> When I put it together to animate the sine as following, it does not entirely 
> create the sine animation I am looking for
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
> \startMPcode
> path p;
> numeric n, u;
> u := 1cm;
> n:=\recurselevel*u;
> p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> draw p;
> \stopMPcode
> \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> What better way can I create a sine animation with Metapost?
>  
> 

Here is another way to do your animation. This is doing something, but I guess 
not what you want. Could you describe what do you have in mind ?

\starttext
\dorecurse{7}{ % 3180
\startMPpage
myvariable := #1 ;
path p;
numeric n, u;
u := 1cm;
n:=myvariable*u;
p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. 
(i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
draw p;
\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
___


[NTG-context] Metapost Animation of Sine

2021-07-21 Thread Jeroen
I use this small animation to enlarge a circle


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
\startMPcode
path p;
numeric n, u;
u := 1cm;
n:=\recurselevel*u;
p := fullcircle scaled n;
draw p;
\stopMPcode
  \stopframe}}
\stopanimation
\stoptext


This I use to draw a sine


\starttext
\startMPcode
  draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i)))endfor;
\stopMPcode
\stoptext


When I put it together to animate the sine as following, it does not
entirely create the sine animation I am looking for


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
\startMPcode
path p;
numeric n, u;
u := 1cm;
n:=\recurselevel*u;
p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
draw p;
\stopMPcode
\stopframe}}
\stopanimation
\stoptext


What better way can I create a sine animation with Metapost?
___
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] MetaPost Animation

2010-04-16 Thread Boštjan Vesnicer
Hi Troy

Here is a simple solution:

\def\MyGraphics#1{%
\startMPcode
path p,q;
p:=fullcircle scaled 72;
L:=length p;
N:=20;
q:=subpath (0,#1/N*L) of p;
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q withcolor blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75;
\stopMPcode}

\starttext
\dostepwiserecurse{0}{20}{1}{%
\startTEXpage
\MyGraphics{\recurselevel}
\stopTEXpage}
\stoptext

Regards, Bostjan

On Thu, Apr 15, 2010 at 7:53 PM, Troy Henderson thend...@gmail.com wrote:

 I am trying to create an animation in ConTeXt + MetaPost.  In
 particular, I would like to have ConTeXt + MetaPost generate each
 individual frame of the animation, and then I would like to place each
 of these graphics on the page in succession.  I am looking for a
 ConTeXt way without placing the MetaPost code in a separate source
 file, running MetaPost, and using \externalfigure.  The following
 MetaPost sample code generate 21 graphics images  (numbered .0 to
 .20), but I have no idea how to have ConTeXt generate these graphics
 without a manual external MetaPost run and have them included in a way
 that is consistent with \startuseMPgraphic or similar.

 Thanks in advance,

 Troy Henderson

 path p,q;
 p:=fullcircle scaled 72;
 L:=length p;
 N:=20;
 for n=0 upto N:
beginfig(n);
q:=subpath (0,n/N*L) of p;
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q
 withcolor blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5)
 scaled 75;
endfig;
 endfor;
 end


 --
 Troy Henderson
 Assistant Professor
 Department of Mathematics
 University of Mobile
 http://www.tlhiv.org

 ___
 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://tex.aanhet.net
 archive  : http://foundry.supelec.fr/projects/contextrev/
 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] MetaPost Animation

2010-04-16 Thread Hans Hagen

On 16-4-2010 9:36, Boštjan Vesnicer wrote:

Hi Troy

Here is a simple solution:

\def\MyGraphics#1{%
\startMPcode
path p,q;
p:=fullcircle scaled 72;
L:=length p;
N:=20;
q:=subpath (0,#1/N*L) of p;
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q withcolor blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75;
\stopMPcode}

\starttext
\dostepwiserecurse{0}{20}{1}{%
\startTEXpage
\MyGraphics{\recurselevel}
\stopTEXpage}
\stoptext


or, if you want to fool yourself that you're not using tex ... put this 
in somefile.cld:


-- --

local template = [[
path p, q ;
p := fullcircle scaled 72 ;
L := length p ;
N := 20 ;
q:=subpath (0,%s/N*L) of p ;
draw q withcolor red ;
fill fullcircle scaled 3 shifted point length q of q withcolor blue ;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75 ;
]]

context.starttext()
for i=0,20 do
context.startMPpage()
context(template,i)
context.stopMPpage()
end
context.stoptext()

-- --

and then run:

context somefile.cld




-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] MetaPost Animation

2010-04-16 Thread Troy Henderson
 \def\MyGraphics#1{%

Thanks for the replies folks.  The example that I posted is a simple
example.  The example that I'm working on (displaying successive terms
in a Taylor series) requires a bit of computations, and I don't want
to have to go back and do each computation for each value of #1.  That
is, I want to build a table of numerical values (numeric Y[][]) and be
able to address those values from my \startMPcode section.

If I have two different \startMPcode ... \stopMPcode sections, is
there a way (perhaps it does this by default) to have the variables
stored in the first block available in the second block?  In pure
MetaPost, I can do

numeric a:=4;
beginfig(1);
label(decimal(a),origin);
endfig;
beginfig(2);
label(decimal(a),origin);
endfig;
end

and both figures have the value of 'a' available to them because 'a'
was defined before each figure.  What is the ConTeXt way of doing
this?

Thanks,

Troy
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] MetaPost Animation

2010-04-16 Thread Boštjan Vesnicer

 If I have two different \startMPcode ... \stopMPcode sections, is
 there a way (perhaps it does this by default) to have the variables
 stored in the first block available in the second block?  In pure
 MetaPost, I can do

 numeric a:=4;
 beginfig(1);
label(decimal(a),origin);
 endfig;
 beginfig(2);
label(decimal(a),origin);
 endfig;
 end

 and both figures have the value of 'a' available to them because 'a'
 was defined before each figure.  What is the ConTeXt way of doing
 this?


Do you mean something like this?

\starttext
\startMPpage
a := 4;
label(decimal a, origin);
\stopMPpage
\startMPpage
a := a+1;
label(decimal a, origin);
\stopMPpage
\stoptext

Regards, Bostjan
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] MetaPost Animation

2010-04-16 Thread Wolfgang Schuster

Am 16.04.10 14:51, schrieb Troy Henderson:

If I have two different \startMPcode ... \stopMPcode sections, is
there a way (perhaps it does this by default) to have the variables
stored in the first block available in the second block?  In pure
MetaPost, I can do

numeric a:=4;
beginfig(1);
 label(decimal(a),origin);
endfig;
beginfig(2);
 label(decimal(a),origin);
endfig;
end

and both figures have the value of 'a' available to them because 'a'
was defined before each figure.  What is the ConTeXt way of doing
this?
   

\starttext
\startluacode
local a = 0
for i=1,10 do
a = a + 1
context.startMPpage()
-- context('label(%d,origin);',a)
context('label(textext(%d),origin);',a)
context.stopMPpage()
end
\stopluacode
\stoptext

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

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] MetaPost Animation

2010-04-15 Thread Troy Henderson
I am trying to create an animation in ConTeXt + MetaPost.  In
particular, I would like to have ConTeXt + MetaPost generate each
individual frame of the animation, and then I would like to place each
of these graphics on the page in succession.  I am looking for a
ConTeXt way without placing the MetaPost code in a separate source
file, running MetaPost, and using \externalfigure.  The following
MetaPost sample code generate 21 graphics images  (numbered .0 to
.20), but I have no idea how to have ConTeXt generate these graphics
without a manual external MetaPost run and have them included in a way
that is consistent with \startuseMPgraphic or similar.

Thanks in advance,

Troy Henderson

path p,q;
p:=fullcircle scaled 72;
L:=length p;
N:=20;
for n=0 upto N:
beginfig(n);
q:=subpath (0,n/N*L) of p;
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q withcolor 
blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) 
scaled 75;
endfig;
endfor;
end


-- 
Troy Henderson
Assistant Professor
Department of Mathematics
University of Mobile
http://www.tlhiv.org
___
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Metapost animation

2005-05-19 Thread Mojca Miklavec
Hans Hagen wrote:
Michal Kvasnicka wrote:
Hm. Do you quote the Metafun manual, section 13.6? I know this 
technique. But my question was different: Is it possible to `animate' 
the fieldstack? In other words, to make it change one figure to 
another automatically, without clicking anywhere, changing one frame 
to another each 1/n second to simulate a smoth motion like in a cinema? 
sure, you can let a javascript toggle the states; however, small steps 
(1 sec) are not to be trusted in precission, since they also depend on 
the machine; they also kind of block other actions since there is no 
concept of animation in pdf (apart from svg, which is poorly 
implemented/integrated).  
Another method is demonstrated in the 'dante XV' presentation (runs 
slightly faster on a mac than on windows);
Hans
Can someone please post any example of JavaScript code to toggle the 
states like in either http://www.math.muni.cz/~plch/nkpm/nradanm6.pdf 
or https://www.pragma-pod.com/present/talks/fifteen.pdf?

I produced the graphics as explained in the section 13.6 of the metafun 
manual, but I would like to press the button only once at the beginning 
of the animation instead of twenty times.

Thank you very much,
Mojca Miklavec
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Metapost animation

2005-05-19 Thread luigi.scarso
Mojca Miklavec wrote:
Can someone please post any example of JavaScript code to toggle the 
states like in either http://www.math.muni.cz/~plch/nkpm/nradanm6.pdf 
or https://www.pragma-pod.com/present/talks/fifteen.pdf?

I hope this can help you:
http://www.fi.muni.cz/~xholecek/animations/
luigi
___
ntg-context mailing list
ntg-context@ntg.nl
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Metapost animation

2004-09-16 Thread Michal Kvasnicka
Good evening.
Many thanks for your answer. If it doesn't work for `small steps (1s)', 
it's probably useless, since for a smooth motion at least 15 frames per 
seconds are needed. But anyway, what is `svg'? Where can I see `dante XV 
presentation'?

And one more question: Is sounds as system-dependent as movies? If not, 
how can I integrate it in a PDF document?

Many thanks and greetings.
Yours
Michal Kvasnicka
sure, you can let a javascript toggle the states; however, small steps 
(1 sec) are not to be trusted in precission, since they also depend 
on the machine; they also kind of block other actions since there is 
no concept of animation in pdf (apart from svg, which is poorly 
implemented/integrated).  
Another method is demonstrated in the 'dante XV' presentation (runs 
slightly faster on a mac than on windows);
Hans 

___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Metapost animation

2004-09-15 Thread Hans Hagen
Michal Kvasnicka wrote:
Hm. Do you quote the Metafun manual, section 13.6? I know this 
technique. But my question was different: Is it possible to `animate' 
the fieldstack? In other words, to make it change one figure to 
another automatically, without clicking anywhere, changing one frame 
to another each 1/n second to simulate a smoth motion like in a cinema?
sure, you can let a javascript toggle the states; however, small steps (1 sec) are not to be trusted in precission, since they also depend on the machine; they also kind of block other actions since there is no concept of animation in pdf (apart from svg, which is poorly implemented/integrated).   

Another method is demonstrated in the 'dante XV' presentation (runs slightly faster on a mac than on windows); 

Hans 

-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


Re: [NTG-context] Metapost animation

2004-09-14 Thread Hans Hagen
Michal Kvasnicka wrote:
Now to my next question. I have seen a great thing: Metapost pictures 
were animated (probably with the JavaScript code). You can found some 
examples here:
   http://www.math.muni.cz/~plch/nkpm/nradanm6.pdf
   http://www.math.muni.cz/~plch/nkpm/nradanm8.pdf
(Just click on the `Spustit animaci' button.)
it's in the metafun manual 

that kind of trickery has been present in context for a long time, but unfortunately it's not always available on each platform 

(apart from the fact that each version of acrobat has its own side effects) 

Hans 

-
 Hans Hagen | PRAGMA ADE
 Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
| www.pragma-pod.nl
-
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context


[NTG-context] Metapost animation

2004-09-13 Thread Michal Kvasnicka
Good evening.
First of all I want to thank to Mr. Hagen for his last answer. I will 
check your last code of balanced columnsets at home (with the newest 
ConTeXt). As for your correcting code for ordinary collumns, I have 
tried it with three different types of my documents, and it worked well. 
Maybe this is the final solution of the problem. I will try it with more 
documents and let you know, anyway.

Now to my next question. I have seen a great thing: Metapost pictures 
were animated (probably with the JavaScript code). You can found some 
examples here:
   http://www.math.muni.cz/~plch/nkpm/nradanm6.pdf
   http://www.math.muni.cz/~plch/nkpm/nradanm8.pdf
(Just click on the `Spustit animaci' button.)

Is it possible to do it simply in the ConTeXt? Of course I may break 
down the mechanism of widgets and write my own JavaScript (I don't know 
how to do timing), but isn't there some special macro for animating 
series of figures? It would be great.

If so, is Acrobat Reader fast enough to simulate this way the nice 
feature of MS PowerPoint---curves and shapes that are drawn by pieces, 
or that appear somewhere and then go to its final location? (This is 
quite instructive in economics, because you can easily notice which 
curve is drawn first, what second, and so on.) How can I do it?

With many greetings and thanks
Michal Kvasnicka
___
ntg-context mailing list
[EMAIL PROTECTED]
http://www.ntg.nl/mailman/listinfo/ntg-context