ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metapost Animation of Sine
@ 2021-07-21 14:08 Jeroen
  2021-07-21 15:54 ` Fabrice L
  0 siblings, 1 reply; 7+ messages in thread
From: Jeroen @ 2021-07-21 14:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1135 bytes --]

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?

[-- Attachment #1.2: Type: text/html, Size: 1817 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

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

end of thread, other threads:[~2021-07-22 20:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 14:08 Metapost Animation of Sine Jeroen
2021-07-21 15:54 ` Fabrice L
2021-07-21 17:44   ` Jeroen
2021-07-21 21:26     ` Otared Kavian
2021-07-22 12:28       ` Jeroen
2021-07-22 20:38         ` Otared Kavian
2021-07-21 21:45     ` Otared Kavian

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).